I was debugging my method and it
somehow updates my element
variable. Even if I don't work with
that variable from within the
method.
CODE:
private
static List createFormFieldsMapping(ArrayList
CDOfields,
List fieldMappings, Element element) {
System.out.println(" - Creating field mappings for "+element.name);
for
(Mapping fieldMapping : fieldMappings){
if
(fieldMapping.targetEntityFieldId!=null){
String formField =
getContactFieldNameById(fieldMapping.targetEntityFieldId);
formField =
formField.trim();
formField = formField.replaceAll("-",
"");
formField = formField.replaceAll("_", "");
formField =
formField.replaceAll(" ", "");
formField =
formField.toLowerCase();
Boolean matchFound = false;
for (String
cdoField : CDOfields){
String[] cdoFieldSplit =
cdoField.split(";",-1);
String cdoFieldModified
=cdoFieldSplit[1].trim();
cdoFieldModified = cdoFieldModified.replaceAll("-",
"");
cdoFieldModified = cdoFieldModified.replaceAll("_",
"");
cdoFieldModified = cdoFieldModified.replaceAll(" ",
"");
cdoFieldModified = cdoFieldModified.toLowerCase();
if
(cdoFieldModified.equals(formField)){
fieldMapping.targetEntityFieldId =
cdoFieldSplit[0];
matchFound = true;
break;
}
if (!matchFound){
// WRITE NOT MATCHED FORM FIELD TO A
FILE
}
}
}
}
element.processingSteps.targetEntityFieldId
is being changed
This is the way I call the
method:
List
fieldMapping = new
ArrayList();
Iterator i =
element.processingSteps.iterator();
while (i.hasNext())
{
ProcessingStep step = i.next();
if
(step.type.equals("FormStepCreateUpdateContactFromFormField")){
fieldMapping
= step.mappings;
step.execute = "never";
//i.remove();
}
}
// Update contact field IDs with CDO field
IDs
fieldMapping = createFormFieldsMapping(CDOfields, fieldMapping,
element);
Everything I
wanted was to kind of copy field mapping, process it by that method and then return back
and add it to list of
fieldMappings
.
The
thing is that step.mappings
is part of
element
, but that step.mappings
is
being put to an ArrayList
fieldMapping
. By that I would assume that element should never
be edited by anything.
No comments:
Post a Comment