Merge branch 'master' of ssh://hsh04.hostsharing.net/home/doms/source.hostsharing.net/source/hsadmin
This commit is contained in:
commit
fd02157854
@ -8,6 +8,23 @@ public class JSONFormatter {
|
|||||||
|
|
||||||
private int indent = 1;
|
private int indent = 1;
|
||||||
|
|
||||||
|
public String format(Object object) {
|
||||||
|
if (object == null) return "";
|
||||||
|
if (object instanceof List<?>) {
|
||||||
|
return formatList((List<?>) object);
|
||||||
|
}
|
||||||
|
if (object instanceof Map<?, ?>) {
|
||||||
|
return formatMap((Map<?, ?>) object);
|
||||||
|
}
|
||||||
|
if (object instanceof String) {
|
||||||
|
return formatString((String) object);
|
||||||
|
}
|
||||||
|
if (object instanceof Object[]) {
|
||||||
|
return formatArr((Object[]) object);
|
||||||
|
}
|
||||||
|
return "an instance of " + object.getClass().getCanonicalName();
|
||||||
|
}
|
||||||
|
|
||||||
public String formatMap(Map<?, ?> map) {
|
public String formatMap(Map<?, ?> map) {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
result.append('{');
|
result.append('{');
|
||||||
@ -61,23 +78,6 @@ public class JSONFormatter {
|
|||||||
return result.toString();
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String format(Object object) {
|
|
||||||
if (object == null) return "";
|
|
||||||
if (object instanceof List<?>) {
|
|
||||||
return formatList((List<?>) object);
|
|
||||||
}
|
|
||||||
if (object instanceof Map<?, ?>) {
|
|
||||||
return formatMap((Map<?, ?>) object);
|
|
||||||
}
|
|
||||||
if (object instanceof String) {
|
|
||||||
return formatString((String) object);
|
|
||||||
}
|
|
||||||
if (object instanceof Object[]) {
|
|
||||||
return formatArr((Object[]) object);
|
|
||||||
}
|
|
||||||
return "an instance of " + object.getClass().getCanonicalName();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void incr() {
|
private void incr() {
|
||||||
indent += 3;
|
indent += 3;
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@ public class Main {
|
|||||||
String file = cmdParser.getFile();
|
String file = cmdParser.getFile();
|
||||||
if (file != null && file.length() > 0) {
|
if (file != null && file.length() > 0) {
|
||||||
if ("-".equals(file)) {
|
if ("-".equals(file)) {
|
||||||
console.println(formatter.format(scriptClient.execute(new InputStreamReader(System.in))));
|
scriptClient.execute(new InputStreamReader(System.in));
|
||||||
|
console.println(formatter.format(scriptClient.getLastRpcResult()));
|
||||||
} else {
|
} else {
|
||||||
File fileHandle = new File(file);
|
File fileHandle = new File(file);
|
||||||
try {
|
try {
|
||||||
console.println(formatter.format(scriptClient.execute(new FileReader(fileHandle))));
|
scriptClient.execute(new FileReader(fileHandle));
|
||||||
|
console.println(formatter.format(scriptClient.getLastRpcResult()));
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
System.err.println("File not found: " + file);
|
System.err.println("File not found: " + file);
|
||||||
}
|
}
|
||||||
@ -32,13 +34,15 @@ public class Main {
|
|||||||
}
|
}
|
||||||
String expr = cmdParser.getExpression();
|
String expr = cmdParser.getExpression();
|
||||||
if (expr != null && expr.length() > 0) {
|
if (expr != null && expr.length() > 0) {
|
||||||
console.println(formatter.format(scriptClient.execute(expr)));
|
scriptClient.execute(expr);
|
||||||
|
console.println(formatter.format(scriptClient.getLastRpcResult()));
|
||||||
}
|
}
|
||||||
if (cmdParser.isInteractive()) {
|
if (cmdParser.isInteractive()) {
|
||||||
String command = console.readInput();
|
String command = console.readInput();
|
||||||
while (!("bye".equals(command.trim()) || "exit".equals(command.trim()) || "quit".equals(command.trim()))) {
|
while (!("bye".equals(command.trim()) || "exit".equals(command.trim()) || "quit".equals(command.trim()))) {
|
||||||
try {
|
try {
|
||||||
console.println(formatter.format(scriptClient.execute(command)));
|
scriptClient.execute(command);
|
||||||
|
console.println(formatter.format(scriptClient.getLastRpcResult()));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
console.println("Error: " + e.getLocalizedMessage() + "\n");
|
console.println("Error: " + e.getLocalizedMessage() + "\n");
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,16 @@ public class ScriptClient {
|
|||||||
try {
|
try {
|
||||||
engine.put("casgrantingticket", grantingTicket);
|
engine.put("casgrantingticket", grantingTicket);
|
||||||
engine.put("xmlrpcclient", rpcClient);
|
engine.put("xmlrpcclient", rpcClient);
|
||||||
|
engine.put("xmlrpcLastResult", null);
|
||||||
engine.eval("importClass(java.util.ArrayList);");
|
engine.eval("importClass(java.util.ArrayList);");
|
||||||
engine.eval("importClass(java.util.HashMap);");
|
engine.eval("importClass(java.util.HashMap);");
|
||||||
|
engine.eval("function hsaParseParam(val) { " +
|
||||||
|
"if (val instanceof java.util.List) return val;" +
|
||||||
|
"if (val instanceof java.util.Map) return val;" +
|
||||||
|
"if (typeof val === 'object' && val.constructor === Array) { res = hsaParseParamArray(val); } " +
|
||||||
|
"else if (typeof val === 'object') { res = hsaParseParamObject(val); }; " +
|
||||||
|
"return res; " +
|
||||||
|
"}");
|
||||||
engine.eval("function hsaParseParamArray(o) { " +
|
engine.eval("function hsaParseParamArray(o) { " +
|
||||||
"var lst = new ArrayList(); " +
|
"var lst = new ArrayList(); " +
|
||||||
"var val = ''; " +
|
"var val = ''; " +
|
||||||
@ -45,6 +53,25 @@ public class ScriptClient {
|
|||||||
" hsh.put(key, val); " +
|
" hsh.put(key, val); " +
|
||||||
"}; " +
|
"}; " +
|
||||||
"return hsh; " +
|
"return hsh; " +
|
||||||
|
"}");
|
||||||
|
engine.eval("function hsaToNativeJSObject(val) { " +
|
||||||
|
"if (val instanceof java.util.List) {" +
|
||||||
|
" var res = [];" +
|
||||||
|
" for (i = 0; i < val.size(); i++) {" +
|
||||||
|
" res[i] = hsaToNativeJSObject(val.get(i));" +
|
||||||
|
" }" +
|
||||||
|
" return res;" +
|
||||||
|
"}" +
|
||||||
|
"if (val instanceof java.util.Map) {" +
|
||||||
|
" var res = {};" +
|
||||||
|
" var iter = val.keySet().iterator();" +
|
||||||
|
" while (iter.hasNext()) {" +
|
||||||
|
" var key = iter.next();" +
|
||||||
|
" res[key] = hsaToNativeJSObject(val.get(key));" +
|
||||||
|
" }" +
|
||||||
|
" return res;" +
|
||||||
|
"}" +
|
||||||
|
"return val;" +
|
||||||
"};");
|
"};");
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
throw new JSCliException(e);
|
throw new JSCliException(e);
|
||||||
@ -72,7 +99,8 @@ public class ScriptClient {
|
|||||||
"if (typeof json === 'undefined') { json = { where:{}, set:{} } };" +
|
"if (typeof json === 'undefined') { json = { where:{}, set:{} } };" +
|
||||||
"if (fct == 'update' || fct == 'add') { params.add(hsaParseParamObject(json['set'])); }; " +
|
"if (fct == 'update' || fct == 'add') { params.add(hsaParseParamObject(json['set'])); }; " +
|
||||||
"if (fct == 'update' || fct == 'delete' || fct == 'search') { params.add(hsaParseParamObject(json['where'])); }; " +
|
"if (fct == 'update' || fct == 'delete' || fct == 'search') { params.add(hsaParseParamObject(json['where'])); }; " +
|
||||||
"return xmlrpcclient.execute(mod + '.' + fct, params); " +
|
"xmlrpcLastResult = xmlrpcclient.execute(mod + '.' + fct, params);" +
|
||||||
|
"return hsaToNativeJSObject(xmlrpcLastResult); " +
|
||||||
"};");
|
"};");
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -94,6 +122,7 @@ public class ScriptClient {
|
|||||||
|
|
||||||
public Object execute(String snippet) throws JSCliException {
|
public Object execute(String snippet) throws JSCliException {
|
||||||
try {
|
try {
|
||||||
|
engine.put("xmlrpcLastResult", null);
|
||||||
return engine.eval(snippet);
|
return engine.eval(snippet);
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
throw new JSCliException(e);
|
throw new JSCliException(e);
|
||||||
@ -102,10 +131,15 @@ public class ScriptClient {
|
|||||||
|
|
||||||
public Object execute(Reader rd) throws JSCliException {
|
public Object execute(Reader rd) throws JSCliException {
|
||||||
try {
|
try {
|
||||||
|
engine.put("xmlrpcLastResult", null);
|
||||||
return engine.eval(rd);
|
return engine.eval(rd);
|
||||||
} catch (ScriptException e) {
|
} catch (ScriptException e) {
|
||||||
throw new JSCliException(e);
|
throw new JSCliException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getLastRpcResult() {
|
||||||
|
return engine.get("xmlrpcLastResult");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@
|
|||||||
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlrpc-client-3.1.3.jar"/>
|
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlrpc-client-3.1.3.jar"/>
|
||||||
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlrpc-common-3.1.3.jar"/>
|
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/xmlrpc-common-3.1.3.jar"/>
|
||||||
<classpathentry kind="lib" path="/hsarback/lib/servlet-api-2.4.jar"/>
|
<classpathentry kind="lib" path="/hsarback/lib/servlet-api-2.4.jar"/>
|
||||||
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/vaadin-6.8.4.jar"/>
|
<classpathentry kind="lib" path="WebContent/WEB-INF/lib/vaadin-6.8.7.jar"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
Binary file not shown.
@ -82,7 +82,7 @@ public abstract class AbstractModule implements Module, Serializable {
|
|||||||
public void buttonClick(ClickEvent event) {
|
public void buttonClick(ClickEvent event) {
|
||||||
application.getMainWindow().removeWindow(childWindow);
|
application.getMainWindow().removeWindow(childWindow);
|
||||||
try {
|
try {
|
||||||
Map<String, AbstractProperty> map = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> map = new HashMap<String, XmlrpcProperty>();
|
||||||
genericForm.transferToHash(map, form);
|
genericForm.transferToHash(map, form);
|
||||||
((InsertAble) thisModule).insertRow(map);
|
((InsertAble) thisModule).insertRow(map);
|
||||||
componentFactory.loadData();
|
componentFactory.loadData();
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package de.hsadmin.web;
|
package de.hsadmin.web;
|
||||||
|
|
||||||
public abstract class AbstractProperty {
|
public abstract class AbstractProperty implements XmlrpcProperty {
|
||||||
|
|
||||||
|
@Override
|
||||||
public abstract Object toXmlrpcParam();
|
public abstract Object toXmlrpcParam();
|
||||||
|
|
||||||
|
public abstract String toStringValue();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ public abstract class DatabaseModule extends GenericModule {
|
|||||||
public List<String> getDatabaseUsers() {
|
public List<String> getDatabaseUsers() {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
try {
|
try {
|
||||||
Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap<String, AbstractProperty>());
|
Object callSearch = getApplication().getRemote().callSearch(getUserModuleIdent(), new HashMap<String, XmlrpcProperty>());
|
||||||
if (callSearch instanceof Object[]) {
|
if (callSearch instanceof Object[]) {
|
||||||
for (Object row : ((Object[])callSearch)) {
|
for (Object row : ((Object[])callSearch)) {
|
||||||
if (row instanceof Map<?, ?>) {
|
if (row instanceof Map<?, ?>) {
|
||||||
|
40
hsarweb/src/de/hsadmin/web/DateProperty.java
Normal file
40
hsarweb/src/de/hsadmin/web/DateProperty.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package de.hsadmin.web;
|
||||||
|
|
||||||
|
import java.text.DateFormat;
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class DateProperty extends AbstractProperty {
|
||||||
|
|
||||||
|
public static final DateFormat serverDf = DateFormat.getDateInstance(DateFormat.SHORT);
|
||||||
|
|
||||||
|
final private Date property;
|
||||||
|
|
||||||
|
public DateProperty(Date propertyValue) {
|
||||||
|
this.property = propertyValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DateProperty(String propertyValue) {
|
||||||
|
Date temp = null;
|
||||||
|
try {
|
||||||
|
temp = serverDf.parse(propertyValue);
|
||||||
|
} catch (ParseException e) {
|
||||||
|
}
|
||||||
|
property = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object toXmlrpcParam() {
|
||||||
|
return serverDf.format(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toStringValue() {
|
||||||
|
return serverDf.format(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getDateValue() {
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -4,6 +4,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface DeleteAble {
|
public interface DeleteAble {
|
||||||
|
|
||||||
public void deleteRow(Map<String, AbstractProperty> paramHash) throws HsarwebException;
|
public void deleteRow(Map<String, XmlrpcProperty> paramHash) throws HsarwebException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,16 +12,16 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public void insertRow(Map<String, AbstractProperty> paramHash) throws HsarwebException {
|
public void insertRow(Map<String, XmlrpcProperty> paramHash) throws HsarwebException {
|
||||||
getApplication().getRemote().callAdd(getModuleConfig().getRemoteName(), paramHash);
|
getApplication().getRemote().callAdd(getModuleConfig().getRemoteName(), paramHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteRow(Map<String, AbstractProperty> paramHash) throws HsarwebException {
|
public void deleteRow(Map<String, XmlrpcProperty> paramHash) throws HsarwebException {
|
||||||
getApplication().getRemote().callDelete(getModuleConfig().getRemoteName(), paramHash);
|
getApplication().getRemote().callDelete(getModuleConfig().getRemoteName(), paramHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRow(Map<String, AbstractProperty> paramHash) throws HsarwebException {
|
public void updateRow(Map<String, XmlrpcProperty> paramHash) throws HsarwebException {
|
||||||
Map<String, AbstractProperty> whereHash = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> whereHash = new HashMap<String, XmlrpcProperty>();
|
||||||
String idKey = findIdKey();
|
String idKey = findIdKey();
|
||||||
whereHash.put(idKey, paramHash.get(idKey));
|
whereHash.put(idKey, paramHash.get(idKey));
|
||||||
getApplication().getRemote().callUpdate(getModuleConfig().getRemoteName(), paramHash, whereHash);
|
getApplication().getRemote().callUpdate(getModuleConfig().getRemoteName(), paramHash, whereHash);
|
||||||
@ -43,7 +43,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
|
|||||||
public List<String> getUsers() {
|
public List<String> getUsers() {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
try {
|
try {
|
||||||
Object callSearch = getApplication().getRemote().callSearch("user", new HashMap<String, AbstractProperty>());
|
Object callSearch = getApplication().getRemote().callSearch("user", new HashMap<String, XmlrpcProperty>());
|
||||||
if (callSearch instanceof Object[]) {
|
if (callSearch instanceof Object[]) {
|
||||||
for (Object row : ((Object[])callSearch)) {
|
for (Object row : ((Object[])callSearch)) {
|
||||||
if (row instanceof Map<?, ?>) {
|
if (row instanceof Map<?, ?>) {
|
||||||
@ -64,7 +64,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
|
|||||||
public List<String> getEMailAliases() {
|
public List<String> getEMailAliases() {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
try {
|
try {
|
||||||
Object callSearch = getApplication().getRemote().callSearch("emailalias", new HashMap<String, AbstractProperty>());
|
Object callSearch = getApplication().getRemote().callSearch("emailalias", new HashMap<String, XmlrpcProperty>());
|
||||||
if (callSearch instanceof Object[]) {
|
if (callSearch instanceof Object[]) {
|
||||||
for (Object row : ((Object[])callSearch)) {
|
for (Object row : ((Object[])callSearch)) {
|
||||||
if (row instanceof Map<?, ?>) {
|
if (row instanceof Map<?, ?>) {
|
||||||
@ -85,7 +85,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
|
|||||||
public List<String> getDomains() {
|
public List<String> getDomains() {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
try {
|
try {
|
||||||
Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap<String, AbstractProperty>());
|
Object callSearch = getApplication().getRemote().callSearch("domain", new HashMap<String, XmlrpcProperty>());
|
||||||
if (callSearch instanceof Object[]) {
|
if (callSearch instanceof Object[]) {
|
||||||
for (Object row : ((Object[])callSearch)) {
|
for (Object row : ((Object[])callSearch)) {
|
||||||
if (row instanceof Map<?, ?>) {
|
if (row instanceof Map<?, ?>) {
|
||||||
@ -106,7 +106,7 @@ public abstract class GenericModule extends AbstractModule implements InsertAble
|
|||||||
public List<String> getPackets() {
|
public List<String> getPackets() {
|
||||||
ArrayList<String> list = new ArrayList<String>();
|
ArrayList<String> list = new ArrayList<String>();
|
||||||
try {
|
try {
|
||||||
Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap<String, AbstractProperty>());
|
Object callSearch = getApplication().getRemote().callSearch("pac", new HashMap<String, XmlrpcProperty>());
|
||||||
if (callSearch instanceof Object[]) {
|
if (callSearch instanceof Object[]) {
|
||||||
for (Object row : ((Object[])callSearch)) {
|
for (Object row : ((Object[])callSearch)) {
|
||||||
if (row instanceof Map<?, ?>) {
|
if (row instanceof Map<?, ?>) {
|
||||||
|
@ -35,8 +35,8 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda
|
|||||||
setComponentFactory(this);
|
setComponentFactory(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRow(Map<String, AbstractProperty> paramHash) throws HsarwebException {
|
public void updateRow(Map<String, XmlrpcProperty> paramHash) throws HsarwebException {
|
||||||
Map<String, AbstractProperty> whereHash = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> whereHash = new HashMap<String, XmlrpcProperty>();
|
||||||
String idKey = findIdKey();
|
String idKey = findIdKey();
|
||||||
whereHash.put(idKey, paramHash.get(idKey));
|
whereHash.put(idKey, paramHash.get(idKey));
|
||||||
paramHash.remove(idKey);
|
paramHash.remove(idKey);
|
||||||
@ -94,7 +94,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda
|
|||||||
Button button = new Button(moduleConfig.getLabel("change_password"));
|
Button button = new Button(moduleConfig.getLabel("change_password"));
|
||||||
ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon"));
|
ThemeResource icon = new ThemeResource(moduleConfig.getLabel("change_password_icon"));
|
||||||
button.setIcon(icon);
|
button.setIcon(icon);
|
||||||
Map<String, AbstractProperty> whereHash = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> whereHash = new HashMap<String, XmlrpcProperty>();
|
||||||
whereHash.put("name", new StringProperty(application.getRunAs()));
|
whereHash.put("name", new StringProperty(application.getRunAs()));
|
||||||
Long key = -1L;
|
Long key = -1L;
|
||||||
try {
|
try {
|
||||||
@ -130,7 +130,7 @@ public class HomeModule extends AbstractModule implements ComponentFactory, Upda
|
|||||||
public void buttonClick(ClickEvent event) {
|
public void buttonClick(ClickEvent event) {
|
||||||
application.getMainWindow().removeWindow(childWindow);
|
application.getMainWindow().removeWindow(childWindow);
|
||||||
try {
|
try {
|
||||||
Map<String, AbstractProperty> map = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> map = new HashMap<String, XmlrpcProperty>();
|
||||||
map.put("id", new StringProperty(((Long) event.getButton().getData()).toString()));
|
map.put("id", new StringProperty(((Long) event.getButton().getData()).toString()));
|
||||||
Iterator<Component> componentIterator = form.getLayout().getComponentIterator();
|
Iterator<Component> componentIterator = form.getLayout().getComponentIterator();
|
||||||
while (componentIterator.hasNext()) {
|
while (componentIterator.hasNext()) {
|
||||||
|
@ -4,6 +4,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface InsertAble {
|
public interface InsertAble {
|
||||||
|
|
||||||
public void insertRow(Map<String, AbstractProperty> paramHash) throws HsarwebException;
|
public void insertRow(Map<String, XmlrpcProperty> paramHash) throws HsarwebException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ public class ItemsReader {
|
|||||||
|
|
||||||
public static List<Object> readItemList(MainApplication app, String module, String property) throws HsarwebException {
|
public static List<Object> readItemList(MainApplication app, String module, String property) throws HsarwebException {
|
||||||
final List<Object> itemsList = new ArrayList<Object>();
|
final List<Object> itemsList = new ArrayList<Object>();
|
||||||
Object custListObj = app.getRemote().callSearch(module, new HashMap<String, AbstractProperty>());
|
Object custListObj = app.getRemote().callSearch(module, new HashMap<String, XmlrpcProperty>());
|
||||||
if (custListObj instanceof Object[]) {
|
if (custListObj instanceof Object[]) {
|
||||||
Object[] custList = (Object[]) custListObj;
|
Object[] custList = (Object[]) custListObj;
|
||||||
for (Object custObj : custList) {
|
for (Object custObj : custList) {
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
package de.hsadmin.web;
|
package de.hsadmin.web;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ListOfStringsProperty extends AbstractProperty {
|
public class ListOfStringsProperty implements XmlrpcProperty {
|
||||||
|
|
||||||
public final List<String> properties;
|
public final List<String> properties;
|
||||||
|
|
||||||
@ -25,4 +26,8 @@ public class ListOfStringsProperty extends AbstractProperty {
|
|||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Iterator<String> stringsIterator() {
|
||||||
|
return properties.iterator();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,23 +18,23 @@ public class Remote {
|
|||||||
this.app = application;
|
this.app = application;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object callSearch(String module, Map<String, AbstractProperty> where) throws HsarwebException {
|
public Object callSearch(String module, Map<String, XmlrpcProperty> where) throws HsarwebException {
|
||||||
return xmlrpcCall(module, "search", buildXmlrpcParam(where));
|
return xmlrpcCall(module, "search", buildXmlrpcParam(where));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callAdd(String module, Map<String, AbstractProperty> set) throws HsarwebException {
|
public void callAdd(String module, Map<String, XmlrpcProperty> set) throws HsarwebException {
|
||||||
xmlrpcCall(module, "add", buildXmlrpcParam(set));
|
xmlrpcCall(module, "add", buildXmlrpcParam(set));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callUpdate(String module, Map<String, AbstractProperty> set, Map<String, AbstractProperty> where) throws HsarwebException {
|
public void callUpdate(String module, Map<String, XmlrpcProperty> set, Map<String, XmlrpcProperty> where) throws HsarwebException {
|
||||||
xmlrpcCall(module, "update", buildXmlrpcParam(set), buildXmlrpcParam(where));
|
xmlrpcCall(module, "update", buildXmlrpcParam(set), buildXmlrpcParam(where));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void callDelete(String module, Map<String, AbstractProperty> where) throws HsarwebException {
|
public void callDelete(String module, Map<String, XmlrpcProperty> where) throws HsarwebException {
|
||||||
xmlrpcCall(module, "delete", buildXmlrpcParam(where));
|
xmlrpcCall(module, "delete", buildXmlrpcParam(where));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Object> buildXmlrpcParam(Map<String, AbstractProperty> paramHash) {
|
private Map<String, Object> buildXmlrpcParam(Map<String, XmlrpcProperty> paramHash) {
|
||||||
Map<String, Object> resultMap = new HashMap<String, Object>();
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
if (paramHash == null) {
|
if (paramHash == null) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -2,15 +2,28 @@ package de.hsadmin.web;
|
|||||||
|
|
||||||
public class StringProperty extends AbstractProperty {
|
public class StringProperty extends AbstractProperty {
|
||||||
|
|
||||||
public String property ;
|
final public String property ;
|
||||||
|
|
||||||
public StringProperty(String property) {
|
public StringProperty(String property) {
|
||||||
this.property = property;
|
this.property = property;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public StringProperty(Object value) {
|
||||||
|
String temp = "undefined";
|
||||||
|
if (value instanceof String) {
|
||||||
|
temp = (String) value;
|
||||||
|
}
|
||||||
|
this.property = temp;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object toXmlrpcParam() {
|
public Object toXmlrpcParam() {
|
||||||
return property;
|
return property;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toStringValue() {
|
||||||
|
return property;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,6 @@ import java.util.Map;
|
|||||||
|
|
||||||
public interface UpdateAble {
|
public interface UpdateAble {
|
||||||
|
|
||||||
public void updateRow(Map<String, AbstractProperty> paramHash) throws HsarwebException;
|
public void updateRow(Map<String, XmlrpcProperty> paramHash) throws HsarwebException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
7
hsarweb/src/de/hsadmin/web/XmlrpcProperty.java
Normal file
7
hsarweb/src/de/hsadmin/web/XmlrpcProperty.java
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package de.hsadmin.web;
|
||||||
|
|
||||||
|
public interface XmlrpcProperty {
|
||||||
|
|
||||||
|
public abstract Object toXmlrpcParam();
|
||||||
|
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package de.hsadmin.web.config;
|
package de.hsadmin.web.config;
|
||||||
|
|
||||||
import de.hsadmin.web.AbstractProperty;
|
|
||||||
import de.hsadmin.web.HsarwebException;
|
import de.hsadmin.web.HsarwebException;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
|
|
||||||
public interface PropertyFieldFactory {
|
public interface PropertyFieldFactory {
|
||||||
|
|
||||||
public Object createFieldComponent(PropertyConfig prop, Object value);
|
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value);
|
||||||
|
|
||||||
public AbstractProperty getValue(PropertyConfig prop, Object component) throws HsarwebException;
|
public XmlrpcProperty getValue(PropertyConfig prop, Object component) throws HsarwebException;
|
||||||
|
|
||||||
public void setReadOnly(boolean readOnly);
|
public void setReadOnly(boolean readOnly);
|
||||||
|
|
||||||
|
@ -11,7 +11,9 @@ import com.vaadin.ui.DateField;
|
|||||||
import com.vaadin.ui.PopupDateField;
|
import com.vaadin.ui.PopupDateField;
|
||||||
|
|
||||||
import de.hsadmin.web.AbstractProperty;
|
import de.hsadmin.web.AbstractProperty;
|
||||||
|
import de.hsadmin.web.DateProperty;
|
||||||
import de.hsadmin.web.StringProperty;
|
import de.hsadmin.web.StringProperty;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.PropertyConfig;
|
import de.hsadmin.web.config.PropertyConfig;
|
||||||
import de.hsadmin.web.config.PropertyFieldFactory;
|
import de.hsadmin.web.config.PropertyFieldFactory;
|
||||||
|
|
||||||
@ -23,14 +25,21 @@ public class DatePropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
private boolean writeOnce = false;
|
private boolean writeOnce = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createFieldComponent(PropertyConfig prop, Object value) {
|
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) {
|
||||||
DateField dateField = new PopupDateField(prop.getLabel());
|
DateField dateField = new PopupDateField(prop.getLabel());
|
||||||
dateField.setDateFormat("dd.MM.yyyy");
|
dateField.setDateFormat("dd.MM.yyyy");
|
||||||
dateField.setData(prop.getId());
|
dateField.setData(prop.getId());
|
||||||
dateField.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
dateField.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
||||||
try {
|
try {
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
dateField.setValue(serverDf.parse((String) value));
|
if (value instanceof AbstractProperty) {
|
||||||
|
if (value instanceof StringProperty) {
|
||||||
|
dateField.setValue(DateProperty.serverDf.parse(((StringProperty) value).toStringValue()));
|
||||||
|
}
|
||||||
|
if (value instanceof DateProperty) {
|
||||||
|
dateField.setValue(((DateProperty) value).getDateValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
dateField.setReadOnly(isReadOnly());
|
dateField.setReadOnly(isReadOnly());
|
||||||
return dateField;
|
return dateField;
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.vaadin.ui.TextField;
|
|||||||
|
|
||||||
import de.hsadmin.web.AbstractProperty;
|
import de.hsadmin.web.AbstractProperty;
|
||||||
import de.hsadmin.web.StringProperty;
|
import de.hsadmin.web.StringProperty;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.PropertyConfig;
|
import de.hsadmin.web.config.PropertyConfig;
|
||||||
import de.hsadmin.web.config.PropertyFieldFactory;
|
import de.hsadmin.web.config.PropertyFieldFactory;
|
||||||
|
|
||||||
@ -14,11 +15,15 @@ public class DefaultPropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
private boolean writeOnce = false;
|
private boolean writeOnce = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createFieldComponent(PropertyConfig prop, Object value) {
|
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) {
|
||||||
TextField tf = new TextField(prop.getLabel());
|
TextField tf = new TextField(prop.getLabel());
|
||||||
tf.setData(prop.getId());
|
tf.setData(prop.getId());
|
||||||
tf.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
tf.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
||||||
tf.setValue(value != null ? value : prop.getDefaultValue());
|
String valueOrDefault = prop.getDefaultValue();
|
||||||
|
if (value instanceof AbstractProperty) {
|
||||||
|
valueOrDefault = ((AbstractProperty) value).toStringValue();
|
||||||
|
}
|
||||||
|
tf.setValue(valueOrDefault);
|
||||||
tf.setReadOnly(isReadOnly());
|
tf.setReadOnly(isReadOnly());
|
||||||
return tf;
|
return tf;
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,17 @@
|
|||||||
/**
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
package de.hsadmin.web.vaadin;
|
package de.hsadmin.web.vaadin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.vaadin.data.Property;
|
|
||||||
import com.vaadin.data.Property.ValueChangeEvent;
|
|
||||||
import com.vaadin.terminal.Sizeable;
|
import com.vaadin.terminal.Sizeable;
|
||||||
import com.vaadin.ui.AbstractField;
|
import com.vaadin.ui.AbstractField;
|
||||||
import com.vaadin.ui.HorizontalLayout;
|
import com.vaadin.ui.HorizontalLayout;
|
||||||
import com.vaadin.ui.Select;
|
|
||||||
import com.vaadin.ui.VerticalLayout;
|
import com.vaadin.ui.VerticalLayout;
|
||||||
|
|
||||||
import de.hsadmin.web.AbstractProperty;
|
import de.hsadmin.web.AbstractProperty;
|
||||||
import de.hsadmin.web.HsarwebException;
|
import de.hsadmin.web.HsarwebException;
|
||||||
import de.hsadmin.web.ListOfStringsProperty;
|
import de.hsadmin.web.ListOfStringsProperty;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.PropertyConfig;
|
import de.hsadmin.web.config.PropertyConfig;
|
||||||
import de.hsadmin.web.config.PropertyFieldFactory;
|
import de.hsadmin.web.config.PropertyFieldFactory;
|
||||||
|
|
||||||
@ -49,13 +44,13 @@ public class DomainOptionsPropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createFieldComponent(PropertyConfig prop, Object value) {
|
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AbstractProperty getValue(PropertyConfig prop, Object component)
|
public XmlrpcProperty getValue(PropertyConfig prop, Object component)
|
||||||
throws HsarwebException {
|
throws HsarwebException {
|
||||||
return setOptions;
|
return setOptions;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.hsadmin.web.vaadin;
|
package de.hsadmin.web.vaadin;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
@ -18,8 +19,10 @@ import com.vaadin.ui.VerticalLayout;
|
|||||||
import de.hsadmin.web.AbstractProperty;
|
import de.hsadmin.web.AbstractProperty;
|
||||||
import de.hsadmin.web.GenericModule;
|
import de.hsadmin.web.GenericModule;
|
||||||
import de.hsadmin.web.HsarwebException;
|
import de.hsadmin.web.HsarwebException;
|
||||||
|
import de.hsadmin.web.ListOfStringsProperty;
|
||||||
import de.hsadmin.web.Module;
|
import de.hsadmin.web.Module;
|
||||||
import de.hsadmin.web.StringProperty;
|
import de.hsadmin.web.StringProperty;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.PropertyConfig;
|
import de.hsadmin.web.config.PropertyConfig;
|
||||||
import de.hsadmin.web.config.PropertyFieldFactory;
|
import de.hsadmin.web.config.PropertyFieldFactory;
|
||||||
|
|
||||||
@ -61,7 +64,7 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createFieldComponent(PropertyConfig prop, Object value) {
|
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) {
|
||||||
GenericModule genModule = (GenericModule) module;
|
GenericModule genModule = (GenericModule) module;
|
||||||
users = genModule.getUsers();
|
users = genModule.getUsers();
|
||||||
mailAliases = genModule.getEMailAliases();
|
mailAliases = genModule.getEMailAliases();
|
||||||
@ -71,23 +74,23 @@ public class EMailTargetPropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
|
|
||||||
targets = new HashMap<Integer, SingleEMailTarget>();
|
targets = new HashMap<Integer, SingleEMailTarget>();
|
||||||
lastIndex = 0;
|
lastIndex = 0;
|
||||||
if (value instanceof String) {
|
if (value instanceof AbstractProperty) {
|
||||||
StringTokenizer tokenizer = new StringTokenizer((String) value, ",");
|
String stringValue = ((AbstractProperty) value).toStringValue();
|
||||||
|
StringTokenizer tokenizer = new StringTokenizer(stringValue, ",");
|
||||||
while (tokenizer.hasMoreTokens()) {
|
while (tokenizer.hasMoreTokens()) {
|
||||||
String target = tokenizer.nextToken().trim();
|
String target = tokenizer.nextToken().trim();
|
||||||
targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, target));
|
targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, target));
|
||||||
lastIndex++;
|
lastIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (value instanceof Object[]) {
|
if (value instanceof ListOfStringsProperty) {
|
||||||
Object[] list = (Object[]) value;
|
ListOfStringsProperty list = (ListOfStringsProperty) value;
|
||||||
for (Object o : list) {
|
Iterator<String> stringsIterator = list.stringsIterator();
|
||||||
if (o instanceof String) {
|
while (stringsIterator.hasNext()) {
|
||||||
targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, (String) o));
|
targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, stringsIterator.next()));
|
||||||
lastIndex++;
|
lastIndex++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, ""));
|
targets.put(lastIndex, new SingleEMailTarget(this, lastIndex, ""));
|
||||||
repaint();
|
repaint();
|
||||||
return layout;
|
return layout;
|
||||||
|
@ -10,11 +10,12 @@ import com.vaadin.ui.Component;
|
|||||||
import com.vaadin.ui.Form;
|
import com.vaadin.ui.Form;
|
||||||
import com.vaadin.ui.Layout;
|
import com.vaadin.ui.Layout;
|
||||||
|
|
||||||
import de.hsadmin.web.AbstractProperty;
|
|
||||||
import de.hsadmin.web.HsarwebException;
|
import de.hsadmin.web.HsarwebException;
|
||||||
|
import de.hsadmin.web.ListOfStringsProperty;
|
||||||
import de.hsadmin.web.MainApplication;
|
import de.hsadmin.web.MainApplication;
|
||||||
import de.hsadmin.web.Module;
|
import de.hsadmin.web.Module;
|
||||||
import de.hsadmin.web.StringProperty;
|
import de.hsadmin.web.StringProperty;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.ModuleConfig;
|
import de.hsadmin.web.config.ModuleConfig;
|
||||||
import de.hsadmin.web.config.PropertyConfig;
|
import de.hsadmin.web.config.PropertyConfig;
|
||||||
import de.hsadmin.web.config.PropertyFieldFactory;
|
import de.hsadmin.web.config.PropertyFieldFactory;
|
||||||
@ -48,7 +49,7 @@ public class GenericForm {
|
|||||||
try {
|
try {
|
||||||
MainApplication application = module.getApplication();
|
MainApplication application = module.getApplication();
|
||||||
ModuleConfig config = module.getModuleConfig();
|
ModuleConfig config = module.getModuleConfig();
|
||||||
Map<String, AbstractProperty> where = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> where = new HashMap<String, XmlrpcProperty>();
|
||||||
where.put(findIdKey(), new StringProperty(entityId.toString()));
|
where.put(findIdKey(), new StringProperty(entityId.toString()));
|
||||||
Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where);
|
Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where);
|
||||||
if (searchResult instanceof Object[]) {
|
if (searchResult instanceof Object[]) {
|
||||||
@ -60,7 +61,18 @@ public class GenericForm {
|
|||||||
for (PropertyConfig prop : config.getPropertyList()) {
|
for (PropertyConfig prop : config.getPropertyList()) {
|
||||||
if (!prop.getPropTableColumn().equals(PropertyTableColumn.INTERNAL_KEY) && prop.isShowInForm()) {
|
if (!prop.getPropTableColumn().equals(PropertyTableColumn.INTERNAL_KEY) && prop.isShowInForm()) {
|
||||||
PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory();
|
PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory();
|
||||||
Object value = row.get(prop.getId());
|
Object propValue = row.get(prop.getId());
|
||||||
|
XmlrpcProperty value = new StringProperty("");
|
||||||
|
if (propValue instanceof Object[]) {
|
||||||
|
ListOfStringsProperty list = new ListOfStringsProperty();
|
||||||
|
for (Object o : ((Object[]) propValue)) {
|
||||||
|
list.add(o.toString());
|
||||||
|
}
|
||||||
|
value = list;
|
||||||
|
}
|
||||||
|
if (propValue instanceof String) {
|
||||||
|
value = new StringProperty(propValue);
|
||||||
|
}
|
||||||
Component component = (Component) propFieldFactory.createFieldComponent(prop, value);
|
Component component = (Component) propFieldFactory.createFieldComponent(prop, value);
|
||||||
if (propFieldFactory.isWriteOnce()) {
|
if (propFieldFactory.isWriteOnce()) {
|
||||||
component.setReadOnly(true);
|
component.setReadOnly(true);
|
||||||
@ -81,7 +93,7 @@ public class GenericForm {
|
|||||||
try {
|
try {
|
||||||
MainApplication application = module.getApplication();
|
MainApplication application = module.getApplication();
|
||||||
ModuleConfig config = module.getModuleConfig();
|
ModuleConfig config = module.getModuleConfig();
|
||||||
Map<String, AbstractProperty> where = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> where = new HashMap<String, XmlrpcProperty>();
|
||||||
where.put(findIdKey(), new StringProperty(entityId.toString()));
|
where.put(findIdKey(), new StringProperty(entityId.toString()));
|
||||||
Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where);
|
Object searchResult = application.getRemote().callSearch(config.getRemoteName(), where);
|
||||||
if (searchResult instanceof Object[]) {
|
if (searchResult instanceof Object[]) {
|
||||||
@ -96,7 +108,8 @@ public class GenericForm {
|
|||||||
&& prop.getPropTableColumn().equals(PropertyTableColumn.DISPLAY)) {
|
&& prop.getPropTableColumn().equals(PropertyTableColumn.DISPLAY)) {
|
||||||
PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory();
|
PropertyFieldFactory propFieldFactory = prop.getPropFieldFactory();
|
||||||
Object value = row.get(prop.getId());
|
Object value = row.get(prop.getId());
|
||||||
Component component = (Component) propFieldFactory.createFieldComponent(prop, value);
|
StringProperty propValue = new StringProperty(value);
|
||||||
|
Component component = (Component) propFieldFactory.createFieldComponent(prop, propValue);
|
||||||
component.setReadOnly(true);
|
component.setReadOnly(true);
|
||||||
layout.addComponent(component);
|
layout.addComponent(component);
|
||||||
}
|
}
|
||||||
@ -123,7 +136,7 @@ public class GenericForm {
|
|||||||
return idKey;
|
return idKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transferToHash(Map<String, AbstractProperty> map, Form form) throws HsarwebException {
|
public void transferToHash(Map<String, XmlrpcProperty> map, Form form) throws HsarwebException {
|
||||||
Iterator<Component> iterator = form.getLayout().getComponentIterator();
|
Iterator<Component> iterator = form.getLayout().getComponentIterator();
|
||||||
Object formData = form.getData();
|
Object formData = form.getData();
|
||||||
if (formData != null && formData instanceof Long) {
|
if (formData != null && formData instanceof Long) {
|
||||||
|
@ -11,6 +11,7 @@ import de.hsadmin.web.AbstractProperty;
|
|||||||
import de.hsadmin.web.HsarwebException;
|
import de.hsadmin.web.HsarwebException;
|
||||||
import de.hsadmin.web.Module;
|
import de.hsadmin.web.Module;
|
||||||
import de.hsadmin.web.StringProperty;
|
import de.hsadmin.web.StringProperty;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.ModuleConfig;
|
import de.hsadmin.web.config.ModuleConfig;
|
||||||
import de.hsadmin.web.config.PropertyConfig;
|
import de.hsadmin.web.config.PropertyConfig;
|
||||||
import de.hsadmin.web.config.PropertyFieldFactory;
|
import de.hsadmin.web.config.PropertyFieldFactory;
|
||||||
@ -28,7 +29,7 @@ public class PacPrefixedNamePropertyFieldFactory implements PropertyFieldFactory
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createFieldComponent(PropertyConfig prop, Object value) {
|
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) {
|
||||||
ModuleConfig config = module.getModuleConfig();
|
ModuleConfig config = module.getModuleConfig();
|
||||||
HorizontalLayout layout = new HorizontalLayout();
|
HorizontalLayout layout = new HorizontalLayout();
|
||||||
layout.setCaption(prop.getLabel());
|
layout.setCaption(prop.getLabel());
|
||||||
@ -55,7 +56,10 @@ public class PacPrefixedNamePropertyFieldFactory implements PropertyFieldFactory
|
|||||||
tf.setData(prop.getId());
|
tf.setData(prop.getId());
|
||||||
tf.setWidth(384.0f, Sizeable.UNITS_PIXELS);
|
tf.setWidth(384.0f, Sizeable.UNITS_PIXELS);
|
||||||
layout.addComponent(tf);
|
layout.addComponent(tf);
|
||||||
String valueOrDefault = (value != null && value instanceof String) ? ((String) value) : prop.getDefaultValue();
|
String valueOrDefault = prop.getDefaultValue();
|
||||||
|
if (value instanceof AbstractProperty) {
|
||||||
|
valueOrDefault = ((AbstractProperty) value).toStringValue();
|
||||||
|
}
|
||||||
if (valueOrDefault.length() >= 5) {
|
if (valueOrDefault.length() >= 5) {
|
||||||
sel.setValue(valueOrDefault.substring(0, 5));
|
sel.setValue(valueOrDefault.substring(0, 5));
|
||||||
tf.setValue(valueOrDefault.length() > 6 ? valueOrDefault.substring(6) : "");
|
tf.setValue(valueOrDefault.length() > 6 ? valueOrDefault.substring(6) : "");
|
||||||
|
@ -8,6 +8,7 @@ import de.hsadmin.web.AbstractProperty;
|
|||||||
import de.hsadmin.web.HsarwebException;
|
import de.hsadmin.web.HsarwebException;
|
||||||
import de.hsadmin.web.Module;
|
import de.hsadmin.web.Module;
|
||||||
import de.hsadmin.web.StringProperty;
|
import de.hsadmin.web.StringProperty;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.ModuleConfig;
|
import de.hsadmin.web.config.ModuleConfig;
|
||||||
import de.hsadmin.web.config.PropertyConfig;
|
import de.hsadmin.web.config.PropertyConfig;
|
||||||
import de.hsadmin.web.config.PropertyFieldFactory;
|
import de.hsadmin.web.config.PropertyFieldFactory;
|
||||||
@ -24,7 +25,7 @@ public class PasswordPropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createFieldComponent(PropertyConfig prop, Object value) {
|
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) {
|
||||||
ModuleConfig config = module.getModuleConfig();
|
ModuleConfig config = module.getModuleConfig();
|
||||||
VerticalLayout layout = new VerticalLayout();
|
VerticalLayout layout = new VerticalLayout();
|
||||||
layout.setCaption(prop.getLabel());
|
layout.setCaption(prop.getLabel());
|
||||||
@ -32,13 +33,17 @@ public class PasswordPropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
PasswordField tf1 = new PasswordField(config.getLabel(prop.getId() + "1"));
|
PasswordField tf1 = new PasswordField(config.getLabel(prop.getId() + "1"));
|
||||||
tf1.setData(prop.getId());
|
tf1.setData(prop.getId());
|
||||||
tf1.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
tf1.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
||||||
tf1.setValue(value != null ? value : prop.getDefaultValue());
|
String valueOrDefault = prop.getDefaultValue();
|
||||||
|
if (value instanceof AbstractProperty) {
|
||||||
|
valueOrDefault = ((AbstractProperty) value).toStringValue();
|
||||||
|
}
|
||||||
|
tf1.setValue(valueOrDefault);
|
||||||
tf1.setReadOnly(readOnly);
|
tf1.setReadOnly(readOnly);
|
||||||
layout.addComponent(tf1);
|
layout.addComponent(tf1);
|
||||||
PasswordField tf2 = new PasswordField(config.getLabel(prop.getId() + "2"));
|
PasswordField tf2 = new PasswordField(config.getLabel(prop.getId() + "2"));
|
||||||
tf2.setData(prop.getId());
|
tf2.setData(prop.getId());
|
||||||
tf2.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
tf2.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
||||||
tf2.setValue(value != null ? value : prop.getDefaultValue());
|
tf2.setValue(valueOrDefault);
|
||||||
tf2.setReadOnly(readOnly);
|
tf2.setReadOnly(readOnly);
|
||||||
layout.addComponent(tf2);
|
layout.addComponent(tf2);
|
||||||
return layout;
|
return layout;
|
||||||
|
@ -8,6 +8,7 @@ import com.vaadin.ui.Select;
|
|||||||
import de.hsadmin.web.AbstractProperty;
|
import de.hsadmin.web.AbstractProperty;
|
||||||
import de.hsadmin.web.HsarwebException;
|
import de.hsadmin.web.HsarwebException;
|
||||||
import de.hsadmin.web.StringProperty;
|
import de.hsadmin.web.StringProperty;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.PropertyConfig;
|
import de.hsadmin.web.config.PropertyConfig;
|
||||||
import de.hsadmin.web.config.PropertyFieldFactory;
|
import de.hsadmin.web.config.PropertyFieldFactory;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ public class SelectPropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
private boolean writeOnce = false;
|
private boolean writeOnce = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object createFieldComponent(PropertyConfig prop, Object value) {
|
public Object createFieldComponent(PropertyConfig prop, XmlrpcProperty value) {
|
||||||
Select sel = new Select(prop.getLabel());
|
Select sel = new Select(prop.getLabel());
|
||||||
sel.setData(prop.getId());
|
sel.setData(prop.getId());
|
||||||
sel.setNullSelectionAllowed(false);
|
sel.setNullSelectionAllowed(false);
|
||||||
@ -28,7 +29,11 @@ public class SelectPropertyFieldFactory implements PropertyFieldFactory {
|
|||||||
sel.setItemCaption(key, selectValues.get(key));
|
sel.setItemCaption(key, selectValues.get(key));
|
||||||
}
|
}
|
||||||
sel.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
sel.setWidth(480.0f, Sizeable.UNITS_PIXELS);
|
||||||
sel.setValue(value != null ? value : prop.getDefaultValue());
|
String valueOrDefault = prop.getDefaultValue();
|
||||||
|
if (value instanceof AbstractProperty) {
|
||||||
|
valueOrDefault = ((AbstractProperty) value).toStringValue();
|
||||||
|
}
|
||||||
|
sel.setValue(valueOrDefault);
|
||||||
sel.setReadOnly(readOnly);
|
sel.setReadOnly(readOnly);
|
||||||
sel.setInvalidAllowed(prop.newItemsAllowed());
|
sel.setInvalidAllowed(prop.newItemsAllowed());
|
||||||
return sel;
|
return sel;
|
||||||
|
@ -21,13 +21,13 @@ import com.vaadin.ui.VerticalLayout;
|
|||||||
import com.vaadin.ui.Window;
|
import com.vaadin.ui.Window;
|
||||||
import com.vaadin.ui.themes.BaseTheme;
|
import com.vaadin.ui.themes.BaseTheme;
|
||||||
|
|
||||||
import de.hsadmin.web.AbstractProperty;
|
|
||||||
import de.hsadmin.web.DeleteAble;
|
import de.hsadmin.web.DeleteAble;
|
||||||
import de.hsadmin.web.HsarwebException;
|
import de.hsadmin.web.HsarwebException;
|
||||||
import de.hsadmin.web.MainApplication;
|
import de.hsadmin.web.MainApplication;
|
||||||
import de.hsadmin.web.Module;
|
import de.hsadmin.web.Module;
|
||||||
import de.hsadmin.web.StringProperty;
|
import de.hsadmin.web.StringProperty;
|
||||||
import de.hsadmin.web.UpdateAble;
|
import de.hsadmin.web.UpdateAble;
|
||||||
|
import de.hsadmin.web.XmlrpcProperty;
|
||||||
import de.hsadmin.web.config.ComponentFactory;
|
import de.hsadmin.web.config.ComponentFactory;
|
||||||
import de.hsadmin.web.config.LocaleConfig;
|
import de.hsadmin.web.config.LocaleConfig;
|
||||||
import de.hsadmin.web.config.ModuleConfig;
|
import de.hsadmin.web.config.ModuleConfig;
|
||||||
@ -108,7 +108,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable {
|
|||||||
table.removeAllItems();
|
table.removeAllItems();
|
||||||
try {
|
try {
|
||||||
ModuleConfig moduleConfig = module.getModuleConfig();
|
ModuleConfig moduleConfig = module.getModuleConfig();
|
||||||
Object callSearch = module.getApplication().getRemote().callSearch(moduleConfig.getRemoteName(), new HashMap<String, AbstractProperty>());
|
Object callSearch = module.getApplication().getRemote().callSearch(moduleConfig.getRemoteName(), new HashMap<String, XmlrpcProperty>());
|
||||||
List<PropertyConfig> propertyList = moduleConfig.getPropertyList();
|
List<PropertyConfig> propertyList = moduleConfig.getPropertyList();
|
||||||
if (callSearch instanceof Object[]) {
|
if (callSearch instanceof Object[]) {
|
||||||
for (Object row : ((Object[])callSearch)) {
|
for (Object row : ((Object[])callSearch)) {
|
||||||
@ -230,7 +230,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable {
|
|||||||
public void buttonClick(ClickEvent event) {
|
public void buttonClick(ClickEvent event) {
|
||||||
application.getMainWindow().removeWindow(childWindow);
|
application.getMainWindow().removeWindow(childWindow);
|
||||||
try {
|
try {
|
||||||
Map<String, AbstractProperty> map = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> map = new HashMap<String, XmlrpcProperty>();
|
||||||
genericForm.transferToHash(map, form);
|
genericForm.transferToHash(map, form);
|
||||||
((UpdateAble) module).updateRow(map);
|
((UpdateAble) module).updateRow(map);
|
||||||
loadData();
|
loadData();
|
||||||
@ -289,7 +289,7 @@ public class TableComponentFactory implements ComponentFactory, Serializable {
|
|||||||
public void buttonClick(ClickEvent event) {
|
public void buttonClick(ClickEvent event) {
|
||||||
application.getMainWindow().removeWindow(childWindow);
|
application.getMainWindow().removeWindow(childWindow);
|
||||||
try {
|
try {
|
||||||
Map<String, AbstractProperty> map = new HashMap<String, AbstractProperty>();
|
Map<String, XmlrpcProperty> map = new HashMap<String, XmlrpcProperty>();
|
||||||
map.put(findIdKey(), new StringProperty(((Long) button.getData()).toString()));
|
map.put(findIdKey(), new StringProperty(((Long) button.getData()).toString()));
|
||||||
((DeleteAble) module).deleteRow(map);
|
((DeleteAble) module).deleteRow(map);
|
||||||
loadData();
|
loadData();
|
||||||
|
Loading…
Reference in New Issue
Block a user