use of com.twinsoft.convertigo.beans.core.IStepSourceContainer 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());
}
}
}
use of com.twinsoft.convertigo.beans.core.IStepSourceContainer in project convertigo by convertigo.
the class TreeDropAdapter method validateDrop.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ViewerDropAdapter#validateDrop(java.lang.Object, int, org.eclipse.swt.dnd.TransferData)
*/
@Override
public boolean validateDrop(Object target, int operation, TransferData transferType) {
if (TextTransfer.getInstance().isSupportedType(transferType)) {
if (getCurrentOperation() == DND.DROP_MOVE) {
Object targetObject = getCurrentTarget();
Object sourceObject = getSelectedObject();
if (targetObject != null && targetObject instanceof TreeObject) {
TreeObject targetTreeObject = (TreeObject) targetObject;
if (sourceObject != null && sourceObject instanceof TreeObject) {
TreeObject sourceTreeObject = (TreeObject) sourceObject;
boolean isFocus = sourceTreeObject.viewer.getControl().isFocusControl();
if (isFocus && (sourceObject == targetObject || targetTreeObject.isChildOf(sourceTreeObject))) {
return false;
}
}
if (targetObject instanceof DatabaseObjectTreeObject) {
try {
String xmlData = TextTransfer.getInstance().nativeToJava(transferType).toString();
List<Object> list = ConvertigoPlugin.clipboardManagerDND.read(xmlData);
DatabaseObject databaseObject = (DatabaseObject) list.get(0);
DatabaseObject targetDatabaseObject = ((DatabaseObjectTreeObject) target).getObject();
if (DatabaseObjectsManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
return true;
}
DatabaseObject parentDatabaseObject = targetDatabaseObject.getParent();
if (parentDatabaseObject != null && DatabaseObjectsManager.acceptDatabaseObjects(parentDatabaseObject, databaseObject)) {
return true;
}
return false;
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
}
return true;
}
if (StepSourceTransfer.getInstance().isSupportedType(transferType)) {
if (target instanceof TreeObject) {
TreeObject targetTreeObject = (TreeObject) target;
// Check for drop to a step which contains a stepSource definition
// if (targetTreeObject.getObject() instanceof IStepSourceContainer) {
Object ob = targetTreeObject.getObject();
if (ob instanceof Step && ((Step) ob).canWorkOnSource() || ob instanceof IStepSourceContainer) {
StepSource stepSource = StepSourceTransfer.getInstance().getStepSource();
if (stepSource != null) {
Step targetStep = (Step) ((ob instanceof StepVariable) ? ((StepVariable) ob).getParent() : ob);
// Check for drop to a step in the same sequence
Long key = Long.valueOf(stepSource.getPriority());
Step sourceStep = targetStep.getSequence().loadedSteps.get(key);
if ((sourceStep != null) && (!targetStep.equals(sourceStep))) {
// Check for drop on a 'following' step
try {
List<TreeObject> siblings = new ArrayList<TreeObject>();
getNextSiblings(siblings, targetTreeObject.getProjectTreeObject(), sourceStep);
// System.out.println("siblings: "+siblings.toString());
return siblings.contains(targetTreeObject);
} catch (Exception e) {
e.printStackTrace(System.out);
}
;
}
}
}
}
}
if (PaletteSourceTransfer.getInstance().isSupportedType(transferType)) {
if (target instanceof TreeObject) {
TreeObject targetTreeObject = (TreeObject) target;
PaletteSource paletteSource = PaletteSourceTransfer.getInstance().getPaletteSource();
if (paletteSource != null) {
try {
String xmlData = paletteSource.getXmlData();
List<Object> list = ConvertigoPlugin.clipboardManagerDND.read(xmlData);
DatabaseObject databaseObject = (DatabaseObject) list.get(0);
if (targetTreeObject instanceof ObjectsFolderTreeObject) {
ObjectsFolderTreeObject folderTreeObject = (ObjectsFolderTreeObject) targetTreeObject;
if (!ProjectExplorerView.folderAcceptMobileComponent(folderTreeObject.folderType, databaseObject)) {
return false;
}
// continue
targetTreeObject = folderTreeObject.getParent();
}
if (targetTreeObject instanceof DatabaseObjectTreeObject) {
DatabaseObject targetDatabaseObject = ((DatabaseObjectTreeObject) targetTreeObject).getObject();
if (targetDatabaseObject != null) {
if (!DatabaseObjectsManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
return false;
}
if (targetTreeObject instanceof MobileComponentTreeObject) {
if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
return false;
}
if (!com.twinsoft.convertigo.beans.mobile.components.dynamic.ComponentManager.isTplCompatible(targetDatabaseObject, databaseObject)) {
return false;
}
}
if (targetTreeObject instanceof NgxComponentTreeObject) {
if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.acceptDatabaseObjects(targetDatabaseObject, databaseObject)) {
return false;
}
if (!com.twinsoft.convertigo.beans.ngx.components.dynamic.ComponentManager.isTplCompatible(targetDatabaseObject, databaseObject)) {
return false;
}
}
return true;
}
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}
}
}
if (MobileSourceTransfer.getInstance().isSupportedType(transferType)) {
MobileSource mobileSource = MobileSourceTransfer.getInstance().getMobileSource();
if (mobileSource != null) {
if (target instanceof MobileUIComponentTreeObject) {
MobileUIComponentTreeObject mcto = GenericUtils.cast(target);
com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource mss = com.twinsoft.convertigo.beans.mobile.components.MobileSmartSource.valueOf(mobileSource.getJsonString());
if (mss == null || !mss.isDroppableInto(mcto.getObject())) {
return false;
}
for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
if (descriptor instanceof MobileSmartSourcePropertyDescriptor) {
if (!((MobileSmartSourcePropertyDescriptor) descriptor).isReadOnly()) {
return true;
}
}
}
}
if (target instanceof NgxUIComponentTreeObject) {
NgxUIComponentTreeObject mcto = GenericUtils.cast(target);
com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource mss = com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.valueOf(mobileSource.getJsonString());
if (mss == null || !mss.isDroppableInto(mcto.getObject())) {
return false;
}
for (IPropertyDescriptor descriptor : mcto.getPropertyDescriptors()) {
if (descriptor instanceof NgxSmartSourcePropertyDescriptor) {
if (!((NgxSmartSourcePropertyDescriptor) descriptor).isReadOnly()) {
return true;
}
}
}
}
}
}
return false;
}
use of com.twinsoft.convertigo.beans.core.IStepSourceContainer in project convertigo by convertigo.
the class SourcePickerView method showStep.
private void showStep(DatabaseObject dbo, boolean showSource) {
if (selectedDbo == null)
return;
String priority, xpath;
DatabaseObject dboToShow = null;
if (showSource) {
XMLVector<String> sourceDefinition = ((IStepSourceContainer) dbo).getSourceDefinition();
if (!sourceDefinition.isEmpty()) {
Long key = Long.valueOf(sourceDefinition.firstElement());
priority = "" + key;
xpath = sourceDefinition.lastElement();
Step step = dbo instanceof Step ? (Step) dbo : (Step) dbo.getParent();
dboToShow = step.getSequence().loadedSteps.get(key);
if (dboToShow == null) {
ConvertigoPlugin.infoMessageBox("Source is not valid!");
return;
}
} else {
ConvertigoPlugin.infoMessageBox("Source is empty!");
return;
}
} else {
dboToShow = dbo;
priority = "" + dboToShow.priority;
xpath = ".";
}
sourcePicker.getTwsDomTree().removeAll();
sourcePicker.getXpathEvaluator().removeAnchor();
sourcePicker.getXpathEvaluator().getXpath().setText("");
XMLVector<String> stepSourceDefinition = new XMLVector<String>();
stepSourceDefinition.add(priority);
stepSourceDefinition.add(xpath);
sourcePicker.setStepSourceDefinition(stepSourceDefinition);
sourcePicker.displayTargetWsdlDom(dboToShow);
try {
TreeObject treeObject = ConvertigoPlugin.getDefault().getProjectExplorerView().findTreeObjectByUserObject(dboToShow);
ConvertigoPlugin.getDefault().getProjectExplorerView().setSelectedTreeObject(treeObject);
} catch (Throwable t) {
}
}
use of com.twinsoft.convertigo.beans.core.IStepSourceContainer in project convertigo by convertigo.
the class SourcePickerView method removeSource.
private void removeSource() {
if (selectedDbo != null) {
if (selectedDbo instanceof IStepSourceContainer) {
try {
DatabaseObjectTreeObject dboTreeObject = (DatabaseObjectTreeObject) ConvertigoPlugin.getDefault().getProjectExplorerView().findTreeObjectByUserObject(selectedDbo);
ConvertigoPlugin.getDefault().getProjectExplorerView().setSelectedTreeObject(dboTreeObject);
dboTreeObject.setPropertyValue("sourceDefinition", new XMLVector<String>());
showBtn.setEnabled(false);
showBtn.setSelection(false);
remBtn.setEnabled(false);
} catch (Throwable t) {
}
}
}
}
use of com.twinsoft.convertigo.beans.core.IStepSourceContainer in project convertigo by convertigo.
the class SetStepSourceDefinition method getServiceResult.
@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
HttpSession session = request.getSession();
CheStudio cheStudio = CallAction.getStudio(session);
Element root = document.getDocumentElement();
if (cheStudio != null) {
SourcePickerViewWrap spv = cheStudio.getSourcePickerView();
if (spv != null) {
// Retrieve the StepSource definition
String qname = request.getParameter("qname");
DatabaseObject dbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
StepSourceWrap ssw = (StepSourceWrap) spv.getDragData();
// Update step source definition
if (com.twinsoft.convertigo.engine.admin.services.studio.sourcepicker.CanCreateSource.canCreateSource(dbo, ssw)) {
XMLVector<String> sourceDefinition = new XMLVector<>(2);
sourceDefinition.add(ssw.getPriority());
sourceDefinition.add(ssw.getXpath());
IStepSourceContainer stepSourceContainer = (IStepSourceContainer) dbo;
stepSourceContainer.setSourceDefinition(sourceDefinition);
root.appendChild(new SetPropertyResponse("sourceDefinition").toXml(document, qname));
}
}
}
}
Aggregations