SelectableValues can now be annotated with kind of data (e.g.

SINGLEVALUE, DOMAINOPTIONS, et al), and these annotations are passed to
remote via moduleprop.search
This commit is contained in:
Purodha 2013-02-20 16:37:14 +00:00
parent 5ef8615a54
commit c5c575c095
4 changed files with 47 additions and 15 deletions

View File

@ -5,7 +5,10 @@ import java.util.List;
public class DefaultSelectableValues {
public List<SelectableValue> get() {
return new ArrayList<SelectableValue>();
}
public KindOfSelectableValue getkind() {
return KindOfSelectableValue.UNSPECIFIED;
}
public List<SelectableValue> get() {
return new ArrayList<SelectableValue>();
}
}

View File

@ -0,0 +1,5 @@
package de.hsadmin.core.model;
public enum KindOfSelectableValue {
UNSPECIFIED , DOMAINOPTIONS, SINGLESTRING
}

View File

@ -5,10 +5,16 @@ import java.util.List;
import de.hsadmin.core.model.BooleanListValue;
import de.hsadmin.core.model.DefaultSelectableValues;
import de.hsadmin.core.model.KindOfSelectableValue;
import de.hsadmin.core.model.SelectableValue;
public class DomainOptionValues extends DefaultSelectableValues {
@Override
public KindOfSelectableValue getkind() {
return KindOfSelectableValue.DOMAINOPTIONS;
}
@Override
public List<SelectableValue> get() {
ArrayList<SelectableValue> list = new ArrayList<SelectableValue>();

View File

@ -11,10 +11,12 @@ import java.util.Properties;
import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.core.model.AnnFieldIO;
import de.hsadmin.core.model.AuthenticationException;
import de.hsadmin.core.model.DefaultSelectableValues;
import de.hsadmin.core.model.HSAdminException;
import de.hsadmin.core.model.ReadWriteAccess;
import de.hsadmin.core.model.SelectableValue;
import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.model.KindOfSelectableValue;
public class ModulePropertiesRemote implements IRemote {
@ -51,22 +53,38 @@ public class ModulePropertiesRemote implements IRemote {
ReadWriteAccess rw = fieldIO.rw();
propertyProperties.put("rw", rw.name());
String[] referredProps = fieldIO.referredProps();
propertyProperties.put("referredProps", referredProps);
// Class<?> declaringClass = f.getDeclaringClass();
// declaringClass = f.getDeclaringClass();
propertyProperties.put("referredProps", referredProps);
for(String s : referredProps) {
String fullPropertyName = fieldName+"."+s;
propertiesList.add(createReferredPropertyInfo(fullPropertyName, f, s));
}
ArrayList<Map<String,Object>> selectableValueslist = new ArrayList<Map<String,Object>>();
List<SelectableValue> selectableValues = fieldIO.selectableValues().newInstance().get();
propertyProperties.put("selectableValues", selectableValueslist);
for( SelectableValue s : selectableValues) {
String SelectableValueName = s.getName();
Object SelectableValues = s.getValues();
Map<String, Object> m = new HashMap<String, Object>();
m.put(SelectableValueName, SelectableValues);
selectableValueslist.add(m);
DefaultSelectableValues selectableValuesInstance = fieldIO.selectableValues().newInstance() ;
KindOfSelectableValue kind = selectableValuesInstance.getkind();
HashMap<String,Object> kindMap = new HashMap<String,Object>();
kindMap.put("kind", kind.name());
switch (kind) {
case UNSPECIFIED :
break;
case SINGLESTRING :
propertyProperties.put("selectableValues", kindMap);
// ArrayList<Map<String,String>> selectableValueslist = new ArrayList<Map<String,String>>();
// kindMap.put("values", selectableValueslist);
// List<SelectableValue> selectableValues = selectableValuesInstance.get();
// TODO: Hier fehlt noch was!
break;
case DOMAINOPTIONS :
propertyProperties.put("selectableValues", kindMap);
ArrayList<Map<String,Object>> selectableValueslist = new ArrayList<Map<String,Object>>();
kindMap.put("values", selectableValueslist);
List<SelectableValue> selectableValues = selectableValuesInstance.get();
for( SelectableValue s : selectableValues) {
String SelectableValueName = s.getName();
Object SelectableValues = s.getValues();
Map<String, Object> m = new HashMap<String, Object>();
m.put(SelectableValueName, SelectableValues);
selectableValueslist.add(m);
}
break;
}
addCommonPropertyInfo(propertyProperties, f);
propertiesList.add(propertyProperties);