}\r
\r
public String getLabel() {\r
- return getOneElementValue("commandname");\r
+ return getOneValue("commandname");\r
}\r
\r
public String getMessage() {\r
if (isServiceError()) { \r
return getServiceError().getMsg();\r
} else { \r
- return getOneElementValue("errormessage");\r
+ return getOneValue("errormessage");\r
}\r
}\r
\r
public String getException () {\r
- return getOneElementValue("exception");\r
+ return getOneValue("exception");\r
}\r
\r
public List<String> getSuggestions() { \r
}\r
\r
public String getTitle () {\r
- return getOneElementValue("md-title");\r
+ return getOneValue("md-title");\r
}\r
\r
public String getTitleRemainder() {\r
- return getOneElementValue("md-title-remainder");\r
+ return getOneValue("md-title-remainder");\r
}\r
\r
public String getAuthor (String prefix) {\r
}\r
\r
public String getAuthor () {\r
- return getOneElementValue("md-author");\r
+ return getOneValue("md-author");\r
}\r
\r
public String getTitleResponsibility() {\r
- return getOneElementValue("md-title-responsibility");\r
+ return getOneValue("md-title-responsibility");\r
}\r
\r
public String getDate() {\r
- return getOneElementValue("md-date");\r
+ return getOneValue("md-date");\r
}\r
\r
public String getTitleComplete() {\r
- return getOneElementValue("md-title-complete");\r
+ return getOneValue("md-title-complete");\r
}\r
\r
public String getRecId() {\r
- return getOneElementValue("recid");\r
+ return getOneValue("recid");\r
+ }\r
+ \r
+ public String getDescription() {\r
+ return getOneValue("md-description");\r
}\r
-\r
\r
}\r
private static final long serialVersionUID = -1479775157276901600L;\r
\r
public String getStatus() {\r
- return getOneElementValue("status");\r
+ return getOneValue("status");\r
}\r
\r
}\r
}\r
\r
public String getSubject() {\r
- return getOneElementValue("md-subject");\r
+ return getOneValue("md-subject");\r
}\r
\r
public void setSequenceNumber(int num) {\r
}\r
\r
public String getAuthor() {\r
- return getOneElementValue("md-author");\r
+ return getOneValue("md-author");\r
}\r
\r
public String getAuthors() {\r
private static final long serialVersionUID = 6682722004285796002L;\r
\r
public String getRecId () {\r
- return getOneElementValue("recid");\r
+ return getOneValue("recid");\r
}\r
\r
public List<Location> getLocations() {\r
}\r
\r
public String getTitle() {\r
- return getOneElementValue("md-title");\r
+ return getOneValue("md-title");\r
}\r
\r
public String getDate() {\r
- return getOneElementValue("md-date");\r
+ return getOneValue("md-date");\r
}\r
\r
public String getAuthor() {\r
- return getOneElementValue("md-author");\r
+ return getOneValue("md-author");\r
}\r
\r
public String getSubject() {\r
- return getOneElementValue("md-subject");\r
+ return getOneValue("md-subject");\r
}\r
\r
public String getSubjects() {\r
if (getIsBinary()) {\r
return "0";\r
} else {\r
- String activeclients = getOneElementValue("activeclients");\r
+ String activeclients = getOneValue("activeclients");\r
if (activeclients == null || activeclients.length()==0) {\r
// Look for override\r
activeclients = getAttribute("activeclients");\r
elements.get(name).add(value);\r
} else {\r
List<ResponseDataObject> list = new ArrayList<ResponseDataObject>();\r
- list.add(value);\r
+ list.add(value); \r
elements.put(name,list);\r
}\r
}\r
return elements.get(name);\r
}\r
\r
+ public List<ResponseDataObject> getElements(String name, int maxElements) {\r
+ if (getElements(name)!=null) {\r
+ int size = getElements(name).size();\r
+ if (size>0) {\r
+ return ((ArrayList<ResponseDataObject>) getElements(name)).subList(0, Math.min(maxElements,size)); \r
+ } \r
+ } \r
+ return getElements(name);\r
+ }\r
+ \r
+ public List<ResponseDataObject> getElements(String name, int maxElements, int maxTotalValueLength) {\r
+ if (getElements(name)!=null) {\r
+ int size = getElements(name).size();\r
+ if (size>0) {\r
+ List<ResponseDataObject> maxElementsList = ((ArrayList<ResponseDataObject>) getElements(name)).subList(0, Math.min(maxElements,size));\r
+ int i = 0;\r
+ int totalLength = 0;\r
+ for (ResponseDataObject element : maxElementsList) {\r
+ totalLength += element.getValue().length(); \r
+ i++;\r
+ if (totalLength>maxTotalValueLength) {\r
+ break;\r
+ } \r
+ }\r
+ return maxElementsList.subList(0, i);\r
+ } \r
+ } \r
+ return getElements(name);\r
+ }\r
+\r
+ \r
public ResponseDataObject getOneElement (String name) {\r
if (elements.get(name) != null) {\r
return elements.get(name).get(0);\r
* @param name of the element \r
* @return text value, empty string if none found\r
*/\r
- public String getOneElementValue (String name) {\r
+ public String getOneValue (String name) {\r
if (getOneElement(name)!=null && getOneElement(name).getValue().length()>0) {\r
return getOneElement(name).getValue();\r
} else {\r
}\r
}\r
\r
+ public String[] getValueArray (String name) {\r
+ List<ResponseDataObject> elements = getElements(name);\r
+ String[] valueArray = {};\r
+ if (elements != null) {\r
+ valueArray = new String[elements.size()];\r
+ int i = 0;\r
+ for (ResponseDataObject element : elements) {\r
+ valueArray[i++] = element.getValue();\r
+ } \r
+ }\r
+ return valueArray;\r
+ }\r
+ \r
public void appendContent (String content) {\r
textContent = textContent + content;\r
}\r
}\r
\r
public int getIntValue(String name) {\r
- String val = getOneElementValue(name);\r
+ String val = getOneValue(name);\r
if (val.length()==0) {\r
return 0;\r
} else {\r
private boolean isNew = true;\r
\r
public String getStatus() {\r
- return getOneElementValue("status");\r
+ return getOneValue("status");\r
}\r
\r
public boolean isNew () {\r
\r
\r
public String getStatus() {\r
- return getOneElementValue("status");\r
+ return getOneValue("status");\r
}\r
\r
public String getActiveClients () {\r
- return getOneElementValue("activeclients");\r
+ return getOneValue("activeclients");\r
}\r
\r
public int getMerged () {\r
}\r
\r
public String getTotal () {\r
- return getOneElementValue("total"); \r
+ return getOneValue("total"); \r
}\r
\r
public int getStart () {\r
}\r
\r
public String getProgress() {\r
- return getOneElementValue("progress");\r
+ return getOneValue("progress");\r
}\r
\r
}\r
private static final long serialVersionUID = 3343881183545520108L;\r
\r
public String getId () {\r
- return getOneElementValue("id");\r
+ return getOneValue("id");\r
}\r
\r
public String getName() {\r
- return getOneElementValue("name");\r
+ return getOneValue("name");\r
}\r
\r
public String getHits() {\r
- return getOneElementValue("hits");\r
+ return getOneValue("hits");\r
}\r
\r
public String getDiagnostic() {\r
- return getOneElementValue("diagnostic");\r
+ return getOneValue("diagnostic");\r
}\r
\r
public String getRecords() {\r
- return getOneElementValue("records");\r
+ return getOneValue("records");\r
}\r
\r
public String getState () {\r
- return getOneElementValue("state");\r
+ return getOneValue("state");\r
}\r
\r
}\r
private static final long serialVersionUID = 8006774126022849936L;\r
\r
public String getDisplayName () {\r
- return getOneElementValue("displayName");\r
+ return getOneValue("displayName");\r
}\r
\r
public String getRealm () {\r
- return getOneElementValue("realm");\r
+ return getOneValue("realm");\r
}\r
\r
public String getStatus () {\r
- return getOneElementValue("status");\r
+ return getOneValue("status");\r
}\r
\r
public String getAuthenticationType () {\r
- return getOneElementValue("type");\r
+ return getOneValue("type");\r
}\r
\r
public String onSuccess(String navigateTo) {\r
private static final long serialVersionUID = -3027515807117682584L;\r
\r
public String getCategoryName () {\r
- return getOneElementValue("categoryName");\r
+ return getOneValue("categoryName");\r
}\r
\r
public String getCategoryId() {\r
- return getOneElementValue("categoryId");\r
+ return getOneValue("categoryId");\r
}\r
\r
}\r
package com.indexdata.mkjsf.utils;\r
\r
+import javax.enterprise.context.ApplicationScoped;\r
+import javax.inject.Named;\r
+\r
+@Named("utils")\r
+@ApplicationScoped\r
public class Utils {\r
\r
public static String nl = System.getProperty("line.separator"); \r
return objectId(objName);\r
}\r
}\r
+ \r
+ public static String concat(String... strings) {\r
+ StringBuilder concatenated = new StringBuilder("");\r
+ for (String string : strings) {\r
+ concatenated.append(string);\r
+ }\r
+ return concatenated.toString();\r
+ }\r
}\r