hsarweb/src/de/hsadmin/web/EMailAliasModule.java | ●●●●● patch | view | raw | blame | history | |
hsarweb/src/de/hsadmin/web/UnixUserModule.java | ●●●●● patch | view | raw | blame | history | |
hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java | ●●●●● patch | view | raw | blame | history |
hsarweb/src/de/hsadmin/web/EMailAliasModule.java
@@ -1,9 +1,17 @@ package de.hsadmin.web; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; 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.SelectPropertyFieldFactory; public class EMailAliasModule extends GenericModule { @@ -39,18 +47,37 @@ return ""; } }); PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN); PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory()); pacProp.setDefaultValue(new PropertyDefaultValue() { @Override public String getDefaultValue() { return pac; } }); pacProp.setReadOnly(true); pacProp.setSelectValues(new PropertySelectValues() { @Override public boolean newItemsAllowed() { return false; } @Override public boolean hasSelectList() { return true; } @Override public Map<String, String> getSelectValues() { List<String> list = getPackets(); TreeMap<String,String> map = new TreeMap<String, String>(); for (String pac : list) { map.put(pac, pac); } return map; } }); pacProp.setWriteOnce(true); moduleConfig.addProperty(idProp); moduleConfig.addProperty(pacProp); moduleConfig.addProperty(nameProp); moduleConfig.addProperty(targetProp); moduleConfig.addProperty(pacProp); } @Override @@ -58,4 +85,25 @@ return moduleConfig; } public List<String> getPackets() { ArrayList<String> list = new ArrayList<String>(); try { Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap<String, String>()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map<?, ?>) { Object object = ((Map<?, ?>) row).get("name"); if (object instanceof String) { list.add((String) object); } } } } } catch (HsarwebException e) { e.printStackTrace(); getApplication().showSystemException(e); } return list; } } hsarweb/src/de/hsadmin/web/UnixUserModule.java
@@ -1,5 +1,8 @@ package de.hsadmin.web; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; @@ -22,6 +25,33 @@ moduleConfig = new ModuleConfig("user"); String login = getApplication().getLogin(); final String pac = login.length() >= 5 ? login.substring(0, 5) : ""; PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN, new SelectPropertyFieldFactory()); pacProp.setSelectValues(new PropertySelectValues() { @Override public boolean newItemsAllowed() { return false; } @Override public boolean hasSelectList() { return true; } @Override public Map<String, String> getSelectValues() { List<String> list = getPackets(); TreeMap<String,String> map = new TreeMap<String, String>(); for (String pac : list) { map.put(pac, pac); } return map; } }); pacProp.setDefaultValue(new PropertyDefaultValue() { @Override public String getDefaultValue() { return pac; } }); pacProp.setWriteOnce(true); PropertyConfig idProp = new PropertyConfig(moduleConfig, "id", Long.class, PropertyTableColumn.INTERNAL_KEY); idProp.setReadOnly(true); PropertyConfig useridProp = new PropertyConfig(moduleConfig, "userid", Long.class, PropertyTableColumn.HIDDEN); @@ -71,14 +101,6 @@ }); PropertyConfig homedirProp = new PropertyConfig(moduleConfig, "homedir", String.class, PropertyTableColumn.HIDDEN); homedirProp.setReadOnly(true); PropertyConfig pacProp = new PropertyConfig(moduleConfig, "pac", String.class, PropertyTableColumn.HIDDEN); pacProp.setReadOnly(true); pacProp.setDefaultValue(new PropertyDefaultValue() { @Override public String getDefaultValue() { return pac; } }); PropertyConfig softQuotaProp = new PropertyConfig(moduleConfig, "quota_softlimit", Long.class, PropertyTableColumn.HIDDEN); softQuotaProp.setDefaultValue(new PropertyDefaultValue() { @Override @@ -93,6 +115,7 @@ return "0"; } }); moduleConfig.addProperty(pacProp); moduleConfig.addProperty(idProp); moduleConfig.addProperty(useridProp); moduleConfig.addProperty(nameProp); @@ -100,7 +123,6 @@ moduleConfig.addProperty(commentProp); moduleConfig.addProperty(shellProp); moduleConfig.addProperty(homedirProp); moduleConfig.addProperty(pacProp); moduleConfig.addProperty(softQuotaProp); moduleConfig.addProperty(hardQuotaProp); } @@ -110,4 +132,25 @@ return moduleConfig; } public List<String> getPackets() { ArrayList<String> list = new ArrayList<String>(); try { Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap<String, String>()); if (callSearch instanceof Object[]) { for (Object row : ((Object[])callSearch)) { if (row instanceof Map<?, ?>) { Object object = ((Map<?, ?>) row).get("name"); if (object instanceof String) { list.add((String) object); } } } } } catch (HsarwebException e) { e.printStackTrace(); getApplication().showSystemException(e); } return list; } } hsarweb/src/de/hsadmin/web/vaadin/GenericForm.java
@@ -56,13 +56,15 @@ f.setData(entityId); Layout layout = f.getLayout(); for (PropertyConfig prop : config.getPropertyList()) { PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory(); Object value = row.get(prop.getId()); Component component = (Component) propFieldFactory.createFieldComponent(prop, value); if (propFieldFactory.isWriteOnce()) { component.setReadOnly(true); if (!prop.getPropTableColumn().equals(PropertyTableColumn.INTERNAL_KEY)) { PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory(); Object value = row.get(prop.getId()); Component component = (Component) propFieldFactory.createFieldComponent(prop, value); if (propFieldFactory.isWriteOnce()) { component.setReadOnly(true); } layout.addComponent(component); } layout.addComponent(component); } return f; }