use of com.twinsoft.convertigo.beans.steps.XMLActionStep in project convertigo by convertigo.
the class Migration7_0_0 method handleSteps.
private static void handleSteps(XmlSchema projectSchema, Map<String, Reference> referenceMap, List<Step> stepList) {
for (Step step : stepList) {
if (step instanceof XMLActionStep) {
XMLVector<XMLVector<Object>> sourcesDefinition = ((XMLActionStep) step).getSourcesDefinition();
for (XMLVector<Object> row : sourcesDefinition) {
if (row.size() > 1) {
XMLVector<String> definition = GenericUtils.cast(row.get(1));
handleSourceDefinition(definition);
}
}
}
if (step instanceof TransactionStep) {
XMLVector<String> definition = ((TransactionStep) step).getConnectionStringDefinition();
handleSourceDefinition(definition);
}
if (step instanceof IStepSourceContainer) {
/**
* Case step's xpath has not been migrated when project has been deployed
** on a 5.0 server from a Studio with an older version *
*/
IStepSourceContainer stepSourceContainer = (IStepSourceContainer) step;
XMLVector<String> definition = stepSourceContainer.getSourceDefinition();
handleSourceDefinition(definition);
}
if (step instanceof IVariableContainer) {
IVariableContainer variableContainer = (IVariableContainer) step;
for (Variable variable : variableContainer.getVariables()) {
if (variable instanceof IStepSourceContainer) {
IStepSourceContainer stepSourceContainer = (IStepSourceContainer) variable;
XMLVector<String> definition = stepSourceContainer.getSourceDefinition();
handleSourceDefinition(definition);
}
}
}
String targetProjectName = null;
String typeLocalName = null;
if (step instanceof TransactionStep) {
targetProjectName = ((TransactionStep) step).getProjectName();
typeLocalName = ((TransactionStep) step).getConnectorName() + "__" + ((TransactionStep) step).getTransactionName() + "ResponseType";
} else if (step instanceof SequenceStep) {
targetProjectName = ((SequenceStep) step).getProjectName();
typeLocalName = ((SequenceStep) step).getSequenceName() + "ResponseType";
}
String namespaceURI = null;
// Case of Requestable steps
if (targetProjectName != null) {
try {
namespaceURI = Project.CONVERTIGO_PROJECTS_NAMESPACEURI + targetProjectName;
if (!targetProjectName.equals(step.getProject().getName())) {
try {
namespaceURI = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(targetProjectName).getTargetNamespace();
} catch (Exception e) {
}
// Add reference
String location = "../" + targetProjectName + "/" + targetProjectName + ".xsd";
addReferenceToMap(referenceMap, namespaceURI, location);
}
// Set step's typeQName
step.setXmlComplexTypeAffectation(new XmlQName(new QName(namespaceURI, typeLocalName)));
} catch (Exception e) {
e.printStackTrace();
}
} else // Other steps
{
try {
String targetNamespace = projectSchema.getTargetNamespace();
String targetPrefix = projectSchema.getNamespaceContext().getPrefix(targetNamespace);
String s = null;
try {
if (step instanceof XMLCopyStep) {
XmlSchemaCollection collection = SchemaMeta.getCollection(projectSchema);
XmlSchemaObject ob = step.getXmlSchemaObject(collection, projectSchema);
if (ob != null) {
if (ob instanceof XmlSchemaSequence) {
ob = ((XmlSchemaSequence) ob).getItems().getItem(0);
}
if (ob instanceof XmlSchemaElement || ob instanceof XmlSchemaAttribute) {
QName schemaTypeName = ob instanceof XmlSchemaElement ? ((XmlSchemaElement) ob).getSchemaTypeName() : ((XmlSchemaAttribute) ob).getSchemaTypeName();
String schemaTypePrefix = projectSchema.getNamespaceContext().getPrefix(schemaTypeName.getNamespaceURI());
String schemaTypeLocalName = schemaTypeName.getLocalPart();
s = schemaTypePrefix + ":" + schemaTypeLocalName;
}
}
} else {
String schemaType = step.getSchemaDataType();
s = schemaType.equals("") ? "xsd:string" : schemaType;
}
} catch (Exception e) {
s = "xsd:string";
}
if ((s != null) && (!s.equals("")) && (!s.startsWith("xsd:"))) {
String prefix = s.split(":")[0];
typeLocalName = s.split(":")[1];
if (prefix.equals(targetPrefix)) {
// ignore
} else {
// Retrieve namespace uri
namespaceURI = projectSchema.getNamespaceContext().getNamespaceURI(prefix);
// Set step's typeQName
QName qname = new QName(namespaceURI, typeLocalName);
XmlSchemaType schemaType = projectSchema.getTypeByName(qname);
if (schemaType instanceof XmlSchemaComplexType)
step.setXmlComplexTypeAffectation(new XmlQName(qname));
if (schemaType instanceof XmlSchemaSimpleType)
step.setXmlSimpleTypeAffectation(new XmlQName(qname));
}
}
} catch (Exception e) {
}
}
if (step instanceof ISimpleTypeAffectation) {
QName qName = XmlSchemaUtils.getSchemaDataTypeName(step.getSchemaDataType());
step.setXmlSimpleTypeAffectation(new XmlQName(qName));
}
if (step instanceof StepWithExpressions) {
handleSteps(projectSchema, referenceMap, ((StepWithExpressions) step).getSteps());
}
}
}
Aggregations