Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
issue imixs#364
  • Loading branch information
rsoika committed Apr 15, 2018
1 parent f57728e commit 6a0ea6f
Show file tree
Hide file tree
Showing 24 changed files with 506 additions and 448 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

import org.imixs.workflow.exceptions.InvalidAccessException;
import org.imixs.workflow.xml.XMLItem;
import org.imixs.workflow.xml.XMLItemCollection;
import org.imixs.workflow.xml.XMLDocument;

/**
* This Class defines a ValueObject to be used to exchange data structures used
Expand Down Expand Up @@ -771,7 +771,7 @@ private static boolean isBasicType(java.lang.Object o) {
// test raw array types first
if (o instanceof byte[] || o instanceof boolean[] || o instanceof short[] || o instanceof char[]
|| o instanceof int[] || o instanceof long[] || o instanceof float[] || o instanceof double[]
|| o instanceof XMLItem[] || o instanceof XMLItemCollection[]) {
|| o instanceof XMLItem[] || o instanceof XMLDocument[]) {
return true;
}

Expand All @@ -780,7 +780,7 @@ private static boolean isBasicType(java.lang.Object o) {
String name = c.getName();
if (name.startsWith("java.lang.") || name.startsWith("java.math.") || "java.util.Date".equals(name)
|| "org.imixs.workflow.xml.XMLItem".equals(name)
|| "org.imixs.workflow.xml.XMLItemCollection".equals(name)) {
|| "org.imixs.workflow.xml.XMLDocument".equals(name)) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@

import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.util.Base64;
import org.imixs.workflow.xml.DocumentCollection;
import org.imixs.workflow.xml.XMLItemCollection;
import org.imixs.workflow.xml.XMLItemCollectionAdapter;
import org.imixs.workflow.xml.XMLDataCollection;
import org.imixs.workflow.xml.XMLDocument;
import org.imixs.workflow.xml.XMLDocumentAdapter;
import org.imixs.workflow.xml.XMLDataCollectionAdapter;

/**
* This ServiceClient is a WebService REST Client which encapsulate the
Expand Down Expand Up @@ -160,7 +161,7 @@ public void setContent(String content) {
* - an Entity Collection
* @return HTTPResult
*/
public int postEntity(String uri, XMLItemCollection aItemCol) throws Exception {
public int postEntity(String uri, XMLDocument aItemCol) throws Exception {
PrintWriter printWriter = null;

HttpURLConnection urlConnection = null;
Expand All @@ -183,7 +184,7 @@ public int postEntity(String uri, XMLItemCollection aItemCol) throws Exception {

StringWriter writer = new StringWriter();

JAXBContext context = JAXBContext.newInstance(XMLItemCollection.class);
JAXBContext context = JAXBContext.newInstance(XMLDocument.class);
Marshaller m = context.createMarshaller();
m.marshal(aItemCol, writer);

Expand Down Expand Up @@ -231,7 +232,7 @@ public int postEntity(String uri, XMLItemCollection aItemCol) throws Exception {
* - an Entity Collection
* @return HTTPResult
*/
public int postCollection(String uri, DocumentCollection aEntityCol) throws Exception {
public int postCollection(String uri, XMLDataCollection aEntityCol) throws Exception {
PrintWriter printWriter = null;

HttpURLConnection urlConnection = null;
Expand All @@ -255,7 +256,7 @@ public int postCollection(String uri, DocumentCollection aEntityCol) throws Exce

StringWriter writer = new StringWriter();

JAXBContext context = JAXBContext.newInstance(DocumentCollection.class);
JAXBContext context = JAXBContext.newInstance(XMLDataCollection.class);
Marshaller m = context.createMarshaller();
m.marshal(aEntityCol, writer);

Expand Down Expand Up @@ -509,12 +510,12 @@ public List<ItemCollection> getDocumentCollection(String url) throws Exception {
String xmlResult = this.getContent();

// convert into ItemCollection list
JAXBContext context = JAXBContext.newInstance(DocumentCollection.class);
JAXBContext context = JAXBContext.newInstance(XMLDataCollection.class);
Unmarshaller u = context.createUnmarshaller();
StringReader reader = new StringReader(xmlResult);
DocumentCollection xmlDocuments = (DocumentCollection) u.unmarshal(reader);
XMLDataCollection xmlDocuments = (XMLDataCollection) u.unmarshal(reader);

List<ItemCollection> documents = XMLItemCollectionAdapter.getCollection(xmlDocuments);
List<ItemCollection> documents = XMLDataCollectionAdapter.putDataCollection(xmlDocuments);
return documents;

}
Expand All @@ -531,14 +532,14 @@ public ItemCollection getDocument(String url) throws Exception {
String xmlResult = this.getContent();

// convert into ItemCollection list
JAXBContext context = JAXBContext.newInstance(XMLItemCollection.class);
JAXBContext context = JAXBContext.newInstance(XMLDocument.class);
//JAXBContext context = JAXBContext.newInstance( "org.imixs.workflow.xml" );

Unmarshaller u = context.createUnmarshaller();
StringReader reader = new StringReader(xmlResult);
XMLItemCollection xmlDocument = (XMLItemCollection) u.unmarshal(reader);
XMLDocument xmlDocument = (XMLDocument) u.unmarshal(reader);

ItemCollection document = XMLItemCollectionAdapter.getItemCollection(xmlDocument);
ItemCollection document = XMLDocumentAdapter.putDocument(xmlDocument);
return document;

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import org.imixs.workflow.ItemCollection;
import org.imixs.workflow.services.rest.RestClient;
import org.imixs.workflow.xml.XMLItemCollectionAdapter;
import org.imixs.workflow.xml.XMLDataCollectionAdapter;
import org.imixs.workflow.xml.XMLDocumentAdapter;

/**
* The Imixs WorkflowTestSuite provides a test framework for testing business
Expand Down Expand Up @@ -131,7 +132,7 @@ public List<ItemCollection> getWorklist(String user, String resourceType, String
int result = client.get(url);
if (result >= 200 && result <= 299) {
String content = client.getContent();
resultList = XMLItemCollectionAdapter.readCollection(content
resultList = XMLDataCollectionAdapter.readCollection(content
.getBytes());
}

Expand Down Expand Up @@ -168,10 +169,10 @@ public ItemCollection processWorkitem(ItemCollection workitem, String user) {

try {
int result = client.postEntity(getHost() + "workflow/workitem",
XMLItemCollectionAdapter.putItemCollection(workitem));
XMLDocumentAdapter.getDocument(workitem));
if (result >= 200 && result <= 299) {
String content = client.getContent();
resultWorkitem = XMLItemCollectionAdapter
resultWorkitem = XMLDocumentAdapter
.readItemCollection(content.getBytes());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,25 @@
public class DocumentTable implements java.io.Serializable {

private static final long serialVersionUID = 1L;
private XMLItemCollection[] document;
private XMLDocument[] document;
private List<String> items;
private List<String> labels;

public DocumentTable() {
setDocument(new XMLItemCollection[] {});
setDocument(new XMLDocument[] {});
}

public DocumentTable(XMLItemCollection[] documents,List<String> items,List<String> labels) {
public DocumentTable(XMLDocument[] documents,List<String> items,List<String> labels) {
setDocument(documents);
setItems(items);
setLabels(labels);
}

public XMLItemCollection[] getDocument() {
public XMLDocument[] getDocument() {
return document;
}

public void setDocument(XMLItemCollection[] document) {
public void setDocument(XMLDocument[] document) {
this.document = document;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,31 +29,28 @@
import javax.xml.bind.annotation.XmlRootElement;

/**
* The DocumentCollection represents a list of XMLItemCollections to be used by
* JAXB api
* The XMLDataCollection represents a list of XMLItemCollections. This root element
* is used by JAXB api
*
* @author rsoika
* @version 0.0.1
*/
@XmlRootElement(name="data")
public class DocumentCollection implements java.io.Serializable {
@XmlRootElement(name = "data")
public class XMLDataCollection implements java.io.Serializable {

private static final long serialVersionUID = 1L;
private XMLItemCollection[] document;
private XMLDocument[] document;

public DocumentCollection() {
setDocument(new XMLItemCollection[] {});
public XMLDataCollection() {
setDocument(new XMLDocument[] {});
}

public XMLItemCollection[] getDocument() {
public XMLDocument[] getDocument() {
return document;
}

public void setDocument(XMLItemCollection[] entity) {
public void setDocument(XMLDocument[] entity) {
this.document = entity;
}




}
Loading

0 comments on commit 6a0ea6f

Please sign in to comment.