diff --git a/README.md b/README.md index cf09fbb..987b3c4 100644 --- a/README.md +++ b/README.md @@ -18,3 +18,38 @@ und Ihrer Rolle für die Genossenschaft (technischer oder kaufmännischer Anspre ## pac Das neue Paket-Modul ist in Entwicklung https://dev.hostsharing.net/doc/hsadmin!hs.hsadmin.jee.git/master/services!doc!package.md + +## run locally + +Alles bauen und Eclise Konfiguration erzeugen: + +```bash +mvn clean install eclipse:clean eclipse +``` + +Backend auf localhost:8080 starten: + +```bash +cd cust-services +# entweder: +mvn tomee:run +# oder: +mvn tomee:debug +``` + +Frontend auf localhost:8081 starten: + +```bash +cd ../web +# entweder: +mvn tomcat7:run +# oder: +mvnDebug tomcat7:run +``` + +Sobald der Debugger unter dem in der Programmausgabe genannten Port verbunden ist, startet der Server. + +Login unter http://localhost:8081/ mit ad/ad. + +Im Webfrontend funktioniert natürlich nur der Customer-Teil, +weil sich die anderen Module im Legacy Backend befinden. diff --git a/cust-services/src/main/java/de/hsadmin/service/customer/MemberShareService.java b/cust-services/src/main/java/de/hsadmin/service/customer/MemberShareService.java index 15c8d01..202010a 100644 --- a/cust-services/src/main/java/de/hsadmin/service/customer/MemberShareService.java +++ b/cust-services/src/main/java/de/hsadmin/service/customer/MemberShareService.java @@ -79,14 +79,14 @@ public class MemberShareService extends AbstractModule implements @RequiredScope({@ScopePolicy(Role.SYSTEM)}) public List update(final RequestContext requestContext, final MemberShareVO criteria, final MemberShareVO prototype) throws UserException, TechnicalException { - throw new TechnicalException(new NotImplementedException("MemberShares are immuatable")); + throw new TechnicalException(new NotImplementedException("MemberShares are immutable")); } @Override @RequiredScope({@ScopePolicy(Role.SYSTEM)}) public void delete(final RequestContext requestContext, final MemberShareVO criteria) throws UserException, TechnicalException { - throw new TechnicalException(new NotImplementedException("MemberShares are immuatable")); + throw new TechnicalException(new NotImplementedException("MemberShares are immutable")); } // macht diese Klasse Unit-testbar diff --git a/web/src/main/java/de/hsadmin/rpc/PropertyInfo.java b/web/src/main/java/de/hsadmin/rpc/PropertyInfo.java index 80ad89a..b8e048f 100644 --- a/web/src/main/java/de/hsadmin/rpc/PropertyInfo.java +++ b/web/src/main/java/de/hsadmin/rpc/PropertyInfo.java @@ -100,9 +100,13 @@ public class PropertyInfo implements Serializable { void setSearchable(final String searchable) { this.searchable = SearchPolicy.valueOf(searchable.toUpperCase()); } + + public String getResourceId() { + return module + "." + name; + } @Override public String toString() { - return "PropertyInfo " + module + "." + name; + return "PropertyInfo " + getResourceId(); } } diff --git a/web/src/main/java/de/hsadmin/web/CustomerPanel.java b/web/src/main/java/de/hsadmin/web/CustomerPanel.java index bcae029..a561391 100644 --- a/web/src/main/java/de/hsadmin/web/CustomerPanel.java +++ b/web/src/main/java/de/hsadmin/web/CustomerPanel.java @@ -34,12 +34,20 @@ public class CustomerPanel extends CustomComponent implements IHSPanel, Selected tabsheet.addSelectedTabChangeListener(this); tabsheet.addSelectedTabChangeListener(this); tabsheet.addTab(new GenericForm("customer", session, itemId, "name"), I18N.getText("customer")); + final HSTab usersTab = new HSTab("contact", session, "customer", itemId, "email"); usersTab.fillTable(); tabsheet.addTab(usersTab, I18N.getText("contact")); - HSTab aliasTab = new HSTab("mandat", session, "customer", itemId, "mandatRef"); + + final HSTab aliasTab = new HSTab("mandat", session, "customer", itemId, "mandatRef"); tabsheet.addTab(aliasTab, I18N.getText("mandat")); - HSTab pacTab = new HSTab("pac", session, "customer", itemId, "name"); + + final HSTab assetsTab = new HSTab("memberShare", session, "customer", itemId, "id"); + assetsTab.getPanelToolbar().setUpdateEnabled(false); + assetsTab.getPanelToolbar().setDeleteEnabled(false); + tabsheet.addTab(assetsTab, I18N.getText("memberShare")); + + final HSTab pacTab = new HSTab("pac", session, "customer", itemId, "name"); tabsheet.addTab(pacTab, I18N.getText("pac")); return tabsheet; } diff --git a/web/src/main/java/de/hsadmin/web/GenericEditorFactory.java b/web/src/main/java/de/hsadmin/web/GenericEditorFactory.java index 4d76118..af95cbc 100644 --- a/web/src/main/java/de/hsadmin/web/GenericEditorFactory.java +++ b/web/src/main/java/de/hsadmin/web/GenericEditorFactory.java @@ -50,6 +50,11 @@ public class GenericEditorFactory implements IEditorFactory, Serializable { return getSelectFromRemote(action, propertyInfo, session, "postgresqluser", whereContext); } } + if ("memberShare".equals(module)) { + if ("action".equals(inputName)) { + return getMemberShareActionEditor(action, propertyInfo, session, whereContext); + } + } return getEditor(action, propertyInfo); } @@ -58,6 +63,13 @@ public class GenericEditorFactory implements IEditorFactory, Serializable { return PanelToolbar.ACTION_EDIT.equals(action) ? new DomainOptionsEditor(propertyInfo, session, whereContext) : new NullEditor(); } + private IHSEditor getMemberShareActionEditor(String action, PropertyInfo propertyInfo, HSAdminSession session, Map whereContext) { + final String[] items = new String[] { "SUBSCRIPTION", "UNSUBSCRIPTION" }; + final HSSelect field = new HSSelect(propertyInfo, 0, Arrays.asList(items)); + field.setWidth("100%"); + field.setEnabled(isWriteAble(propertyInfo, action)); + return field; + } private IHSEditor getEMailTargetEditor(final String action, final PropertyInfo propertyInfo, final HSAdminSession session, final Map whereContext) { @@ -75,6 +87,9 @@ public class GenericEditorFactory implements IEditorFactory, Serializable { if ("shell".equals(inputName)) { return getShellSelect(action, propertyInfo); } + if ("date".equals(inputName)) { + return getDateSelect(action, propertyInfo); + } final String module = propertyInfo.getModule(); if ("user".equals(module) || "emailalias".equals(module)) { if ("name".equals(inputName)) { @@ -99,7 +114,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable { private IHSEditor getSelectField(final String action, final PropertyInfo propertyInfo, final String... items) { - final HSSelect field = new HSSelect(propertyInfo.getName(), Arrays.asList(items)); + final HSSelect field = new HSSelect(propertyInfo, 0, Arrays.asList(items)); field.setWidth("100%"); field.setEnabled(isWriteAble(propertyInfo, action)); return field; @@ -108,7 +123,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable { private IHSEditor getPacPrefixedField(final String action, final PropertyInfo propertyInfo, final char delimiter) { - final HSPacPrefixedField field = new HSPacPrefixedField(propertyInfo.getName(), delimiter); + final HSPacPrefixedField field = new HSPacPrefixedField(propertyInfo, delimiter); field.setWidth("100%"); field.setValue("xyz00-"); enableAndValidate(action, propertyInfo, field); @@ -118,7 +133,15 @@ public class GenericEditorFactory implements IEditorFactory, Serializable { private IHSEditor getShellSelect(final String action, final PropertyInfo propertyInfo) { final String[] items = new String[] { "/bin/false", "/bin/bash", "/bin/csh", "/bin/dash", "/bin/ksh", "/bin/tcsh", "/bin/zsh", "/usr/bin/passwd", "/usr/bin/scponly" }; - final HSSelect field = new HSSelect(propertyInfo.getName(), 7, Arrays.asList(items)); + final HSSelect field = new HSSelect(propertyInfo, 7, Arrays.asList(items)); + field.setWidth("100%"); + field.setEnabled(isWriteAble(propertyInfo, action)); + return field; + } + + private IHSEditor getDateSelect(final String action, final PropertyInfo propertyInfo) + { + final HSDateSelect field = new HSDateSelect(propertyInfo); field.setWidth("100%"); field.setEnabled(isWriteAble(propertyInfo, action)); return field; @@ -142,7 +165,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable { // TODO Auto-generated catch block e.printStackTrace(); } - final HSSelect field = new HSSelect(propertyInfo.getName(), selectList); + final HSSelect field = new HSSelect(propertyInfo, 0, selectList); field.setEnabled(isWriteAble(propertyInfo, action)); field.setWidth("100%"); return field; @@ -158,7 +181,7 @@ public class GenericEditorFactory implements IEditorFactory, Serializable { private IHSEditor getTextField(final String action, final PropertyInfo propertyInfo) { - final HSTextField field = new HSTextField(propertyInfo.getName()); + final HSTextField field = new HSTextField(propertyInfo); field.setWidth("100%"); enableAndValidate(action, propertyInfo, field); return field; diff --git a/web/src/main/java/de/hsadmin/web/HSDateSelect.java b/web/src/main/java/de/hsadmin/web/HSDateSelect.java new file mode 100644 index 0000000..40f85e8 --- /dev/null +++ b/web/src/main/java/de/hsadmin/web/HSDateSelect.java @@ -0,0 +1,26 @@ +package de.hsadmin.web; + +import java.util.Map; + +import com.vaadin.data.util.converter.StringToDateConverter; +import com.vaadin.ui.DateField; + +import de.hsadmin.rpc.PropertyInfo; + +public class HSDateSelect extends DateField implements IHSEditor { + + private static final long serialVersionUID = 1L; + + private String field; + + public HSDateSelect(PropertyInfo propertyInfo) { + super(I18N.getText(propertyInfo.getResourceId())); + field = propertyInfo.getName(); + setConverter(StringToDateConverter.class); + } + + @Override + public void setValues(Map valuesMap) { + setConvertedValue( valuesMap.get(field) ); + } +} diff --git a/web/src/main/java/de/hsadmin/web/HSPacPrefixedField.java b/web/src/main/java/de/hsadmin/web/HSPacPrefixedField.java index 7668543..ca85996 100644 --- a/web/src/main/java/de/hsadmin/web/HSPacPrefixedField.java +++ b/web/src/main/java/de/hsadmin/web/HSPacPrefixedField.java @@ -2,6 +2,8 @@ package de.hsadmin.web; import java.util.Map; +import de.hsadmin.rpc.PropertyInfo; + public class HSPacPrefixedField extends HSTextField implements PacNamePrefixed { @@ -11,8 +13,8 @@ public class HSPacPrefixedField extends HSTextField implements PacNamePrefixed { private String pacName; - public HSPacPrefixedField(final String name, final char delimiter) { - super(name); + public HSPacPrefixedField(final PropertyInfo propertyInfo, final char delimiter) { + super(propertyInfo); pacName = "xyz00"; this.delimiter = delimiter; addValidator(new PacNamePrefixValidator(this)); diff --git a/web/src/main/java/de/hsadmin/web/HSSelect.java b/web/src/main/java/de/hsadmin/web/HSSelect.java index 3edefb8..bd775b2 100644 --- a/web/src/main/java/de/hsadmin/web/HSSelect.java +++ b/web/src/main/java/de/hsadmin/web/HSSelect.java @@ -5,19 +5,17 @@ import java.util.Map; import com.vaadin.ui.NativeSelect; +import de.hsadmin.rpc.PropertyInfo; + public class HSSelect extends NativeSelect implements IHSEditor { private static final long serialVersionUID = 1L; private final String propertyName; - public HSSelect(final String label, final List values) { - this(label, 0, values); - } - - public HSSelect(final String label, final int defaultIndex, final List values) { - super(I18N.getText(label)); - this.propertyName = label; + public HSSelect(final PropertyInfo propertyInfo, final int defaultIndex, final List values) { + super(I18N.getText(propertyInfo.getResourceId())); + this.propertyName = propertyInfo.getName(); super.addItems(values); if (values != null && values.size() > defaultIndex) { super.setValue(values.get(defaultIndex)); diff --git a/web/src/main/java/de/hsadmin/web/HSTab.java b/web/src/main/java/de/hsadmin/web/HSTab.java index 0e4bca4..adfcc65 100644 --- a/web/src/main/java/de/hsadmin/web/HSTab.java +++ b/web/src/main/java/de/hsadmin/web/HSTab.java @@ -32,7 +32,7 @@ public class HSTab extends CustomComponent { private final Object selectPropertyValue; private final String selectPropertyName; private final String rowIdPropertyName; - private final HorizontalLayout panelToolbar; + private final PanelToolbar panelToolbar; private Table grid; @@ -166,4 +166,8 @@ public class HSTab extends CustomComponent { return selectPropertyName; } + public PanelToolbar getPanelToolbar() { + return panelToolbar; + } + } diff --git a/web/src/main/java/de/hsadmin/web/HSTextField.java b/web/src/main/java/de/hsadmin/web/HSTextField.java index e925c87..6d1f7fd 100644 --- a/web/src/main/java/de/hsadmin/web/HSTextField.java +++ b/web/src/main/java/de/hsadmin/web/HSTextField.java @@ -4,15 +4,17 @@ import java.util.Map; import com.vaadin.ui.TextField; +import de.hsadmin.rpc.PropertyInfo; + public class HSTextField extends TextField implements IHSEditor { private static final long serialVersionUID = 1L; private final String propertyName; - public HSTextField(final String name) { - super(I18N.getText(name)); - this.propertyName = name; + public HSTextField(final PropertyInfo propertyInfo) { + super(I18N.getText(propertyInfo.getResourceId())); + this.propertyName = propertyInfo.getName(); } @Override diff --git a/web/src/main/java/de/hsadmin/web/I18N.java b/web/src/main/java/de/hsadmin/web/I18N.java index df14604..4aadac6 100644 --- a/web/src/main/java/de/hsadmin/web/I18N.java +++ b/web/src/main/java/de/hsadmin/web/I18N.java @@ -7,14 +7,29 @@ public class I18N { private static final ResourceBundle TEXTS = ResourceBundle.getBundle("de.hsadmin.web.main"); - public static String getText(final String textProperty) { - String textValue; - try{ - textValue = I18N.TEXTS.getString(textProperty); - }catch(MissingResourceException e){ - textValue = "./. " + textProperty; + /** + * Loads a String resource from the *.properties files. + * + * @param optionallyQualifiedTextProperty + * ID of the resource, optionally qualified module the module name, + * e.g. "customer.name" (preferred) or simply "name" (legacy). + * @return the String resource, e.g. a label or message, usually to be displayed to the user + */ + public static String getText(final String optionallyQualifiedTextProperty) { + String textValue = getTextImpl(optionallyQualifiedTextProperty); + return textValue != null ? textValue : "./. " + optionallyQualifiedTextProperty; + } + + public static String getTextImpl(final String optionallyQualifiedTextProperty) { + try { + return I18N.TEXTS.getString(optionallyQualifiedTextProperty); + } catch(MissingResourceException e1) { + String[] parts = optionallyQualifiedTextProperty.split(".", 2); + if ( parts.length > 1 ) { + return getTextImpl(parts[1]); + } } - return textValue; + return null; } } diff --git a/web/src/main/java/de/hsadmin/web/PanelToolbar.java b/web/src/main/java/de/hsadmin/web/PanelToolbar.java index 9fb9645..11f8fac 100644 --- a/web/src/main/java/de/hsadmin/web/PanelToolbar.java +++ b/web/src/main/java/de/hsadmin/web/PanelToolbar.java @@ -126,4 +126,14 @@ public class PanelToolbar extends HorizontalLayout implements ClickListener { } } + public void setUpdateEnabled(boolean updateEnabled) { + editBtn.setEnabled(updateEnabled); + } + + public void setDeleteEnabled(boolean deleteEnabled) { + deleteBtn.setEnabled(deleteEnabled); + } + + + } diff --git a/web/src/main/resources/de/hsadmin/web/main_de.properties b/web/src/main/resources/de/hsadmin/web/main_de.properties index e69f622..d3d3c57 100644 --- a/web/src/main/resources/de/hsadmin/web/main_de.properties +++ b/web/src/main/resources/de/hsadmin/web/main_de.properties @@ -80,6 +80,12 @@ contact=Ansprechpartner cancel=abbrechen ok=Ok mandat=SEPA-Mandat +memberShare=Geschäftsanteile +memberShare.customer=Mitglieds-Kennung +memberShare.action=Buchungstyp +memberShare.date=Buchungsdatum +memberShare.quantity=Anzahl +memberShare.comment=Kommentar password=Passwort login.title=Anmeldung login.button=anmelden