summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Pielmann2012-06-08 04:59:30 (EDT)
committer Manik Kishore2012-06-12 04:26:31 (EDT)
commit1850377a95a2b6b7b623d9ee7aba3ee9edc43b50 (patch)
tree2b0b41533466aca9f562204874d036d0c9ee6802
parente82bd2447e9a1b5f4a306399c14aa9e8d6525431 (diff)
downloadorg.eclipse.stardust.ide-1850377a95a2b6b7b623d9ee7aba3ee9edc43b50.zip
org.eclipse.stardust.ide-1850377a95a2b6b7b623d9ee7aba3ee9edc43b50.tar.gz
org.eclipse.stardust.ide-1850377a95a2b6b7b623d9ee7aba3ee9edc43b50.tar.bz2
Jira-ID: CRNT-24913
MTA: Overwriting/Appending to List does not work. No mapping is created. git-svn-id: http://emeafrazerg/svn/ipp/product/trunk/stardust/ide@56928 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b
-rw-r--r--modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/MessageTransformationController.java53
-rw-r--r--modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/renderer/PrimitiveMappingRenderer.java29
2 files changed, 61 insertions, 21 deletions
diff --git a/modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/MessageTransformationController.java b/modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/MessageTransformationController.java
index 953acbb..34a42b9 100644
--- a/modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/MessageTransformationController.java
+++ b/modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/MessageTransformationController.java
@@ -698,7 +698,9 @@ public class MessageTransformationController {
private boolean checkStandardMappingAllowed(AccessPointType target, AccessPointType source) {
if (isPrimitive(source)) {
if (isPrimitive(target)) {
- return true;
+ if (isEqualOrSimilar(source, target, true)) {
+ return true;
+ }
}
if (isRoot(target)) {
return false;
@@ -708,7 +710,7 @@ public class MessageTransformationController {
}
return true;
}
- if (isPrimitive(target)) {
+ if (isPrimitive(target)) {
if (isPrimitive(source)) {
return true;
}
@@ -750,6 +752,9 @@ public class MessageTransformationController {
if (apt != null && (!(apt instanceof StructAccessPointType)) && apt.getType() != null && apt.getType().getId() != null && apt.getType().getId().startsWith("prim")) { //$NON-NLS-1$
return true;
}
+ if (apt != null && ((apt instanceof StructAccessPointType)) && apt.getType() != null && apt.getType().getId() != null && apt.getType().getId().startsWith("prim")) { //$NON-NLS-1$
+ return true;
+ }
return false;
}
@@ -834,20 +839,32 @@ public class MessageTransformationController {
usedVar.clear();
String mappingCode = ""; //$NON-NLS-1$
FieldMapping fm = fieldMappings.get(getXPathFor(tm.getType()));
- if (isList(tm.getType())) {
- mappingCode = sm.renderListMappingCode(sm, tm, "", 0, config); //$NON-NLS-1$
- fm.setAdvancedMapping(true);
- } else {
- String getterCode = sm.renderGetterCode(false, false, config);
- mappingCode = tm.renderSetterCode(getterCode, false, false, config);
- fm.setAdvancedMapping(tm instanceof SerializableMappingRenderer);
- if (tm instanceof StructDataMappingRenderer) {
- fm.setAdvancedMapping(arraySelectionDepthTarget > 0);
- }
- }
- mappingCode = mappingCode.replaceAll("@", ""); //$NON-NLS-1$ //$NON-NLS-2$
- fm.setMappingExpression(mappingCode);
- validateMapping(fm, true);
+
+ if (!isList(sm.getType()) && isList(tm.getType())) {
+ mappingCode = sm.renderAdditionCode(sm, tm, config);
+ fm = fieldMappings.get(getXPathFor(tm.getType()));
+ fm.setMappingExpression(fm.getMappingExpression() + "\n" + mappingCode); //$NON-NLS-1$
+ fm.setAdvancedMapping(config != null && config.isOverwrite() || config.isAppend());
+ validateMapping(fm, true);
+ } else {
+ if (isList(tm.getType())) {
+ mappingCode = sm.renderListMappingCode(sm, tm, "", 0, config); //$NON-NLS-1$
+ fm.setAdvancedMapping(true);
+ } else {
+ String getterCode = sm.renderGetterCode(false, false, config);
+ mappingCode = tm.renderSetterCode(getterCode, false, false, config);
+ fm.setAdvancedMapping(tm instanceof SerializableMappingRenderer);
+ if (tm instanceof StructDataMappingRenderer) {
+ fm.setAdvancedMapping(arraySelectionDepthTarget > 0);
+ }
+ }
+ mappingCode = mappingCode.replaceAll("@", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ fm.setMappingExpression(mappingCode);
+ validateMapping(fm, true);
+ }
+
+
+
}
private void mapComplextToPrimitiveMessage(
@@ -928,7 +945,9 @@ public class MessageTransformationController {
if (advanced) {
//Refactor this. Find a suitable way to compare primtives with Serializables and Struct types
if (sr instanceof PrimitiveMappingRenderer || tr instanceof PrimitiveMappingRenderer) {
- return true;
+ if (sr.getTypeString().equals(tr.getTypeString())) {
+ return true;
+ }
}
if (sr.getTypeString().equalsIgnoreCase(tr.getTypeString()) || isSpecialCase(sr, tr)) {
Object[] sourceChildren = sourceAPB.getChildren(sourceMessage, true);
diff --git a/modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/renderer/PrimitiveMappingRenderer.java b/modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/renderer/PrimitiveMappingRenderer.java
index 130086f..07818a2 100644
--- a/modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/renderer/PrimitiveMappingRenderer.java
+++ b/modeling/org.eclipse.stardust.modeling.transformation/src/org/eclipse/stardust/modeling/transformation/messaging/modeling/application/transformation/renderer/PrimitiveMappingRenderer.java
@@ -160,9 +160,30 @@ public class PrimitiveMappingRenderer implements IMappingRenderer {
return " "; //$NON-NLS-1$
}
- public String renderAdditionCode(IMappingRenderer sourceMapper,
- IMappingRenderer targetMapper, MappingConfiguration config) {
- return null;
- }
+ public String renderAdditionCode(IMappingRenderer sourceMapper, IMappingRenderer targetMapper, MappingConfiguration config) {
+ String sourcePath = sourceMapper.renderGetterCode(false, false, config);
+ if (sourcePath.endsWith(".")) { //$NON-NLS-1$
+ sourcePath = sourcePath.replace(".", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String targetIndex = targetMapper.renderGetterCode(false, false, config);
+ if (targetIndex.endsWith(".")) { //$NON-NLS-1$
+ targetIndex = targetIndex.replace(".", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String result = targetIndex;
+ if (config.isAppend()) {
+ int idx1 = targetIndex.lastIndexOf("["); //$NON-NLS-1$
+ int idx2 = targetIndex.lastIndexOf("]"); //$NON-NLS-1$
+ int idx = idx2 - idx1 + 1;
+ targetIndex = targetIndex.substring(0, targetIndex.length() - idx);
+ targetIndex = targetIndex + ".length + 1"; //$NON-NLS-1$
+ String xPath = controller.getXPathFor(targetMapper.getType());
+ config.getIndexMap().put(xPath, targetIndex);
+ result = targetMapper.renderGetterCode(false, false, config);
+ }
+ if (result.endsWith(".")) { //$NON-NLS-1$
+ result = targetIndex.replace(".", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return result + " = " + sourcePath + ";"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
}