From 6a0ea6fde386f34afdcf5627fa14160e190cf3ea Mon Sep 17 00:00:00 2001 From: Ralph Soika Date: Sun, 15 Apr 2018 17:53:15 +0200 Subject: [PATCH] refactoring issue #364 --- .../org/imixs/workflow/ItemCollection.java | 6 +- .../workflow/services/rest/RestClient.java | 27 +- .../workflow/test/WorkflowTestSuite.java | 9 +- .../org/imixs/workflow/xml/DocumentTable.java | 10 +- ...Collection.java => XMLDataCollection.java} | 21 +- .../xml/XMLDataCollectionAdapter.java | 236 ++++++++++++++++++ ...MLItemCollection.java => XMLDocument.java} | 8 +- ...onAdapter.java => XMLDocumentAdapter.java} | 233 ++--------------- .../imixs/workflow/TestItemCollection.java | 26 +- .../bpmn/MigrateImixsModelToBPMN.java | 4 +- .../workflow/xml/TestReadWriteByteArray.java | 4 +- .../workflow/xml/TestReadWriteXMLData.java | 14 +- .../imixs/workflow/xml/TestWriteXMLData.java | 10 +- .../xml/TestXMLItemCollectionAdapter.java | 50 ++-- .../workflow/engine/plugins/MailPlugin.java | 11 +- .../workflow/engine/plugins/ReportPlugin.java | 10 +- .../workflow/jaxrs/AdminPRestService.java | 21 +- .../jaxrs/DocumentCollectionWriter.java | 14 +- .../workflow/jaxrs/DocumentRestService.java | 37 +-- .../workflow/jaxrs/DocumentTableWriter.java | 8 +- .../workflow/jaxrs/ModelRestService.java | 47 ++-- .../workflow/jaxrs/ReportRestService.java | 39 +-- .../workflow/jaxrs/WorkflowRestService.java | 93 +++---- .../jaxrs/XMLItemCollectionWriter.java | 16 +- 24 files changed, 506 insertions(+), 448 deletions(-) rename imixs-workflow-core/src/main/java/org/imixs/workflow/xml/{DocumentCollection.java => XMLDataCollection.java} (77%) create mode 100644 imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDataCollectionAdapter.java rename imixs-workflow-core/src/main/java/org/imixs/workflow/xml/{XMLItemCollection.java => XMLDocument.java} (90%) rename imixs-workflow-core/src/main/java/org/imixs/workflow/xml/{XMLItemCollectionAdapter.java => XMLDocumentAdapter.java} (53%) diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java index 1ea4f33bf..b4f5f0675 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/ItemCollection.java @@ -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 @@ -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; } @@ -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; } diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/services/rest/RestClient.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/services/rest/RestClient.java index 9d95abe34..fb0ad645d 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/services/rest/RestClient.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/services/rest/RestClient.java @@ -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 @@ -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; @@ -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); @@ -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; @@ -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); @@ -509,12 +510,12 @@ public List 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 documents = XMLItemCollectionAdapter.getCollection(xmlDocuments); + List documents = XMLDataCollectionAdapter.putDataCollection(xmlDocuments); return documents; } @@ -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; } diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/test/WorkflowTestSuite.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/test/WorkflowTestSuite.java index ad4563116..7c2b77fd6 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/test/WorkflowTestSuite.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/test/WorkflowTestSuite.java @@ -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 @@ -131,7 +132,7 @@ public List 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()); } @@ -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()); } diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/DocumentTable.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/DocumentTable.java index 5d3fc63f6..02b7014ea 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/DocumentTable.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/DocumentTable.java @@ -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 items; private List labels; public DocumentTable() { - setDocument(new XMLItemCollection[] {}); + setDocument(new XMLDocument[] {}); } - public DocumentTable(XMLItemCollection[] documents,List items,List labels) { + public DocumentTable(XMLDocument[] documents,List items,List 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; } diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/DocumentCollection.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDataCollection.java similarity index 77% rename from imixs-workflow-core/src/main/java/org/imixs/workflow/xml/DocumentCollection.java rename to imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDataCollection.java index 2d821cad2..3601b0e15 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/DocumentCollection.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDataCollection.java @@ -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; } - - - } diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDataCollectionAdapter.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDataCollectionAdapter.java new file mode 100644 index 000000000..5e4c89a8f --- /dev/null +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDataCollectionAdapter.java @@ -0,0 +1,236 @@ +/******************************************************************************* + * Imixs Workflow + * Copyright (C) 2001, 2011 Imixs Software Solutions GmbH, + * http://www.imixs.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You can receive a copy of the GNU General Public + * License at http://www.gnu.org/licenses/gpl.html + * + * Project: + * http://www.imixs.org + * http://java.net/projects/imixs-workflow + * + * Contributors: + * Imixs Software Solutions GmbH - initial API and implementation + * Ralph Soika - Software Developer + *******************************************************************************/ +package org.imixs.workflow.xml; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; +import java.util.logging.Logger; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; + +import org.imixs.workflow.ItemCollection; + +/** + * An XMLItemCollectionAdapter converts a + * org.imixs.workflow.xml.XMLItemCollection into a + * org.imixs.workflow.ItemCollection and reverse + * + * @author imixs.com - Ralph Soika + * @version 1.1 + * @see org.imixs.workflow.ItemCollection + */ + +public class XMLDataCollectionAdapter { + private static Logger logger = Logger.getLogger(XMLDataCollectionAdapter.class.getName()); + + + /** + * This Method converts a org.imixs.workflow.xml.DocumentCollection + * into a List of org.imixs.workflow.ItemCollection + * + * The method returns an empty list if the collection is empty or null + * + * @param entity + * @return ItemCollection + */ + public static List putDataCollection(XMLDataCollection doccol) { + List result = new ArrayList(); + + if (doccol != null && doccol.getDocument() != null) { + for (int i = 0; i < doccol.getDocument().length; i++) { + XMLDocument xmlItemCol = doccol.getDocument()[i]; + result.add(XMLDocumentAdapter.putDocument(xmlItemCol)); + } + } + return result; + } + + + + + + /** + * This method transforms a Collection into a DocumentCollection + * + * @param col + * @return + */ + public static XMLDataCollection getDataCollection(final Collection col) { + return getDataCollection(col, null); + } + + /** + * This method transforms a Collection into a XMLDocumentCollection + * + * If the attribute List is provided only the corresponding properties will be + * returned. + * + * @param col + * - collection of ItemCollection objects to be converted + * @param itemNames + * - optional list of item names to be converted. If null all items + * will be converted + * @return + */ + public static XMLDataCollection getDataCollection(final Collection col, final List itemNames) { + XMLDataCollection entiCol = new XMLDataCollection(); + Iterator it = col.iterator(); + int max = col.size(); + int i = 0; + XMLDocument[] entities = new XMLDocument[max]; + while (it.hasNext()) { + ItemCollection icw = (ItemCollection) it.next(); + XMLDocument entity = XMLDocumentAdapter.getDocument(icw, itemNames); + entities[i] = entity; + i++; + } + if (max > 0) + entiCol.setDocument(entities); + return entiCol; + } + + + /** + * This method transforms a single ItemCollection into a XMLDocumentCollection + * + */ + public static XMLDataCollection getDataCollection(final ItemCollection doc) { + List col=new ArrayList(); + col.add(doc); + return getDataCollection(col,null); + } + + + /** + * This method transforms a single ItemCollection into a XMLDocumentCollection + * + */ + public static XMLDataCollection getDataCollection(final ItemCollection doc, final List itemNames) { + List col=new ArrayList(); + col.add(doc); + return getDataCollection(col,itemNames); + } + + + /** + * This method imports an xml entity data stream and returns a List of + * ItemCollection objects. The method can import any kind of entity data like + * model or configuration data an xml export of workitems. + * + * @param inputStream + * xml input stream + * @throws JAXBException + * @throws IOException + * @return List of ItemCollection objects + */ + public static List readCollectionFromInputStream(InputStream inputStream) + throws JAXBException, IOException { + byte[] byteInput = null; + + if (inputStream == null) { + return null; + } + byteInput = getBytesFromStream(inputStream); + return readCollection(byteInput); + + } + + + + + + + /** + * This method imports an xml entity data byte array and returns a List of + * ItemCollection objects. The method can import any kind of entity data like + * model or configuration data an xml export of workitems. + * + * @param inputStream + * xml input stream + * @throws JAXBException + * @throws IOException + * @return List of ItemCollection objects + */ + public static List readCollection(byte[] byteInput) throws JAXBException, IOException { + + List resultList = new ArrayList(); + + if (byteInput == null) { + return null; + } + + XMLDataCollection ecol = null; + logger.finest("......readCollection importXmlEntityData - verifing content...."); + JAXBContext context = JAXBContext.newInstance(XMLDataCollection.class); + Unmarshaller m = context.createUnmarshaller(); + + ByteArrayInputStream input = new ByteArrayInputStream(byteInput); + Object jaxbObject = m.unmarshal(input); + if (jaxbObject == null) { + throw new RuntimeException("readCollection error - wrong xml file format - unable to read content!"); + } + + ecol = (XMLDataCollection) jaxbObject; + + // convert entities.... + if (ecol.getDocument().length > 0) { + for (XMLDocument aentity : ecol.getDocument()) { + resultList.add(XMLDocumentAdapter.putDocument(aentity)); + } + logger.fine("readCollection" + ecol.getDocument().length + " entries sucessfull imported"); + } + return resultList; + + } + + + + + + + + private static byte[] getBytesFromStream(InputStream is) throws IOException { + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + int nRead; + byte[] data = new byte[0x4000]; + while ((nRead = is.read(data, 0, data.length)) != -1) { + buffer.write(data, 0, nRead); + } + buffer.flush(); + is.close(); + return buffer.toByteArray(); + } + +} diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLItemCollection.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDocument.java similarity index 90% rename from imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLItemCollection.java rename to imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDocument.java index c808abe2b..376e720af 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLItemCollection.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDocument.java @@ -38,12 +38,12 @@ * @version 0.0.1 */ @XmlRootElement(name = "document") -public class XMLItemCollection implements java.io.Serializable { +public class XMLDocument implements java.io.Serializable { private static final long serialVersionUID = 1L; private org.imixs.workflow.xml.XMLItem[] item; - public XMLItemCollection() { + public XMLDocument() { this.setItem(new XMLItem[] {}); } @@ -59,9 +59,9 @@ public void setItem(org.imixs.workflow.xml.XMLItem[] item) { * This method compares the item array */ public boolean equals(Object o) { - if (!(o instanceof XMLItemCollection)) + if (!(o instanceof XMLDocument)) return false; - return Arrays.equals(item,((XMLItemCollection)o).item); + return Arrays.equals(item,((XMLDocument)o).item); } } diff --git a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLItemCollectionAdapter.java b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDocumentAdapter.java similarity index 53% rename from imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLItemCollectionAdapter.java rename to imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDocumentAdapter.java index 7d4a6f0fb..82e0b8e08 100644 --- a/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLItemCollectionAdapter.java +++ b/imixs-workflow-core/src/main/java/org/imixs/workflow/xml/XMLDocumentAdapter.java @@ -33,7 +33,6 @@ import java.io.StringWriter; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -49,8 +48,8 @@ import org.imixs.workflow.ItemCollection; /** - * An XMLItemCollectionAdapter converts a - * org.imixs.workflow.xml.XMLItemCollection into a + * An XMLDocumentAdapter converts a + * org.imixs.workflow.xml.XMLDocument into a * org.imixs.workflow.ItemCollection and reverse * * @author imixs.com - Ralph Soika @@ -58,8 +57,8 @@ * @see org.imixs.workflow.ItemCollection */ -public class XMLItemCollectionAdapter { - private static Logger logger = Logger.getLogger(XMLItemCollectionAdapter.class.getName()); +public class XMLDocumentAdapter { + private static Logger logger = Logger.getLogger(XMLDocumentAdapter.class.getName()); /** * This Method converts a org.imixs.workflow.xml.XMLItemCollection @@ -70,13 +69,13 @@ public class XMLItemCollectionAdapter { * @return ItemCollection */ @SuppressWarnings({ "rawtypes" }) - public static ItemCollection getItemCollection(final XMLItemCollection entity) { + public static ItemCollection putDocument(final XMLDocument xmlDocument) { ItemCollection itemCol = new ItemCollection(); - if (entity == null) { + if (xmlDocument == null) { return itemCol; } - XMLItem items[] = entity.getItem(); + XMLItem items[] = xmlDocument.getItem(); if (items != null) for (int i = 0; i < items.length; i++) { XMLItem it = items[i]; @@ -97,31 +96,21 @@ public static ItemCollection getItemCollection(final XMLItemCollection entity) { } return itemCol; } - + /** - * This Method converts a org.imixs.workflow.xml.DocumentCollection - * into a List of org.imixs.workflow.ItemCollection - * - * The method returns an empty list if the collection is empty or null + * This Method converts a org.imixs.workflow.ItemCollection into a + * XMLDocument * - * @param entity - * @return ItemCollection + * @param aItemCollection + * Collection Object to be converted */ - public static List getCollection(DocumentCollection doccol) { - List result = new ArrayList(); - - if (doccol != null && doccol.getDocument() != null) { - for (int i = 0; i < doccol.getDocument().length; i++) { - XMLItemCollection xmlItemCol = doccol.getDocument()[i]; - result.add(getItemCollection(xmlItemCol)); - } - } - return result; + public static XMLDocument getDocument(final ItemCollection aItemCollection) { + return getDocument(aItemCollection, null); } /** * This Method converts a org.imixs.workflow.ItemCollection into a - * XMLItemCollection + * XMLDocument * *

* The method verifies if the values stored are basic java types. If not these @@ -134,14 +123,14 @@ public static List getCollection(DocumentCollection doccol) { * will be converted */ @SuppressWarnings({ "unchecked" }) - public static XMLItemCollection putItemCollection(final ItemCollection sourceItemCollection, + public static XMLDocument getDocument(final ItemCollection sourceItemCollection, final List itemNames) { // create a deep copy of the source ItemCollection aItemCollection = (ItemCollection) sourceItemCollection.clone(); String itemName = null; - XMLItemCollection entity = new XMLItemCollection(); + XMLDocument entity = new XMLDocument(); int i = 0; XMLItem[] items = null; @@ -195,14 +184,14 @@ public static XMLItemCollection putItemCollection(final ItemCollection sourceIte return entity; } - + /** * This method sorts all items of a XMLItemCollection by item name. * * @param xmlItemCol * @return */ - public static XMLItemCollection sortItemsByName(XMLItemCollection xmlItemCol) { + public static XMLDocument sortItemsByName(XMLDocument xmlItemCol) { XMLItem[] items = xmlItemCol.getItem(); Arrays.sort(items, new XMLItemComparator()); @@ -212,135 +201,9 @@ public static XMLItemCollection sortItemsByName(XMLItemCollection xmlItemCol) { return xmlItemCol; } - /** - * This Method converts a org.imixs.workflow.ItemCollection into a - * Entity - * - *

- * The method verifies if the values stored are basic java types. If not these - * values will not be converted! - * - * @param aItemCollection - * Collection Object to be converted - */ - public static XMLItemCollection putItemCollection(final ItemCollection aItemCollection) { - return putItemCollection(aItemCollection, null); - } - - /** - * This method transforms a Collection into a DocumentCollection - * - * @param col - * @return - */ - public static DocumentCollection putDocuments(final Collection col) { - - return putDocuments(col, null); - } - - /** - * This method transforms a Collection into a DocumentCollection - * - * If the attribute List is provided only the corresponding properties will be - * returned. - * - * @param col - * - collection of ItemCollection objects to be converted - * @param itemNames - * - optional list of item names to be converted. If null all items - * will be converted - * @return - */ - public static DocumentCollection putDocuments(final Collection col, final List itemNames) { - DocumentCollection entiCol = new DocumentCollection(); - Iterator it = col.iterator(); - int max = col.size(); - int i = 0; - XMLItemCollection[] entities = new XMLItemCollection[max]; - while (it.hasNext()) { - ItemCollection icw = (ItemCollection) it.next(); - XMLItemCollection entity = putItemCollection(icw, itemNames); - entities[i] = entity; - i++; - } - if (max > 0) - entiCol.setDocument(entities); - return entiCol; - } - - - - /** - * This method transforms a single ItemCollection into a DocumentCollection with one element. - * - * If the attribute List is provided only the corresponding properties will be - * returned. - * - * @param col - * - collection of ItemCollection objects to be converted - * @param itemNames - * - optional list of item names to be converted. If null all items - * will be converted - * @return - */ - public static DocumentCollection putDocuments(final ItemCollection doc, final List itemNames) { - DocumentCollection entiCol = new DocumentCollection(); - List col=new ArrayList(); - col.add(doc); - - Iterator it = col.iterator(); - int max = col.size(); - int i = 0; - XMLItemCollection[] entities = new XMLItemCollection[max]; - while (it.hasNext()) { - ItemCollection icw = (ItemCollection) it.next(); - XMLItemCollection entity = putItemCollection(icw, itemNames); - entities[i] = entity; - i++; - } - if (max > 0) - entiCol.setDocument(entities); - return entiCol; - } - - /** - * This method transforms single ItemCollection into a DocumentCollection with one element. - * - * @param doc - * @return - */ - public static DocumentCollection putDocuments(final ItemCollection doc) { - return putDocuments(doc, null); - } - - - - - - - /** - * This method imports an xml entity data stream and returns a List of - * ItemCollection objects. The method can import any kind of entity data like - * model or configuration data an xml export of workitems. - * - * @param inputStream - * xml input stream - * @throws JAXBException - * @throws IOException - * @return List of ItemCollection objects - */ - public static List readCollectionFromInputStream(InputStream inputStream) - throws JAXBException, IOException { - byte[] byteInput = null; - if (inputStream == null) { - return null; - } - byteInput = getBytesFromStream(inputStream); - return readCollection(byteInput); - } @@ -368,49 +231,6 @@ public static ItemCollection readItemCollectionFromInputStream(InputStream input - /** - * This method imports an xml entity data byte array and returns a List of - * ItemCollection objects. The method can import any kind of entity data like - * model or configuration data an xml export of workitems. - * - * @param inputStream - * xml input stream - * @throws JAXBException - * @throws IOException - * @return List of ItemCollection objects - */ - public static List readCollection(byte[] byteInput) throws JAXBException, IOException { - - List resultList = new ArrayList(); - - if (byteInput == null) { - return null; - } - - DocumentCollection ecol = null; - logger.finest("......readCollection importXmlEntityData - verifing content...."); - JAXBContext context = JAXBContext.newInstance(DocumentCollection.class); - Unmarshaller m = context.createUnmarshaller(); - - ByteArrayInputStream input = new ByteArrayInputStream(byteInput); - Object jaxbObject = m.unmarshal(input); - if (jaxbObject == null) { - throw new RuntimeException("readCollection error - wrong xml file format - unable to read content!"); - } - - ecol = (DocumentCollection) jaxbObject; - - // convert entities.... - if (ecol.getDocument().length > 0) { - for (XMLItemCollection aentity : ecol.getDocument()) { - resultList.add(XMLItemCollectionAdapter.getItemCollection(aentity)); - } - logger.fine("readCollection" + ecol.getDocument().length + " entries sucessfull imported"); - } - return resultList; - - } - /** * This method imports a single XMLItemCollection and returns the ItemCollection * object. @@ -427,9 +247,9 @@ public static ItemCollection readItemCollection(byte[] byteInput) throws JAXBExc return null; } - XMLItemCollection ecol = null; + XMLDocument ecol = null; logger.finest("......importXmlEntityData - verifing content...."); - JAXBContext context = JAXBContext.newInstance(XMLItemCollection.class); + JAXBContext context = JAXBContext.newInstance(XMLDocument.class); Unmarshaller m = context.createUnmarshaller(); ByteArrayInputStream input = new ByteArrayInputStream(byteInput); @@ -438,17 +258,16 @@ public static ItemCollection readItemCollection(byte[] byteInput) throws JAXBExc throw new RuntimeException("readItemCollection error - wrong xml file format - unable to read content!"); } - ecol = (XMLItemCollection) jaxbObject; + ecol = (XMLDocument) jaxbObject; // convert entity.... - ItemCollection itemCol = XMLItemCollectionAdapter.getItemCollection(ecol); + ItemCollection itemCol = XMLDocumentAdapter.putDocument(ecol); return itemCol; } - /** * This method writes a ItemCollection into a Byte array * @@ -464,14 +283,16 @@ public static byte[] writeItemCollection(ItemCollection document) throws JAXBExc return null; } - XMLItemCollection ecol = putItemCollection(document); + XMLDocument ecol = XMLDocumentAdapter.getDocument(document); StringWriter writer = new StringWriter(); - JAXBContext context = JAXBContext.newInstance(XMLItemCollection.class); + JAXBContext context = JAXBContext.newInstance(XMLDocument.class); Marshaller m = context.createMarshaller(); m.marshal(ecol, writer); return writer.toString().getBytes(); } + + private static byte[] getBytesFromStream(InputStream is) throws IOException { diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java index e98e78943..660289ca3 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/TestItemCollection.java @@ -7,8 +7,8 @@ import java.util.Map; import java.util.Vector; -import org.imixs.workflow.xml.XMLItemCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; +import org.imixs.workflow.xml.XMLDocument; +import org.imixs.workflow.xml.XMLDocumentAdapter; import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -278,7 +278,7 @@ public void testCopyValuesWithEmbeddedCollection() { child1.replaceItemValue("numID", new Integer(2)); try { - itemCollection1.replaceItemValue("child", XMLItemCollectionAdapter.putItemCollection(child1)); + itemCollection1.replaceItemValue("child", XMLDocumentAdapter.getDocument(child1)); } catch (Exception e) { Assert.fail(); @@ -290,9 +290,9 @@ public void testCopyValuesWithEmbeddedCollection() { Assert.assertNotSame(itemCollection1, itemCollection2); - XMLItemCollection xmlChild = (XMLItemCollection) itemCollection1.getItemValue("child").get(0); + XMLDocument xmlChild = (XMLDocument) itemCollection1.getItemValue("child").get(0); - ItemCollection testChild = XMLItemCollectionAdapter.getItemCollection(xmlChild); + ItemCollection testChild = XMLDocumentAdapter.putDocument(xmlChild); Assert.assertEquals(2, testChild.getItemValueInteger("numID")); // manipulate child1 and repeat the test! @@ -304,9 +304,9 @@ public void testCopyValuesWithEmbeddedCollection() { Assert.assertNotSame(child1, testChild); // test child1 form itemcol1 - xmlChild = (XMLItemCollection) itemCollection1.getItemValue("child").get(0); + xmlChild = (XMLDocument) itemCollection1.getItemValue("child").get(0); - testChild = XMLItemCollectionAdapter.getItemCollection(xmlChild); + testChild = XMLDocumentAdapter.putDocument(xmlChild); // expected id is not 3! Assert.assertEquals(2, testChild.getItemValueInteger("numID")); @@ -344,8 +344,8 @@ public void testCopyValuesWithEmbeddedCollectionList() { child2.replaceItemValue("numID", new Integer(3)); List childs = new ArrayList<>(); try { - childs.add(XMLItemCollectionAdapter.putItemCollection(child1)); - childs.add(XMLItemCollectionAdapter.putItemCollection(child2)); + childs.add(XMLDocumentAdapter.getDocument(child1)); + childs.add(XMLDocumentAdapter.getDocument(child2)); } catch (Exception e) { e.printStackTrace(); Assert.fail(); @@ -366,15 +366,15 @@ public void testCopyValuesWithEmbeddedCollectionList() { // get child 1 from itemcol2 List v = itemCollection2.getItemValue("childs"); - XMLItemCollection xmlct1 = (XMLItemCollection) v.get(0); - ItemCollection ct1 = XMLItemCollectionAdapter.getItemCollection(xmlct1); + XMLDocument xmlct1 = (XMLDocument) v.get(0); + ItemCollection ct1 = XMLDocumentAdapter.putDocument(xmlct1); Assert.assertEquals("Thor", ct1.getItemValueString("txtName")); Assert.assertEquals(2, ct1.getItemValueInteger("numID")); Assert.assertEquals(101, child1.getItemValueInteger("numID")); - XMLItemCollection xmlct2 = (XMLItemCollection) v.get(1); - ItemCollection ct2 = XMLItemCollectionAdapter.getItemCollection(xmlct2); + XMLDocument xmlct2 = (XMLDocument) v.get(1); + ItemCollection ct2 = XMLDocumentAdapter.putDocument(xmlct2); Assert.assertEquals("Ilias", ct2.getItemValueString("txtName")); Assert.assertEquals(3, ct2.getItemValueInteger("numID")); diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/MigrateImixsModelToBPMN.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/MigrateImixsModelToBPMN.java index 7c1d96594..fd0ea28ad 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/MigrateImixsModelToBPMN.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/bpmn/MigrateImixsModelToBPMN.java @@ -12,7 +12,7 @@ import javax.xml.bind.JAXBException; import org.imixs.workflow.ItemCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; +import org.imixs.workflow.xml.XMLDataCollectionAdapter; /** * This utility class can be used to convert a old .ixm model into a new imixs @@ -53,7 +53,7 @@ private static void readModel() { try { - modelItemCollection = XMLItemCollectionAdapter + modelItemCollection = XMLDataCollectionAdapter .readCollectionFromInputStream(MigrateImixsModelToBPMN.class .getClass().getResourceAsStream(sourceModelFile)); logger.info("Model contains " + modelItemCollection.size() diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestReadWriteByteArray.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestReadWriteByteArray.java index 32fffe742..e98b51cdc 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestReadWriteByteArray.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestReadWriteByteArray.java @@ -82,7 +82,7 @@ public void testWriteRead() { // write into byte[] byte[] data = null; try { - data = XMLItemCollectionAdapter.writeItemCollection(itemColSource); + data = XMLDocumentAdapter.writeItemCollection(itemColSource); // test if we found some data Assert.assertTrue(data.length > 100); } catch (JAXBException | IOException e) { @@ -93,7 +93,7 @@ public void testWriteRead() { // PHASE III. // read from byte[] try { - ItemCollection resultItemCollection = XMLItemCollectionAdapter.readItemCollection(data); + ItemCollection resultItemCollection = XMLDocumentAdapter.readItemCollection(data); Assert.assertNotNull(resultItemCollection); Assert.assertNotSame(itemColSource, resultItemCollection); // verify content diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestReadWriteXMLData.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestReadWriteXMLData.java index a69e95bfd..8aa76b7f5 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestReadWriteXMLData.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestReadWriteXMLData.java @@ -9,8 +9,8 @@ import javax.xml.bind.Marshaller; import org.imixs.workflow.ItemCollection; -import org.imixs.workflow.xml.DocumentCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; +import org.imixs.workflow.xml.XMLDataCollection; +import org.imixs.workflow.xml.XMLDataCollectionAdapter; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -46,7 +46,7 @@ public void testRead() { List col = null; try { - col = XMLItemCollectionAdapter + col = XMLDataCollectionAdapter .readCollectionFromInputStream(getClass().getResourceAsStream("/document-example.xml")); } catch (JAXBException e) { Assert.fail(); @@ -66,7 +66,7 @@ public void testWrite() { List col = null; // read default content try { - col = XMLItemCollectionAdapter + col = XMLDataCollectionAdapter .readCollectionFromInputStream(getClass().getResourceAsStream("/document-example.xml")); } catch (JAXBException e) { Assert.fail(); @@ -75,9 +75,9 @@ public void testWrite() { } // create JAXB object - DocumentCollection xmlCol = null; + XMLDataCollection xmlCol = null; try { - xmlCol = XMLItemCollectionAdapter.putDocuments(col); + xmlCol = XMLDataCollectionAdapter.getDataCollection(col); } catch (Exception e1) { e1.printStackTrace(); @@ -89,7 +89,7 @@ public void testWrite() { try { file = new File("src/test/resources/export-test.xml"); - JAXBContext jaxbContext = JAXBContext.newInstance(DocumentCollection.class); + JAXBContext jaxbContext = JAXBContext.newInstance(XMLDataCollection.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); // output pretty printed diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestWriteXMLData.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestWriteXMLData.java index f6f563a40..e32474799 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestWriteXMLData.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestWriteXMLData.java @@ -12,8 +12,6 @@ import javax.xml.bind.Marshaller; import org.imixs.workflow.ItemCollection; -import org.imixs.workflow.xml.XMLItemCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -104,9 +102,9 @@ public void testWrite() { // write the write-example.xml.... // create JAXB object - XMLItemCollection xmlCol = null; + XMLDocument xmlCol = null; try { - xmlCol = XMLItemCollectionAdapter.putItemCollection(itemColSource); + xmlCol = XMLDocumentAdapter.getDocument(itemColSource); } catch (Exception e1) { e1.printStackTrace(); @@ -118,7 +116,7 @@ public void testWrite() { try { file = new File("src/test/resources/write-example.xml"); - JAXBContext jaxbContext = JAXBContext.newInstance(XMLItemCollection.class); + JAXBContext jaxbContext = JAXBContext.newInstance(XMLDocument.class); Marshaller jaxbMarshaller = jaxbContext.createMarshaller(); // output pretty printed @@ -141,7 +139,7 @@ public void testWrite() { FileInputStream fis = null; fis = new FileInputStream(file); - ItemCollection resultItemCollection = XMLItemCollectionAdapter.readItemCollectionFromInputStream(fis); + ItemCollection resultItemCollection = XMLDocumentAdapter.readItemCollectionFromInputStream(fis); Assert.assertNotNull(resultItemCollection); diff --git a/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestXMLItemCollectionAdapter.java b/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestXMLItemCollectionAdapter.java index e328449fe..97277c1d7 100644 --- a/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestXMLItemCollectionAdapter.java +++ b/imixs-workflow-core/src/test/java/org/imixs/workflow/xml/TestXMLItemCollectionAdapter.java @@ -28,15 +28,15 @@ public class TestXMLItemCollectionAdapter { public void testItemCollection() { ItemCollection itemCollection = new ItemCollection(); itemCollection.replaceItemValue("txtTitel", "Hello"); - XMLItemCollection xmlItemCollection = null; + XMLDocument xmlItemCollection = null; try { - xmlItemCollection = XMLItemCollectionAdapter.putItemCollection(itemCollection); + xmlItemCollection = XMLDocumentAdapter.getDocument(itemCollection); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } - ItemCollection col2 = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + ItemCollection col2 = XMLDocumentAdapter.putDocument(xmlItemCollection); Assert.assertEquals(itemCollection.getItemValueString("txttitel"), "Hello"); @@ -53,15 +53,15 @@ public void testDateValue() { Date datTest = new Date(); itemCollection.replaceItemValue("datDate", datTest); - XMLItemCollection xmlItemCollection = null; + XMLDocument xmlItemCollection = null; try { - xmlItemCollection = XMLItemCollectionAdapter.putItemCollection(itemCollection); + xmlItemCollection = XMLDocumentAdapter.getDocument(itemCollection); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } - ItemCollection col2 = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + ItemCollection col2 = XMLDocumentAdapter.putDocument(xmlItemCollection); // test if date is equals Assert.assertEquals(col2.getItemValueDate("datDate"), itemCollection.getItemValueDate("datDate")); @@ -86,14 +86,14 @@ public void testXMLGregrianCalendar() { Date datTest = new Date(); - XMLItemCollection xmlItemCollection = new XMLItemCollection(); + XMLDocument xmlItemCollection = new XMLDocument(); XMLItem xmlItem = new XMLItem(); xmlItem.setName("datdate"); xmlItem.setValue(new Object[] { datTest }); XMLItem[] xmlItemList = new XMLItem[] { xmlItem }; xmlItemCollection.setItem(xmlItemList); - ItemCollection itemCollection = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + ItemCollection itemCollection = XMLDocumentAdapter.putDocument(xmlItemCollection); Assert.assertEquals(itemCollection.getItemValueDate("datdate"), datTest); /* @@ -111,14 +111,14 @@ public void testXMLGregrianCalendar() { e.printStackTrace(); Assert.fail(); } - xmlItemCollection = new XMLItemCollection(); + xmlItemCollection = new XMLDocument(); xmlItem = new XMLItem(); xmlItem.setName("datdate"); xmlItem.setValue(new Object[] { xmlDate }); xmlItemList = new XMLItem[] { xmlItem }; xmlItemCollection.setItem(xmlItemList); - itemCollection = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + itemCollection = XMLDocumentAdapter.putDocument(xmlItemCollection); // now we expect that the XMLItemCollectionAdapter has converted // the XMLGregorianCalendar impl into a java.util.Date object @@ -144,15 +144,15 @@ public void testItemCollectionContainingMap() { map.put("_name", "some data"); itemCollection.replaceItemValue("_mapdata", map); - XMLItemCollection xmlItemCollection = null; + XMLDocument xmlItemCollection = null; try { - xmlItemCollection = XMLItemCollectionAdapter.putItemCollection(itemCollection); + xmlItemCollection = XMLDocumentAdapter.getDocument(itemCollection); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } - ItemCollection col2 = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + ItemCollection col2 = XMLDocumentAdapter.putDocument(xmlItemCollection); Assert.assertEquals(itemCollection.getItemValueString("txttitel"), "Hello"); @@ -190,16 +190,16 @@ public void testItemCollectionContainingListOfList() { itemColSource.replaceItemValue("_listdata", valueList); - XMLItemCollection xmlItemCollection = null; + XMLDocument xmlItemCollection = null; try { - xmlItemCollection = XMLItemCollectionAdapter.putItemCollection(itemColSource); + xmlItemCollection = XMLDocumentAdapter.getDocument(itemColSource); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } // now reconstruct the xmlItemCollection into a ItemCollection... - ItemCollection itemColTest = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + ItemCollection itemColTest = XMLDocumentAdapter.putDocument(xmlItemCollection); Assert.assertEquals(itemColTest.getItemValueString("txttitel"), "Hello"); @@ -241,16 +241,16 @@ public void testItemCollectionContainingListOfMap() { mapList.add(map1); itemColSource.replaceItemValue("_mapdata", mapList); - XMLItemCollection xmlItemCollection = null; + XMLDocument xmlItemCollection = null; try { - xmlItemCollection = XMLItemCollectionAdapter.putItemCollection(itemColSource); + xmlItemCollection = XMLDocumentAdapter.getDocument(itemColSource); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } // now reconstruct the xmlItemCollection into a ItemCollection... - ItemCollection itemColTest = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + ItemCollection itemColTest = XMLDocumentAdapter.putDocument(xmlItemCollection); Assert.assertEquals(itemColTest.getItemValueString("txttitel"), "Hello"); @@ -279,16 +279,16 @@ public void testItemCollectionContainingFiles() { // parentWorkitem. itemColSource.addFile(empty, "test.txt", "png"); - XMLItemCollection xmlItemCollection = null; + XMLDocument xmlItemCollection = null; try { - xmlItemCollection = XMLItemCollectionAdapter.putItemCollection(itemColSource); + xmlItemCollection = XMLDocumentAdapter.getDocument(itemColSource); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } // now reconstruct the xmlItemCollection into a ItemCollection... - ItemCollection itemColTest = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + ItemCollection itemColTest = XMLDocumentAdapter.putDocument(xmlItemCollection); Assert.assertEquals(itemColTest.getItemValueString("txttitel"), "Hello"); @@ -325,16 +325,16 @@ public void testItemCollectionContainingListOfMapConstructedOfItemCollections() mapList.add(i2.getAllItems()); itemColSource.replaceItemValue("_mapdata", mapList); - XMLItemCollection xmlItemCollection = null; + XMLDocument xmlItemCollection = null; try { - xmlItemCollection = XMLItemCollectionAdapter.putItemCollection(itemColSource); + xmlItemCollection = XMLDocumentAdapter.getDocument(itemColSource); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } // now reconstruct the xmlItemCollection into a ItemCollection... - ItemCollection itemColTest = XMLItemCollectionAdapter.getItemCollection(xmlItemCollection); + ItemCollection itemColTest = XMLDocumentAdapter.putDocument(xmlItemCollection); Assert.assertEquals(itemColTest.getItemValueString("txttitel"), "Hello"); diff --git a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/MailPlugin.java b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/MailPlugin.java index b3aa3acc0..cfd4f3a6e 100644 --- a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/MailPlugin.java +++ b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/MailPlugin.java @@ -57,9 +57,8 @@ import org.imixs.workflow.ItemCollection; import org.imixs.workflow.exceptions.PluginException; -import org.imixs.workflow.xml.DocumentCollection; -import org.imixs.workflow.xml.XMLItemCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; +import org.imixs.workflow.xml.XMLDocument; +import org.imixs.workflow.xml.XMLDocumentAdapter; import org.imixs.workflow.xml.XSLHandler; /** @@ -447,12 +446,12 @@ public String transformXSLBody(ItemCollection documentContext, String xslTemplat logger.finest("......transfor mail body based on XSL template...."); // Transform XML per XSL and generate output - XMLItemCollection xml; + XMLDocument xml; try { - xml = XMLItemCollectionAdapter.putItemCollection(documentContext); + xml = XMLDocumentAdapter.getDocument(documentContext); StringWriter writer = new StringWriter(); - JAXBContext context = JAXBContext.newInstance(DocumentCollection.class); + JAXBContext context = JAXBContext.newInstance(XMLDocument.class); Marshaller m = context.createMarshaller(); m.setProperty("jaxb.encoding", encoding); m.marshal(xml, writer); diff --git a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/ReportPlugin.java b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/ReportPlugin.java index 7ba22c663..e39495f03 100644 --- a/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/ReportPlugin.java +++ b/imixs-workflow-engine/src/main/java/org/imixs/workflow/engine/plugins/ReportPlugin.java @@ -37,9 +37,9 @@ import org.imixs.workflow.ItemCollection; import org.imixs.workflow.exceptions.PluginException; -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.XSLHandler; /** @@ -125,10 +125,10 @@ public ItemCollection run(ItemCollection adocumentContext, ItemCollection adocum // TODO : we need to clarify if the method call unescapeXMLContent() is // necessary - XMLItemCollection xml = XMLItemCollectionAdapter.putItemCollection(adocumentContext); + XMLDocument xml = XMLDocumentAdapter.getDocument(adocumentContext); StringWriter writer = new StringWriter(); - JAXBContext context = JAXBContext.newInstance(DocumentCollection.class); + JAXBContext context = JAXBContext.newInstance(XMLDataCollection.class); Marshaller m = context.createMarshaller(); m.setProperty("jaxb.encoding", encoding); m.marshal(xml, writer); diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/AdminPRestService.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/AdminPRestService.java index c9783fa17..a0eeba7c4 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/AdminPRestService.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/AdminPRestService.java @@ -53,9 +53,10 @@ import org.imixs.workflow.exceptions.AccessDeniedException; import org.imixs.workflow.exceptions.InvalidAccessException; import org.imixs.workflow.exceptions.WorkflowException; -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; /** * The AdminPRestService provides methods to access the AdminPService EJB @@ -129,15 +130,15 @@ public void write(OutputStream out) throws IOException, WebApplicationException */ @GET @Path("/jobs") - public DocumentCollection getAllJobs() { + public XMLDataCollection getAllJobs() { Collection col = null; try { col = documentService.getDocumentsByType("adminp"); - return XMLItemCollectionAdapter.putDocuments(col); + return XMLDataCollectionAdapter.getDataCollection(col); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } /** @@ -158,12 +159,12 @@ public DocumentCollection getAllJobs() { @Path("/jobs/") @Produces(MediaType.APPLICATION_XML) @Consumes({ MediaType.APPLICATION_XML, "text/xml" }) - public Response putJob(XMLItemCollection xmlworkitem) { + public Response putJob(XMLDocument xmlworkitem) { if (servletRequest.isUserInRole("org.imixs.ACCESSLEVEL.MANAGERACCESS") == false) { return Response.status(Response.Status.UNAUTHORIZED).build(); } ItemCollection workitem; - workitem = XMLItemCollectionAdapter.getItemCollection(xmlworkitem); + workitem = XMLDocumentAdapter.putDocument(xmlworkitem); if (workitem == null) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); @@ -182,10 +183,10 @@ public Response putJob(XMLItemCollection xmlworkitem) { // return workitem try { if (workitem.hasItem("$error_code")) - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem), MediaType.APPLICATION_XML) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem), MediaType.APPLICATION_XML) .status(Response.Status.NOT_ACCEPTABLE).build(); else - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem), MediaType.APPLICATION_XML) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem), MediaType.APPLICATION_XML) .build(); } catch (Exception e) { e.printStackTrace(); diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentCollectionWriter.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentCollectionWriter.java index 41a5626dc..0fcbbaaf8 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentCollectionWriter.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentCollectionWriter.java @@ -41,8 +41,8 @@ import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; -import org.imixs.workflow.xml.DocumentCollection; -import org.imixs.workflow.xml.XMLItemCollection; +import org.imixs.workflow.xml.XMLDataCollection; +import org.imixs.workflow.xml.XMLDocument; /** * This MessageBodyWriter generates an HTML representation from a DocumetCollection @@ -52,14 +52,14 @@ */ @Provider @Produces("text/html") -public class DocumentCollectionWriter implements MessageBodyWriter { +public class DocumentCollectionWriter implements MessageBodyWriter { public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { - return DocumentCollection.class.isAssignableFrom(type); + return XMLDataCollection.class.isAssignableFrom(type); } - public void writeTo(DocumentCollection entityCollection, Class type, Type genericType, + public void writeTo(XMLDataCollection entityCollection, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream) throws IOException, @@ -76,7 +76,7 @@ public void writeTo(DocumentCollection entityCollection, Class type, Type gen bw.write("

EntityCollection

"); bw.write("

" + entityCollection.getDocument().length + " Entries

"); - for (XMLItemCollection xmlworkItem : entityCollection.getDocument()) { + for (XMLDocument xmlworkItem : entityCollection.getDocument()) { XMLItemCollectionWriter.printXMLItemCollectionHTML(bw, xmlworkItem); } @@ -92,7 +92,7 @@ public void writeTo(DocumentCollection entityCollection, Class type, Type gen bw.flush(); } - public long getSize(DocumentCollection arg0, Class arg1, Type arg2, + public long getSize(XMLDataCollection arg0, Class arg1, Type arg2, Annotation[] arg3, MediaType arg4) { return -1; } diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentRestService.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentRestService.java index bed86b9ba..c39636841 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentRestService.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentRestService.java @@ -63,10 +63,11 @@ import org.imixs.workflow.exceptions.AccessDeniedException; import org.imixs.workflow.exceptions.InvalidAccessException; import org.imixs.workflow.exceptions.QueryException; -import org.imixs.workflow.xml.DocumentCollection; +import org.imixs.workflow.xml.XMLDataCollection; import org.imixs.workflow.xml.XMLCount; -import org.imixs.workflow.xml.XMLItemCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; +import org.imixs.workflow.xml.XMLDocument; +import org.imixs.workflow.xml.XMLDocumentAdapter; +import org.imixs.workflow.xml.XMLDataCollectionAdapter; /** * The DocumentService provides methods to access the DocumentService EJB @@ -154,12 +155,12 @@ public void write(OutputStream out) throws IOException, WebApplicationException */ @GET @Path("/{uniqueid}") - public DocumentCollection getDocument(@PathParam("uniqueid") String uniqueid, @QueryParam("items") String items) { + public XMLDataCollection getDocument(@PathParam("uniqueid") String uniqueid, @QueryParam("items") String items) { ItemCollection document; try { document = documentService.load(uniqueid); - return XMLItemCollectionAdapter.putDocuments(document,DocumentRestService.getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(document,DocumentRestService.getItemList(items)); // return XMLItemCollectionAdapter.putItemCollection(document, DocumentRestService.getItemList(items)); } catch (Exception e) { e.printStackTrace(); @@ -178,7 +179,7 @@ public DocumentCollection getDocument(@PathParam("uniqueid") String uniqueid, @Q */ @GET @Path("/search/{query}") - public DocumentCollection findDocumentsByQuery(@PathParam("query") String query, + public XMLDataCollection findDocumentsByQuery(@PathParam("query") String query, @DefaultValue("-1") @QueryParam("pageSize") int pageSize, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @QueryParam("sortBy") String sortBy, @QueryParam("sortReverse") boolean sortReverse, @QueryParam("items") String items) { @@ -187,11 +188,11 @@ public DocumentCollection findDocumentsByQuery(@PathParam("query") String query, // decode query... String decodedQuery = URLDecoder.decode(query, "UTF-8"); col = documentService.find(decodedQuery, pageSize, pageIndex, sortBy, sortReverse); - return XMLItemCollectionAdapter.putDocuments(col, getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } /** @@ -205,7 +206,7 @@ public DocumentCollection findDocumentsByQuery(@PathParam("query") String query, */ @GET @Path("/jpql/{query}") - public DocumentCollection findDocumentsByJPQL(@PathParam("query") String query, + public XMLDataCollection findDocumentsByJPQL(@PathParam("query") String query, @DefaultValue("" + LuceneSearchService.DEFAULT_PAGE_SIZE) @QueryParam("pageSize") int pageSize, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @QueryParam("items") String items) { Collection col = null; @@ -216,11 +217,11 @@ public DocumentCollection findDocumentsByJPQL(@PathParam("query") String query, int firstResult = pageIndex * pageSize; col = documentService.getDocumentsByQuery(decodedQuery, firstResult, pageSize); - return XMLItemCollectionAdapter.putDocuments(col, getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } /** @@ -294,12 +295,12 @@ public XMLCount countTotalPagesByQuery(@PathParam("query") String query, // @Path("/") generates jersey warning @Produces(MediaType.APPLICATION_XML) @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response postEntity(XMLItemCollection xmlworkitem) { + public Response postEntity(XMLDocument xmlworkitem) { if (servletRequest.isUserInRole("org.imixs.ACCESSLEVEL.MANAGERACCESS") == false) { return Response.status(Response.Status.UNAUTHORIZED).build(); } ItemCollection workitem; - workitem = XMLItemCollectionAdapter.getItemCollection(xmlworkitem); + workitem = XMLDocumentAdapter.putDocument(xmlworkitem); if (workitem == null) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); @@ -333,10 +334,10 @@ public Response postEntity(XMLItemCollection xmlworkitem) { // return workitem try { if (workitem.hasItem("$error_code")) - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem), MediaType.APPLICATION_XML) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem), MediaType.APPLICATION_XML) .status(Response.Status.NOT_ACCEPTABLE).build(); else - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem), MediaType.APPLICATION_XML) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem), MediaType.APPLICATION_XML) .build(); } catch (Exception e) { e.printStackTrace(); @@ -355,7 +356,7 @@ public Response postEntity(XMLItemCollection xmlworkitem) { // @Path("/") generates jersey warning @Produces(MediaType.APPLICATION_XML) @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response putEntity(XMLItemCollection xmlworkitem) { + public Response putEntity(XMLDocument xmlworkitem) { logger.finest("putEntity @PUT / delegate to POST...."); return postEntity(xmlworkitem); } @@ -446,14 +447,14 @@ public Response restore(@QueryParam("filepath") String filepath) { @GET @Path("/configuration") @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) - public DocumentCollection getConfiguration() throws Exception { + public XMLDataCollection getConfiguration() throws Exception { if (servletRequest.isUserInRole("org.imixs.ACCESSLEVEL.MANAGERACCESS") == false) { return null; } ItemCollection config = lucenUpdateService.getConfiguration(); - return XMLItemCollectionAdapter.putDocuments(config); + return XMLDataCollectionAdapter.getDataCollection(config); } diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentTableWriter.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentTableWriter.java index b8a576084..592b2fb4c 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentTableWriter.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/DocumentTableWriter.java @@ -44,8 +44,8 @@ import org.imixs.workflow.ItemCollection; import org.imixs.workflow.xml.DocumentTable; -import org.imixs.workflow.xml.XMLItemCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; +import org.imixs.workflow.xml.XMLDocument; +import org.imixs.workflow.xml.XMLDocumentAdapter; /** * This MessageBodyWriter generates an HTML representation from a EntityTable. @@ -97,7 +97,7 @@ public void writeTo(DocumentTable documentTable, Class type, Type genericType // print table body try { - for (XMLItemCollection xmlworkItem : documentTable.getDocument()) { + for (XMLDocument xmlworkItem : documentTable.getDocument()) { /* Print row */ if (trClass) bw.write(""); @@ -105,7 +105,7 @@ public void writeTo(DocumentTable documentTable, Class type, Type genericType bw.write(""); trClass = !trClass; - ItemCollection itemCol = XMLItemCollectionAdapter.getItemCollection(xmlworkItem); + ItemCollection itemCol = XMLDocumentAdapter.putDocument(xmlworkItem); for (String itemName : documentTable.getItems()) { // test if item name contains format or converter definition List vValues = itemCol.getItemValue(itemName); diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java index 35c91c4d3..f1f5108b3 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ModelRestService.java @@ -63,9 +63,10 @@ import org.imixs.workflow.engine.DocumentService; import org.imixs.workflow.engine.ModelService; import org.imixs.workflow.exceptions.ModelException; -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; /** * The WorkflowService Handler supports methods to process different kind of @@ -224,17 +225,17 @@ public String getModelXML() { @GET @Path("/{version}/tasks/") - public DocumentCollection findAllTasks(@PathParam("version") String version, @QueryParam("items") String items) { + public XMLDataCollection findAllTasks(@PathParam("version") String version, @QueryParam("items") String items) { Collection col = null; try { col = modelService.getModel(version).findAllTasks(); - return XMLItemCollectionAdapter.putDocuments(col, getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } @GET @@ -251,31 +252,31 @@ public Response getModelFile(@PathParam("version") String version, @Context UriI @GET @Path("/{version}/tasks/{taskid}") - public XMLItemCollection getTask(@PathParam("version") String version, @PathParam("taskid") int processid, + public XMLDataCollection getTask(@PathParam("version") String version, @PathParam("taskid") int processid, @QueryParam("items") String items) { ItemCollection process = null; try { process = modelService.getModel(version).getTask(processid); - return XMLItemCollectionAdapter.putItemCollection(process, getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(process, getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new XMLItemCollection(); + return new XMLDataCollection(); } @GET @Path("/{version}/tasks/{taskid}/events") - public DocumentCollection findAllEventsByTask(@PathParam("version") String version, + public XMLDataCollection findAllEventsByTask(@PathParam("version") String version, @PathParam("taskid") int processid, @QueryParam("items") String items) { Collection col = null; try { col = modelService.getModel(version).findAllEventsByTask(processid); - return XMLItemCollectionAdapter.putDocuments(col, getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } /** @@ -307,17 +308,17 @@ public List getGroups(@PathParam("version") String version, @QueryParam( */ @GET @Path("/{version}/groups/{group}") - public DocumentCollection findTasksByGroup(@PathParam("version") String version, @PathParam("group") String group, + public XMLDataCollection findTasksByGroup(@PathParam("version") String version, @PathParam("group") String group, @QueryParam("items") String items) { Collection col = null; try { col = modelService.getModel(version).findTasksByGroup(group); - return XMLItemCollectionAdapter.putDocuments(col, getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } @DELETE @@ -375,9 +376,9 @@ public Response postBPMNModel(BPMNModel bpmnmodel) { @PUT @Path("/{version}") @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public void putModelByVersion(@PathParam("version") String sModelVersion, DocumentCollection ecol) { + public void putModelByVersion(@PathParam("version") String sModelVersion, XMLDataCollection ecol) { - XMLItemCollection entity; + XMLDocument entity; ItemCollection itemCollection; try { if (ecol.getDocument().length > 0) { @@ -394,7 +395,7 @@ public void putModelByVersion(@PathParam("version") String sModelVersion, Docume // save new entities into database and update modelversion..... for (int i = 0; i < ecol.getDocument().length; i++) { entity = ecol.getDocument()[i]; - itemCollection = XMLItemCollectionAdapter.getItemCollection(entity); + itemCollection = XMLDocumentAdapter.putDocument(entity); // update model version itemCollection.replaceItemValue("$modelVersion", sModelVersion); // save entity @@ -411,7 +412,7 @@ public void putModelByVersion(@PathParam("version") String sModelVersion, Docume @POST @Path("/{version}") @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public void postModelByVersion(@PathParam("version") String sModelVersion, DocumentCollection ecol) { + public void postModelByVersion(@PathParam("version") String sModelVersion, XMLDataCollection ecol) { putModelByVersion(sModelVersion, ecol); } @@ -425,9 +426,9 @@ public void postModelByVersion(@PathParam("version") String sModelVersion, Docum */ @PUT @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public void putModel(DocumentCollection ecol) { + public void putModel(XMLDataCollection ecol) { String sModelVersion = null; - XMLItemCollection entity; + XMLDocument entity; ItemCollection itemCollection; try { if (ecol.getDocument().length > 0) { @@ -435,7 +436,7 @@ public void putModel(DocumentCollection ecol) { * first we need get model version from first entity */ entity = ecol.getDocument()[0]; - itemCollection = XMLItemCollectionAdapter.getItemCollection(entity); + itemCollection = XMLDocumentAdapter.putDocument(entity); sModelVersion = itemCollection.getItemValueString("$ModelVersion"); putModelByVersion(sModelVersion, ecol); @@ -450,7 +451,7 @@ public void putModel(DocumentCollection ecol) { @POST @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public void postModel(DocumentCollection ecol) { + public void postModel(XMLDataCollection ecol) { putModel(ecol); } diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ReportRestService.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ReportRestService.java index c6a227119..4131798fb 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ReportRestService.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/ReportRestService.java @@ -79,10 +79,11 @@ import org.imixs.workflow.ItemCollection; import org.imixs.workflow.engine.DocumentService; import org.imixs.workflow.engine.ReportService; -import org.imixs.workflow.xml.DocumentCollection; +import org.imixs.workflow.xml.XMLDataCollection; import org.imixs.workflow.xml.DocumentTable; -import org.imixs.workflow.xml.XMLItemCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; +import org.imixs.workflow.xml.XMLDocument; +import org.imixs.workflow.xml.XMLDocumentAdapter; +import org.imixs.workflow.xml.XMLDataCollectionAdapter; import org.imixs.workflow.xml.XSLHandler; /** @@ -148,16 +149,16 @@ public void write(OutputStream out) throws IOException, WebApplicationException @GET @Path("/definitions") - public DocumentCollection getReportsDefinitions() { + public XMLDataCollection getReportsDefinitions() { try { Collection col = null; col = reportService.getReportList(); - return XMLItemCollectionAdapter.putDocuments(col); + return XMLDataCollectionAdapter.getDataCollection(col); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } /** @@ -169,10 +170,10 @@ public DocumentCollection getReportsDefinitions() { */ @GET @Path("/definitions/{name}") - public XMLItemCollection getReportDefinition(@PathParam("name") String name) { + public XMLDataCollection getReportDefinition(@PathParam("name") String name) { try { ItemCollection itemCol = reportService.getReport(name); - return XMLItemCollectionAdapter.putItemCollection(itemCol); + return XMLDataCollectionAdapter.getDataCollection(itemCol); } catch (Exception e) { e.printStackTrace(); } @@ -234,17 +235,17 @@ public Response getExcecuteReport(@PathParam("name") String reportName, // if no XSL is provided return standard html format...? if ("".equals(sXSL)) { - Response.ResponseBuilder builder = Response.ok(XMLItemCollectionAdapter.putDocuments(col), + Response.ResponseBuilder builder = Response.ok(XMLDataCollectionAdapter.getDataCollection(col), "text/html"); return builder.build(); } // Transform XML per XSL and generate output - DocumentCollection xmlCol = XMLItemCollectionAdapter.putDocuments(col); + XMLDataCollection xmlCol = XMLDataCollectionAdapter.getDataCollection(col); StringWriter writer = new StringWriter(); - JAXBContext context = JAXBContext.newInstance(DocumentCollection.class); + JAXBContext context = JAXBContext.newInstance(XMLDataCollection.class); Marshaller m = context.createMarshaller(); m.setProperty("jaxb.encoding", encoding); @@ -344,7 +345,7 @@ public DocumentTable getHTMLResult(@PathParam("name") String reportName, Map params = getQueryParams(uriInfo); col = reportService.executeReport(reportName, pageSize, pageIndex, sortBy, sortReverse, params); - DocumentCollection documentCollection = XMLItemCollectionAdapter.putDocuments(col); + XMLDataCollection documentCollection = XMLDataCollectionAdapter.getDataCollection(col); DocumentTable documentTable = new DocumentTable(documentCollection.getDocument(), items, labels); // documentTable.setDocument(documentCollection.getDocument()); @@ -381,7 +382,7 @@ public DocumentTable getHTMLResult(@PathParam("name") String reportName, @GET @Produces({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) @Path("/{name}.xml") - public DocumentCollection getXMLResult(@PathParam("name") String reportName, + public XMLDataCollection getXMLResult(@PathParam("name") String reportName, @DefaultValue("100") @QueryParam("pageSize") int pageSize, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @QueryParam("sortBy") String sortBy, @QueryParam("sortReverse") boolean sortReverse, @DefaultValue("") @QueryParam("encoding") String encoding, @@ -401,7 +402,7 @@ public DocumentCollection getXMLResult(@PathParam("name") String reportName, logger.fine("set encoding :" + encoding); servlerResponse.setContentType(MediaType.APPLICATION_XML + "; charset=" + encoding); - return XMLItemCollectionAdapter.putDocuments(col); + return XMLDataCollectionAdapter.getDataCollection(col); } catch (Exception e) { e.printStackTrace(); @@ -426,7 +427,7 @@ public DocumentCollection getXMLResult(@PathParam("name") String reportName, @GET @Produces(MediaType.APPLICATION_JSON) @Path("/{name}.json") - public DocumentCollection getJSONResult(@PathParam("name") String name, + public XMLDataCollection getJSONResult(@PathParam("name") String name, @DefaultValue("-1") @QueryParam("pageSize") int pageSize, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @QueryParam("sortBy") String sortBy, @@ -435,7 +436,7 @@ public DocumentCollection getJSONResult(@PathParam("name") String name, @DefaultValue("") @QueryParam("encoding") String encoding, @Context UriInfo uriInfo, @Context HttpServletResponse servlerResponse) throws Exception { - DocumentCollection result = getXMLResult(name, pageSize, pageIndex, sortBy, sortReverse, encoding, uriInfo, + XMLDataCollection result = getXMLResult(name, pageSize, pageIndex, sortBy, sortReverse, encoding, uriInfo, servlerResponse); // set content type and character encoding @@ -478,10 +479,10 @@ public void deleteReport(@PathParam("name") String name) { @PUT @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN, MediaType.TEXT_XML }) - public void putReport(XMLItemCollection reportCol) { + public void putReport(XMLDocument reportCol) { ItemCollection itemCollection; try { - itemCollection = XMLItemCollectionAdapter.getItemCollection(reportCol); + itemCollection = XMLDocumentAdapter.putDocument(reportCol); reportService.updateReport(itemCollection); } catch (Exception e) { e.printStackTrace(); @@ -491,7 +492,7 @@ public void putReport(XMLItemCollection reportCol) { @POST @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_OCTET_STREAM, MediaType.TEXT_PLAIN, MediaType.TEXT_XML }) - public void postReport(XMLItemCollection reportCol) { + public void postReport(XMLDocument reportCol) { putReport(reportCol); } diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/WorkflowRestService.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/WorkflowRestService.java index 7f70bfee5..5a25c70db 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/WorkflowRestService.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/WorkflowRestService.java @@ -71,9 +71,10 @@ import org.imixs.workflow.exceptions.PluginException; import org.imixs.workflow.exceptions.WorkflowException; import org.imixs.workflow.util.JSONParser; -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; /** * The WorkflowService Handler supports methods to process different kind of @@ -151,7 +152,7 @@ public Response getWorkItem(@PathParam("uniqueid") String uniqueid, @QueryParam( return Response.status(Response.Status.NOT_FOUND).build(); } return Response - .ok(XMLItemCollectionAdapter.putItemCollection(workitem, DocumentRestService.getItemList(items))) + .ok(XMLDataCollectionAdapter.getDataCollection(workitem, DocumentRestService.getItemList(items))) .build(); } catch (Exception e) { e.printStackTrace(); @@ -255,16 +256,16 @@ public Response getWorkItemFile(@PathParam("uniqueid") String uniqueid, @PathPar */ @GET @Path("/workitem/events/{uniqueid}") - public DocumentCollection getEvents(@PathParam("uniqueid") String uniqueid) { + public XMLDataCollection getEvents(@PathParam("uniqueid") String uniqueid) { Collection eventList = null; try { eventList = workflowService.getEvents(this.workflowService.getDocumentService().load(uniqueid)); - return XMLItemCollectionAdapter.putDocuments(eventList); + return XMLDataCollectionAdapter.getDataCollection(eventList); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } /** @@ -278,7 +279,7 @@ public DocumentCollection getEvents(@PathParam("uniqueid") String uniqueid) { */ @GET @Path("/worklist") - public DocumentCollection getWorkList(@QueryParam("type") String type, + public XMLDataCollection getWorkList(@QueryParam("type") String type, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @DefaultValue("10") @QueryParam("pageSize") int pageSize, @DefaultValue("") @QueryParam("sortBy") String sortBy, @@ -289,7 +290,7 @@ public DocumentCollection getWorkList(@QueryParam("type") String type, @GET @Path("/tasklist/owner/{owner}") - public DocumentCollection getTaskListByOwner(@PathParam("owner") String owner, @QueryParam("type") String type, + public XMLDataCollection getTaskListByOwner(@PathParam("owner") String owner, @QueryParam("type") String type, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @DefaultValue("10") @QueryParam("pageSize") int pageSize, @DefaultValue("") @QueryParam("sortBy") String sortBy, @@ -304,11 +305,11 @@ public DocumentCollection getTaskListByOwner(@PathParam("owner") String owner, @ owner = URLDecoder.decode(owner, "UTF-8"); col = workflowService.getWorkListByOwner(owner, type, pageSize, pageIndex, sortBy, sortReverse); - return XMLItemCollectionAdapter.putDocuments(col, DocumentRestService.getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, DocumentRestService.getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } /** @@ -322,7 +323,7 @@ public DocumentCollection getTaskListByOwner(@PathParam("owner") String owner, @ */ @GET @Path("/tasklist/author/{user}") - public DocumentCollection getTaskListByAuthor(@PathParam("user") String user, @QueryParam("type") String type, + public XMLDataCollection getTaskListByAuthor(@PathParam("user") String user, @QueryParam("type") String type, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @DefaultValue("10") @QueryParam("pageSize") int pageSize, @DefaultValue("") @QueryParam("sortBy") String sortBy, @@ -337,17 +338,17 @@ public DocumentCollection getTaskListByAuthor(@PathParam("user") String user, @Q user = URLDecoder.decode(user, "UTF-8"); col = workflowService.getWorkListByAuthor(user, type, pageSize, pageIndex, sortBy, sortReverse); - return XMLItemCollectionAdapter.putDocuments(col, DocumentRestService.getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, DocumentRestService.getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } @GET @Path("/tasklist/creator/{creator}") - public DocumentCollection getTaskListByCreator(@PathParam("creator") String creator, + public XMLDataCollection getTaskListByCreator(@PathParam("creator") String creator, @QueryParam("type") String type, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @DefaultValue("10") @QueryParam("pageSize") int pageSize, @DefaultValue("") @QueryParam("sortBy") String sortBy, @@ -362,17 +363,17 @@ public DocumentCollection getTaskListByCreator(@PathParam("creator") String crea creator = URLDecoder.decode(creator, "UTF-8"); col = workflowService.getWorkListByCreator(creator, type, pageSize, pageIndex, sortBy, sortReverse); - return XMLItemCollectionAdapter.putDocuments(col, DocumentRestService.getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, DocumentRestService.getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } @GET @Path("/tasklist/processid/{processid}") - public DocumentCollection getTaskListByProcessID(@PathParam("processid") int processid, + public XMLDataCollection getTaskListByProcessID(@PathParam("processid") int processid, @QueryParam("type") String type, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @DefaultValue("10") @QueryParam("pageSize") int pageSize, @DefaultValue("") @QueryParam("sortBy") String sortBy, @@ -380,16 +381,16 @@ public DocumentCollection getTaskListByProcessID(@PathParam("processid") int pro Collection col = null; try { col = workflowService.getWorkListByProcessID(processid, type, pageSize, pageIndex, sortBy, sortReverse); - return XMLItemCollectionAdapter.putDocuments(col, DocumentRestService.getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, DocumentRestService.getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } @GET @Path("/tasklist/group/{processgroup}") - public DocumentCollection getTaskListByGroup(@PathParam("processgroup") String processgroup, + public XMLDataCollection getTaskListByGroup(@PathParam("processgroup") String processgroup, @QueryParam("type") String type, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @DefaultValue("10") @QueryParam("pageSize") int pageSize, @DefaultValue("") @QueryParam("sortBy") String sortBy, @@ -402,16 +403,16 @@ public DocumentCollection getTaskListByGroup(@PathParam("processgroup") String p processgroup = URLDecoder.decode(processgroup, "UTF-8"); col = workflowService.getWorkListByGroup(processgroup, type, pageSize, pageIndex, sortBy, sortReverse); - return XMLItemCollectionAdapter.putDocuments(col, DocumentRestService.getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, DocumentRestService.getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } @GET @Path("/tasklist/ref/{uniqueid}") - public DocumentCollection getTaskListByRef(@PathParam("uniqueid") String uniqueid, @QueryParam("type") String type, + public XMLDataCollection getTaskListByRef(@PathParam("uniqueid") String uniqueid, @QueryParam("type") String type, @DefaultValue("0") @QueryParam("pageIndex") int pageIndex, @DefaultValue("10") @QueryParam("pageSize") int pageSize, @DefaultValue("") @QueryParam("sortBy") String sortBy, @@ -419,11 +420,11 @@ public DocumentCollection getTaskListByRef(@PathParam("uniqueid") String uniquei Collection col = null; try { col = workflowService.getWorkListByRef(uniqueid, type, pageSize, pageIndex, sortBy, sortReverse); - return XMLItemCollectionAdapter.putDocuments(col, DocumentRestService.getItemList(items)); + return XMLDataCollectionAdapter.getDataCollection(col, DocumentRestService.getItemList(items)); } catch (Exception e) { e.printStackTrace(); } - return new DocumentCollection(); + return new XMLDataCollection(); } /** @@ -470,10 +471,10 @@ public Response postFormWorkitem(InputStream requestBodyStream) { // return workitem try { if (workitem.hasItem("$error_code")) - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)) .status(Response.Status.NOT_ACCEPTABLE).build(); else - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)).build(); + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)).build(); } catch (Exception e) { e.printStackTrace(); return Response.status(Response.Status.NOT_ACCEPTABLE).build(); @@ -512,12 +513,12 @@ public Response putFormWorkitem(InputStream requestBodyStream) { @POST @Path("/workitem") @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response postXMLWorkitem(XMLItemCollection xmlworkitem) { + public Response postXMLWorkitem(XMLDocument xmlworkitem) { logger.fine("postXMLWorkitem @POST /workitem method:postWorkitemXML...."); ItemCollection workitem; - workitem = XMLItemCollectionAdapter.getItemCollection(xmlworkitem); + workitem = XMLDocumentAdapter.putDocument(xmlworkitem); if (workitem == null) { return Response.status(Response.Status.NOT_ACCEPTABLE).build(); @@ -546,10 +547,10 @@ public Response postXMLWorkitem(XMLItemCollection xmlworkitem) { // return workitem try { if (workitem.hasItem("$error_code")) - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)) .status(Response.Status.NOT_ACCEPTABLE).build(); else - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)).build(); + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)).build(); } catch (Exception e) { e.printStackTrace(); return Response.status(Response.Status.NOT_ACCEPTABLE).build(); @@ -565,7 +566,7 @@ public Response postXMLWorkitem(XMLItemCollection xmlworkitem) { @PUT @Path("/workitem") @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response putXMLWorkitem(XMLItemCollection workitem) { + public Response putXMLWorkitem(XMLDocument workitem) { logger.fine("putXMLWorkitem @PUT /workitem delegate to POST...."); return postXMLWorkitem(workitem); } @@ -573,10 +574,10 @@ public Response putXMLWorkitem(XMLItemCollection workitem) { @POST @Path("/workitem/{uniqueid}") @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response postXMLWorkitemByUniqueID(@PathParam("uniqueid") String uniqueid, XMLItemCollection xmlworkitem) { + public Response postXMLWorkitemByUniqueID(@PathParam("uniqueid") String uniqueid, XMLDocument xmlworkitem) { logger.fine("postXMLWorkitemByUniqueID @POST /workitem/" + uniqueid + " method:postWorkitemXML...."); ItemCollection workitem; - workitem = XMLItemCollectionAdapter.getItemCollection(xmlworkitem); + workitem = XMLDocumentAdapter.putDocument(xmlworkitem); // validate given uniqueid.... if (!workitem.getUniqueID().isEmpty() && !uniqueid.equals(workitem.getUniqueID())) { @@ -612,10 +613,10 @@ public Response postXMLWorkitemByUniqueID(@PathParam("uniqueid") String uniqueid // return workitem try { if (workitem.hasItem("$error_code")) - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)) .status(Response.Status.NOT_ACCEPTABLE).build(); else - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)).build(); + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)).build(); } catch (Exception e) { e.printStackTrace(); return Response.status(Response.Status.NOT_ACCEPTABLE).build(); @@ -633,7 +634,7 @@ public Response postXMLWorkitemByUniqueID(@PathParam("uniqueid") String uniqueid @PUT @Path("/workitem/{uniqueid}") @Consumes({ MediaType.APPLICATION_XML, MediaType.TEXT_XML }) - public Response putXMLWorkitemByUniqueID(@PathParam("uniqueid") String uniqueid, XMLItemCollection xmlworkitem) { + public Response putXMLWorkitemByUniqueID(@PathParam("uniqueid") String uniqueid, XMLDocument xmlworkitem) { logger.fine("putXMLWorkitem @PUT /workitem/{uniqueid} delegate to POST...."); return postXMLWorkitemByUniqueID(uniqueid,xmlworkitem); } @@ -716,10 +717,10 @@ public Response postJSONWorkitem(InputStream requestBodyStream, @QueryParam("err // return workitem try { if (workitem.hasItem("$error_code")) - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)) .status(Response.Status.NOT_ACCEPTABLE).build(); else - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)).build(); + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)).build(); } catch (Exception e) { e.printStackTrace(); return Response.status(Response.Status.NOT_ACCEPTABLE).build(); @@ -813,10 +814,10 @@ public Response postJSONWorkitemByUniqueID(@PathParam("uniqueid") String uniquei // return workitem try { if (workitem.hasItem("$error_code")) - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)) + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)) .status(Response.Status.NOT_ACCEPTABLE).build(); else - return Response.ok(XMLItemCollectionAdapter.putItemCollection(workitem)).build(); + return Response.ok(XMLDataCollectionAdapter.getDataCollection(workitem)).build(); } catch (Exception e) { e.printStackTrace(); return Response.status(Response.Status.NOT_ACCEPTABLE).build(); @@ -855,17 +856,17 @@ public Response putJSONWorkitemByUniqueID(@PathParam("uniqueid") String uniqueid @POST @Path("/workitems") @Consumes({ MediaType.APPLICATION_XML, "text/xml" }) - public Response postWorkitems_XML(DocumentCollection worklist) { + public Response postWorkitems_XML(XMLDataCollection worklist) { logger.fine("postWorkitems_XML @POST /workitems method:postWorkitemsXML...."); - XMLItemCollection entity; + XMLDocument entity; ItemCollection itemCollection; try { // save new entities into database and update modelversion..... for (int i = 0; i < worklist.getDocument().length; i++) { entity = worklist.getDocument()[i]; - itemCollection = XMLItemCollectionAdapter.getItemCollection(entity); + itemCollection = XMLDocumentAdapter.putDocument(entity); // process entity workflowService.processWorkItem(itemCollection); } @@ -879,7 +880,7 @@ public Response postWorkitems_XML(DocumentCollection worklist) { @PUT @Path("/workitems") @Consumes({ MediaType.APPLICATION_XML, "text/xml" }) - public Response putWorkitems_XML(DocumentCollection worklist) { + public Response putWorkitems_XML(XMLDataCollection worklist) { logger.fine("pupWorkitems_XML @PUT /workitems delegate to @POST...."); return postWorkitems_XML(worklist); } diff --git a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/XMLItemCollectionWriter.java b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/XMLItemCollectionWriter.java index 48ea6ecf5..4e2f8b06f 100644 --- a/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/XMLItemCollectionWriter.java +++ b/imixs-workflow-jax-rs/src/main/java/org/imixs/workflow/jaxrs/XMLItemCollectionWriter.java @@ -50,19 +50,19 @@ import javax.ws.rs.ext.Provider; import org.imixs.workflow.ItemCollection; -import org.imixs.workflow.xml.XMLItemCollection; -import org.imixs.workflow.xml.XMLItemCollectionAdapter; +import org.imixs.workflow.xml.XMLDocument; +import org.imixs.workflow.xml.XMLDocumentAdapter; @Provider @Produces("text/html") -public class XMLItemCollectionWriter implements MessageBodyWriter { +public class XMLItemCollectionWriter implements MessageBodyWriter { public boolean isWriteable(Class type, Type genericType, Annotation[] annotations, MediaType mediaType) { - return XMLItemCollection.class.isAssignableFrom(type); + return XMLDocument.class.isAssignableFrom(type); } - public void writeTo(XMLItemCollection xmlItemCollection, Class type, Type genericType, Annotation[] annotations, + public void writeTo(XMLDocument xmlItemCollection, Class type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap httpHeaders, OutputStream entityStream) throws IOException, WebApplicationException { BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(entityStream)); @@ -86,7 +86,7 @@ public void writeTo(XMLItemCollection xmlItemCollection, Class type, Type gen bw.flush(); } - public long getSize(XMLItemCollection arg0, Class arg1, Type arg2, Annotation[] arg3, MediaType arg4) { + public long getSize(XMLDocument arg0, Class arg1, Type arg2, Annotation[] arg3, MediaType arg4) { return -1; } @@ -99,10 +99,10 @@ public long getSize(XMLItemCollection arg0, Class arg1, Type arg2, Annotation * @throws IOException */ @SuppressWarnings("rawtypes") - public static void printXMLItemCollectionHTML(BufferedWriter bw, XMLItemCollection xmlworkItem) throws IOException { + public static void printXMLItemCollectionHTML(BufferedWriter bw, XMLDocument xmlworkItem) throws IOException { boolean trClass = false; - ItemCollection workItem = XMLItemCollectionAdapter.getItemCollection(xmlworkItem); + ItemCollection workItem = XMLDocumentAdapter.putDocument(xmlworkItem); bw.write(""); bw.write("");