merged ArstractProperty, pac-prefix editor everywhere
| | |
| | | package de.hsadmin.web; |
| | | |
| | | public class AbstractProperty { |
| | | public abstract class AbstractProperty { |
| | | |
| | | public abstract Object toXmlrpcParam(); |
| | | |
| | | } |
| | |
| | | import de.hsadmin.web.config.PropertyDefaultValue; |
| | | import de.hsadmin.web.config.PropertySelectValues; |
| | | import de.hsadmin.web.config.PropertyTableColumn; |
| | | import de.hsadmin.web.vaadin.PacPrefixedNamePropertyFieldFactory; |
| | | import de.hsadmin.web.vaadin.SelectPropertyFieldFactory; |
| | | |
| | | public abstract class DatabaseModule extends GenericModule { |
| | |
| | | protected void initModule() { |
| | | MainApplication application = getApplication(); |
| | | moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale()); |
| | | String login = application.getRunAs(); |
| | | final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; |
| | | PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); |
| | | idProp.setReadOnly(true); |
| | | PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class); |
| | | nameProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | if (pac.length() >= 5) { |
| | | return pac + "_"; |
| | | } |
| | | return ""; |
| | | } |
| | | }); |
| | | nameProp.setWriteOnce(true); |
| | | PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory()); |
| | | pacProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | return pac; |
| | | } |
| | | }); |
| | | pacProp.setSelectValues(new PropertySelectValues() { |
| | | PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class, new PacPrefixedNamePropertyFieldFactory(this)); |
| | | nameProp.setSelectValues(new PropertySelectValues() { |
| | | @Override |
| | | public boolean newItemsAllowed() { |
| | | return false; |
| | |
| | | return map; |
| | | } |
| | | }); |
| | | pacProp.setWriteOnce(true); |
| | | nameProp.setWriteOnce(true); |
| | | PropertyConfig encodingProp = new PropertyConfig(moduleConfig, "encoding", String.class, new SelectPropertyFieldFactory()); |
| | | encodingProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | |
| | | } |
| | | }); |
| | | idProp.setShowInForm(false); |
| | | pacProp.setShowInForm(false); |
| | | encodingProp.setShowInForm(false); |
| | | moduleConfig.addProperty(idProp); |
| | | moduleConfig.addProperty(pacProp); |
| | | moduleConfig.addProperty(nameProp); |
| | | moduleConfig.addProperty(encodingProp); |
| | | moduleConfig.addProperty(ownerProp); |
| | |
| | | |
| | | import de.hsadmin.web.config.ModuleConfig; |
| | | import de.hsadmin.web.config.PropertyConfig; |
| | | import de.hsadmin.web.config.PropertyDefaultValue; |
| | | import de.hsadmin.web.config.PropertySelectValues; |
| | | import de.hsadmin.web.config.PropertyTableColumn; |
| | | import de.hsadmin.web.vaadin.PacPrefixedNamePropertyFieldFactory; |
| | | import de.hsadmin.web.vaadin.PasswordPropertyFieldFactory; |
| | | import de.hsadmin.web.vaadin.SelectPropertyFieldFactory; |
| | | |
| | | public abstract class DatabaseUserModule extends GenericModule { |
| | | |
| | |
| | | protected void initModule() { |
| | | MainApplication application = getApplication(); |
| | | moduleConfig = new ModuleConfig(getModuleIdent(), application.getLocale()); |
| | | String login = application.getRunAs(); |
| | | final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; |
| | | PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); |
| | | idProp.setReadOnly(true); |
| | | PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class); |
| | | nameProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | if (pac.length() >= 5) { |
| | | return pac + "_"; |
| | | } |
| | | return ""; |
| | | } |
| | | }); |
| | | nameProp.setWriteOnce(true); |
| | | PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory()); |
| | | pacProp.setDefaultValue(new PropertyDefaultValue() { |
| | | @Override |
| | | public String getDefaultValue() { |
| | | return pac; |
| | | } |
| | | }); |
| | | pacProp.setSelectValues(new PropertySelectValues() { |
| | | PropertyConfig nameProp = new PropertyConfig(moduleConfig, "name", String.class, new PacPrefixedNamePropertyFieldFactory(this)); |
| | | nameProp.setSelectValues(new PropertySelectValues() { |
| | | @Override |
| | | public boolean newItemsAllowed() { |
| | | return false; |
| | |
| | | return map; |
| | | } |
| | | }); |
| | | pacProp.setWriteOnce(true); |
| | | nameProp.setWriteOnce(true); |
| | | PropertyConfig passwordProp = new PropertyConfig(moduleConfig, "password", String.class, PropertyTableColumn.NONE, new PasswordPropertyFieldFactory(this)); |
| | | idProp.setShowInForm(false); |
| | | pacProp.setShowInForm(false); |
| | | moduleConfig.addProperty(idProp); |
| | | moduleConfig.addProperty(pacProp); |
| | | moduleConfig.addProperty(nameProp); |
| | | moduleConfig.addProperty(passwordProp); |
| | | } |
| | |
| | | setComponentFactory(this); |
| | | } |
| | | |
| | | public void updateRow(Map<String, String> paramHash) throws HsarwebException { |
| | | Map<String, String> whereHash = new HashMap<String, String>(); |
| | | public void updateRow(Map<String, AbstractProperty> paramHash) throws HsarwebException { |
| | | Map<String, AbstractProperty> whereHash = new HashMap<String, AbstractProperty>(); |
| | | String idKey = findIdKey(); |
| | | whereHash.put(idKey, paramHash.get(idKey)); |
| | | paramHash.remove(idKey); |
| | |
| | | Button button = new Button(moduleConfig.getLabel("change_password")); |
| | | ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon")); |
| | | button.setIcon(icon); |
| | | Map<String, String> whereHash = new HashMap<String, String>(); |
| | | whereHash.put("name", application.getRunAs()); |
| | | Map<String, AbstractProperty> whereHash = new HashMap<String, AbstractProperty>(); |
| | | whereHash.put("name", new StringProperty(application.getRunAs())); |
| | | Long key = -1L; |
| | | try { |
| | | Object object = application.getRemote().callSearch(moduleConfig.getRemoteName(), whereHash); |
| | |
| | | public void buttonClick(ClickEvent event) { |
| | | application.getMainWindow().removeWindow(childWindow); |
| | | try { |
| | | Map<String, String> map = new HashMap<String, String>(); |
| | | map.put("id", ((Long) event.getButton().getData()).toString()); |
| | | Map<String, AbstractProperty> map = new HashMap<String, AbstractProperty>(); |
| | | map.put("id", new StringProperty(((Long) event.getButton().getData()).toString())); |
| | | Iterator<Component> componentIterator = form.getLayout().getComponentIterator(); |
| | | while (componentIterator.hasNext()) { |
| | | Component component = (Component) componentIterator.next(); |
| | |
| | | |
| | | public static List<Object> readItemList(MainApplication app, String module, String property) throws HsarwebException { |
| | | final List<Object> itemsList = new ArrayList<Object>(); |
| | | Object custListObj = app.getRemote().callSearch(module, new HashMap<String, String>()); |
| | | Object custListObj = app.getRemote().callSearch(module, new HashMap<String, AbstractProperty>()); |
| | | if (custListObj instanceof Object[]) { |
| | | Object[] custList = (Object[]) custListObj; |
| | | for (Object custObj : custList) { |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class ListOfStringsProperty extends AbstractProperty { |
| | | public List<String> properties; |
| | | |
| | | public final List<String> properties; |
| | | |
| | | public ListOfStringsProperty(){ |
| | | // ?? this.properties = new List<String>(); |
| | | this.properties = new ArrayList<String>(); |
| | | } |
| | | |
| | | public boolean Add(String string){ |
| | | public boolean add(String string){ |
| | | return properties.add(string); |
| | | } |
| | | |
| | | @Override |
| | | public Object toXmlrpcParam() { |
| | | String[] result = new String[properties.size()]; |
| | | int idx = 0; |
| | | for (String prop : properties) { |
| | | result[idx] = prop; |
| | | idx++; |
| | | } |
| | | return result; |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | public Object callSearch(String module, Map<String, AbstractProperty> where) throws HsarwebException { |
| | | return xmlrpcCall(module, "search", where); |
| | | return xmlrpcCall(module, "search", buildXmlrpcParam(where)); |
| | | } |
| | | |
| | | public void callAdd(String module, Map<String, AbstractProperty> set) throws HsarwebException { |
| | | xmlrpcCall(module, "add", set); |
| | | xmlrpcCall(module, "add", buildXmlrpcParam(set)); |
| | | } |
| | | |
| | | public void callUpdate(String module, Map<String, AbstractProperty> set, Map<String, AbstractProperty> where) throws HsarwebException { |
| | | xmlrpcCall(module, "update", set, where); |
| | | xmlrpcCall(module, "update", buildXmlrpcParam(set), buildXmlrpcParam(where)); |
| | | } |
| | | |
| | | public void callDelete(String module, Map<String, AbstractProperty> where) throws HsarwebException { |
| | | xmlrpcCall(module, "delete", where); |
| | | xmlrpcCall(module, "delete", buildXmlrpcParam(where)); |
| | | } |
| | | |
| | | private Object xmlrpcCall(String module, String operation, Map<String, AbstractProperty> param1) throws HsarwebException { |
| | | private Map<String, Object> buildXmlrpcParam(Map<String, AbstractProperty> paramHash) { |
| | | Map<String, Object> resultMap = new HashMap<String, Object>(); |
| | | if (paramHash == null) { |
| | | return null; |
| | | } |
| | | for (String key : paramHash.keySet()) { |
| | | resultMap.put(key, paramHash.get(key).toXmlrpcParam()); |
| | | } |
| | | return resultMap; |
| | | } |
| | | |
| | | private Object xmlrpcCall(String module, String operation, Map<String, Object> param1) throws HsarwebException { |
| | | Object[] params = new Object[3]; |
| | | params[0] = app.getRunAs(); |
| | | params[1] = app.getProxyTicket(); |
| | | params[2] = param1 != null ? param1 : new HashMap<String, String>(); |
| | | params[2] = param1 != null ? param1 : new HashMap<String, Object>(); |
| | | return xmlrpcCall(module + "." + operation, params); |
| | | } |
| | | |
| | | private Object xmlrpcCall(String module, String operation, Map<String, AbstractProperty> param1, Map<String, AbstractProperty> param2) throws HsarwebException { |
| | | private Object xmlrpcCall(String module, String operation, Map<String, Object> param1, Map<String, Object> param2) throws HsarwebException { |
| | | Object[] params = new Object[4]; |
| | | params[0] = app.getRunAs(); |
| | | params[1] = app.getProxyTicket(); |
| | | params[2] = param1 != null ? param1 : new HashMap<String, String>(); |
| | | params[3] = param2 != null ? param2 : new HashMap<String, String>(); |
| | | params[2] = param1 != null ? param1 : new HashMap<String, Object>(); |
| | | params[3] = param2 != null ? param2 : new HashMap<String, Object>(); |
| | | return xmlrpcCall(module + "." + operation, params); |
| | | } |
| | | |
| | |
| | | package de.hsadmin.web; |
| | | |
| | | public class StringProperty extends AbstractProperty { |
| | | |
| | | public String property ; |
| | | |
| | | public StringProperty(String property) { |
| | | this.property = property; |
| | | } |
| | | |
| | | @Override |
| | | public Object toXmlrpcParam() { |
| | | return property; |
| | | } |
| | | |
| | | } |
| | |
| | | public boolean hasSelectList() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public Map<String, String> getSelectValues() { |
| | | List<String> list = getPackets(); |
| | |
| | | try { |
| | | MainApplication application = module.getApplication(); |
| | | ModuleConfig config = module.getModuleConfig(); |
| | | Map<String, String> where = new HashMap<String, String>(); |
| | | where.put(findIdKey(), entityId.toString()); |
| | | Map<String, AbstractProperty> where = new HashMap<String, AbstractProperty>(); |
| | | where.put(findIdKey(), new StringProperty(entityId.toString())); |
| | | Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where); |
| | | if (searchResult instanceof Object[]) { |
| | | Map<?, ?> row = (Map<?, ?>) (((Object[]) searchResult)[0]); |
| | |
| | | import com.vaadin.ui.Select; |
| | | import com.vaadin.ui.TextField; |
| | | |
| | | import de.hsadmin.web.AbstractProperty; |
| | | import de.hsadmin.web.HsarwebException; |
| | | import de.hsadmin.web.Module; |
| | | import de.hsadmin.web.StringProperty; |
| | | import de.hsadmin.web.config.ModuleConfig; |
| | | import de.hsadmin.web.config.PropertyConfig; |
| | | import de.hsadmin.web.config.PropertyFieldFactory; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public String getValue(PropertyConfig prop, Object component) throws HsarwebException { |
| | | public AbstractProperty getValue(PropertyConfig prop, Object component) throws HsarwebException { |
| | | ModuleConfig config = module.getModuleConfig(); |
| | | HorizontalLayout layout = (HorizontalLayout) component; |
| | | Select sel = (Select) layout.getComponent(0); |
| | | TextField tf = (TextField) layout.getComponent(2); |
| | | String pacPart = (String) sel.getValue(); |
| | | String userPart = (String) tf.getValue(); |
| | | return pacPart + config.getLabel(prop.getId() + ".separator") + userPart; |
| | | return new StringProperty(pacPart + config.getLabel(prop.getId() + ".separator") + userPart); |
| | | } |
| | | |
| | | @Override |
| | |
| | | id=identifier |
| | | name=database |
| | | name.pacprefix=packet |
| | | name.separator=_ |
| | | name.postfix=databasepart |
| | | pac=packet |
| | | encoding=encoding |
| | | owner=owner |
| | |
| | | id=Schlüssel |
| | | name=MySQL Datenbank |
| | | name.pacprefix=Paket |
| | | name.separator=_ |
| | | name.postfix=Datenbank-Postfix |
| | | pac=Paket |
| | | encoding=Zeichensatz |
| | | owner=Verwalter |
| | |
| | | id=identifier |
| | | name=database username |
| | | name.pacprefix=packet |
| | | name.separator=_ |
| | | name.postfix=userpart |
| | | password=password |
| | | password1=new password |
| | | password2=repeat password |
| | |
| | | id=Schlüssel |
| | | name=MySQL User |
| | | name.pacprefix=Paket |
| | | name.separator=_ |
| | | name.postfix=Benutzer-Postfix |
| | | password=Passwort |
| | | password1=neues Passwort |
| | | password2=Passwort-Wiederholung |
| | |
| | | id=identifier |
| | | name=database |
| | | name.pacprefix=packet |
| | | name.separator=_ |
| | | name.postfix=databasepart |
| | | pac=packet |
| | | encoding=encoding |
| | | owner=owner |
| | |
| | | id=Schlüssel |
| | | name=Datenbank |
| | | name.pacprefix=Paket |
| | | name.separator=_ |
| | | name.postfix=Datenbank-Postfix |
| | | pac=Paket |
| | | encoding=Zeichensatz |
| | | owner=Verwalter |
| | |
| | | id=identifier |
| | | name=postgres username |
| | | name.pacprefix=packet |
| | | name.separator=_ |
| | | name.postfix=userpart |
| | | password=password |
| | | password1=new password |
| | | password2=repeat password |
| | |
| | | id=Schlüssel |
| | | name=PostgreSQL User |
| | | name.pacprefix=Paket |
| | | name.separator=_ |
| | | name.postfix=Benutzer-Postfix |
| | | password=Passwort |
| | | password1=neues Passwort |
| | | password2=Passwort-Wiederholung |