summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-09-06 09:12:51 (EDT)
committerStephan Born2012-09-10 08:46:55 (EDT)
commitdf80956bf38a00b28080f9f4e53b4e4d95a7dc7c (patch)
tree5f35f2ca190779082d0041594ccfe6e7d87514a9
parent21e00cd8ffda53594258598204ed9fd1f06d49ed (diff)
downloadorg.eclipse.stardust.ide-df80956bf38a00b28080f9f4e53b4e4d95a7dc7c.zip
org.eclipse.stardust.ide-df80956bf38a00b28080f9f4e53b4e4d95a7dc7c.tar.gz
org.eclipse.stardust.ide-df80956bf38a00b28080f9f4e53b4e4d95a7dc7c.tar.bz2
CRNT-26096 Pepper: Provide methods in ModelBuilderFacade to transform a data into another
git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide@58975 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/AbstractDmsItemInitializer.java44
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/DataStructInitializer.java28
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/DmsDocumentInitializer.java28
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/PrimitiveDataInitializer.java86
-rw-r--r--model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/SerializableDataInitializer.java72
5 files changed, 258 insertions, 0 deletions
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/AbstractDmsItemInitializer.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/AbstractDmsItemInitializer.java
new file mode 100644
index 0000000..a4968c8
--- /dev/null
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/AbstractDmsItemInitializer.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2011 SunGard CSA LLC and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SunGard CSA LLC - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.stardust.model.xpdl.builder.initializer;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.stardust.model.xpdl.carnot.AttributeType;
+import org.eclipse.stardust.model.xpdl.carnot.CarnotWorkflowModelFactory;
+import org.eclipse.stardust.model.xpdl.carnot.DataType;
+import org.eclipse.stardust.model.xpdl.carnot.spi.IDataInitializer;
+import org.eclipse.stardust.model.xpdl.carnot.util.CarnotConstants;
+
+
+/**
+ * @author rsauer
+ * @version $Revision: 51288 $
+ */
+public abstract class AbstractDmsItemInitializer implements IDataInitializer
+{
+ protected abstract Class<?> getInterfaceType();
+
+ public List<AttributeType> initialize(DataType data, List<AttributeType> attributes)
+ {
+ AttributeType attrClassName = CarnotWorkflowModelFactory.eINSTANCE.createAttributeType();
+ attrClassName.setName(CarnotConstants.CLASS_NAME_ATT);
+ attrClassName.setValue(getInterfaceType().getName());
+
+ AttributeType attrBidirectional = CarnotWorkflowModelFactory.eINSTANCE.createAttributeType();
+ attrBidirectional.setName(CarnotConstants.ENGINE_SCOPE + "data:bidirectional"); //$NON-NLS-1$
+ attrBidirectional.setValue(Boolean.TRUE.toString());
+ attrBidirectional.setType(Boolean.TYPE.getName());
+
+ return Arrays.asList(new AttributeType[] {attrClassName, attrBidirectional});
+ }
+}
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/DataStructInitializer.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/DataStructInitializer.java
new file mode 100644
index 0000000..142e8ca
--- /dev/null
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/DataStructInitializer.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 SunGard CSA LLC and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SunGard CSA LLC - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.stardust.model.xpdl.builder.initializer;
+
+import java.util.List;
+
+import org.eclipse.stardust.engine.core.struct.StructuredDataConstants;
+import org.eclipse.stardust.model.xpdl.carnot.DataType;
+import org.eclipse.stardust.model.xpdl.carnot.spi.IDataInitializer;
+import org.eclipse.stardust.model.xpdl.carnot.util.AttributeUtil;
+
+public class DataStructInitializer implements IDataInitializer
+{
+ public List initialize(DataType data, List attributes)
+ {
+ AttributeUtil.setAttribute(data, "carnot:engine:path:separator", StructuredDataConstants.ACCESS_PATH_SEGMENT_SEPARATOR); //$NON-NLS-1$
+ AttributeUtil.setBooleanAttribute(data, "carnot:engine:data:bidirectional", true); //$NON-NLS-1$
+ return null;
+ }
+} \ No newline at end of file
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/DmsDocumentInitializer.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/DmsDocumentInitializer.java
new file mode 100644
index 0000000..92aa9bd
--- /dev/null
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/DmsDocumentInitializer.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2011 SunGard CSA LLC and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SunGard CSA LLC - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.stardust.model.xpdl.builder.initializer;
+
+
+import org.eclipse.stardust.engine.api.runtime.Document;
+import org.eclipse.stardust.model.xpdl.carnot.spi.IDataInitializer;
+
+/**
+ * @author rsauer
+ * @version $Revision: 52562 $
+ */
+public class DmsDocumentInitializer extends AbstractDmsItemInitializer
+ implements IDataInitializer
+{
+ protected Class<?> getInterfaceType()
+ {
+ return Document.class;
+ }
+}
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/PrimitiveDataInitializer.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/PrimitiveDataInitializer.java
new file mode 100644
index 0000000..645ada3
--- /dev/null
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/PrimitiveDataInitializer.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * Copyright (c) 2011 SunGard CSA LLC and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SunGard CSA LLC - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.stardust.model.xpdl.builder.initializer;
+
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+
+import org.eclipse.stardust.common.Money;
+import org.eclipse.stardust.model.xpdl.carnot.AttributeType;
+import org.eclipse.stardust.model.xpdl.carnot.CarnotWorkflowModelFactory;
+import org.eclipse.stardust.model.xpdl.carnot.DataType;
+import org.eclipse.stardust.model.xpdl.carnot.spi.IDataInitializer;
+import org.eclipse.stardust.model.xpdl.carnot.util.CarnotConstants;
+
+/**
+ * @author fherinean
+ * @version $Revision: 52524 $
+ */
+public class PrimitiveDataInitializer implements IDataInitializer
+{
+ static final String[][] mappingsToType = {
+ {boolean.class.getName(), "boolean"}, //$NON-NLS-1$
+ {Boolean.class.getName(), "boolean"}, //$NON-NLS-1$
+ {char.class.getName(), "char"}, //$NON-NLS-1$
+ {Character.class.getName(), "char"}, //$NON-NLS-1$
+ {byte.class.getName(), "byte"}, //$NON-NLS-1$
+ {Byte.class.getName(), "byte"}, //$NON-NLS-1$
+ {short.class.getName(), "short"}, //$NON-NLS-1$
+ {Short.class.getName(), "short"}, //$NON-NLS-1$
+ {int.class.getName(), "int"}, //$NON-NLS-1$
+ {Integer.class.getName(), "int"}, //$NON-NLS-1$
+ {long.class.getName(), "long"}, //$NON-NLS-1$
+ {Long.class.getName(), "long"}, //$NON-NLS-1$
+ {float.class.getName(), "float"}, //$NON-NLS-1$
+ {Float.class.getName(), "float"}, //$NON-NLS-1$
+ {double.class.getName(), "double"}, //$NON-NLS-1$
+ {Double.class.getName(), "double"}, //$NON-NLS-1$
+ {String.class.getName(), "String"}, //$NON-NLS-1$
+ {Calendar.class.getName(), "Calendar"}, //$NON-NLS-1$
+ {Money.class.getName(), "Money"}, //$NON-NLS-1$
+ {Date.class.getName(), "Timestamp"}, //$NON-NLS-1$
+ };
+
+ public List initialize(DataType data, List attributes)
+ {
+ String typeName = null;
+ for (int i = 0; i < attributes.size(); i++)
+ {
+ AttributeType attribute = (AttributeType) attributes.get(i);
+ if (CarnotConstants.CLASS_NAME_ATT.equals(attribute.getName()))
+ {
+ String className = attribute.getValue();
+ if (className != null && className.length() > 0)
+ {
+ for (int j = 0; j < mappingsToType.length; j++)
+ {
+ if (mappingsToType[j][0].equals(className))
+ {
+ typeName = mappingsToType[j][1];
+ break;
+ }
+ }
+ if (typeName != null)
+ {
+ break;
+ }
+ }
+ }
+ }
+ AttributeType attribute = CarnotWorkflowModelFactory.eINSTANCE.createAttributeType();
+ attribute.setName(CarnotConstants.TYPE_ATT);
+ attribute.setType("ag.carnot.workflow.spi.providers.data.java.Type"); //$NON-NLS-1$
+ attribute.setValue(typeName == null ? "String" : typeName); //$NON-NLS-1$
+ return Collections.singletonList(attribute);
+ }
+}
diff --git a/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/SerializableDataInitializer.java b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/SerializableDataInitializer.java
new file mode 100644
index 0000000..c039e0a
--- /dev/null
+++ b/model/org.eclipse.stardust.model.xpdl.builder/src/main/java/org/eclipse/stardust/model/xpdl/builder/initializer/SerializableDataInitializer.java
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2011 SunGard CSA LLC and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * SunGard CSA LLC - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+package org.eclipse.stardust.model.xpdl.builder.initializer;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.stardust.common.StringUtils;
+import org.eclipse.stardust.common.error.InternalException;
+import org.eclipse.stardust.common.reflect.Reflect;
+import org.eclipse.stardust.model.xpdl.carnot.AttributeType;
+import org.eclipse.stardust.model.xpdl.carnot.CarnotWorkflowModelFactory;
+import org.eclipse.stardust.model.xpdl.carnot.DataType;
+import org.eclipse.stardust.model.xpdl.carnot.spi.IDataInitializer;
+import org.eclipse.stardust.model.xpdl.carnot.util.CarnotConstants;
+
+/**
+ * @author fherinean
+ * @version $Revision: 52524 $
+ */
+public class SerializableDataInitializer implements IDataInitializer
+{
+ public List initialize(DataType data, List attributes)
+ {
+ String className = null;
+ for (int i = 0; i < attributes.size(); i++)
+ {
+ AttributeType attribute = (AttributeType) attributes.get(i);
+ if (CarnotConstants.CLASS_NAME_ATT.equals(attribute.getName()))
+ {
+ className = attribute.getValue();
+ }
+ else if (CarnotConstants.REMOTE_INTERFACE_ATT.equals(attribute.getName()))
+ {
+ className = attribute.getValue();
+ }
+ else if (CarnotConstants.TYPE_ATT.equals(attribute.getName()))
+ {
+ try
+ {
+ Class type = Reflect.getClassFromAbbreviatedName(attribute.getValue());
+ if (null != type)
+ {
+ className = type.getName();
+ }
+ }
+ catch (InternalException e)
+ {
+ // ignore
+ }
+ }
+
+ if ( !StringUtils.isEmpty(className))
+ {
+ break;
+ }
+ }
+ AttributeType attribute = CarnotWorkflowModelFactory.eINSTANCE.createAttributeType();
+ attribute.setName(CarnotConstants.CLASS_NAME_ATT);
+ attribute.setValue(className == null ? Serializable.class.getName() : className);
+ return Collections.singletonList(attribute);
+ }
+}