Search in sources :

Example 6 with StepSource

use of com.twinsoft.convertigo.beans.core.StepSource in project convertigo by convertigo.

the class WriteFileStep method stepExecute.

@Override
protected boolean stepExecute(Context javascriptContext, Scriptable scope) throws EngineException {
    if (isEnabled()) {
        filePath = null;
        try {
            StepSource stepSource = getSource();
            if (!stepSource.inError()) {
                filePath = evaluateDataFileName(javascriptContext, scope);
                // Retrieve a view based on context nodes (prevent to modify context nodes, output usefull nodes only)
                OutputFilter outputFilter = sequence.new OutputFilter(writeOutputFalse ? OutputOption.UsefullOnly : OutputOption.VisibleOnly);
                NodeList nl = Sequence.ouputDomView(stepSource.getContextOutputNodes(), outputFilter);
                writeFile(filePath, nl);
                filePath = getAbsoluteFilePath(filePath);
            }
        } catch (Exception e) {
            setErrorStatus(true);
            Engine.logBeans.error("An error occured while writing to file", e);
        }
        return super.stepExecute(javascriptContext, scope);
    }
    return false;
}
Also used : StepSource(com.twinsoft.convertigo.beans.core.StepSource) OutputFilter(com.twinsoft.convertigo.beans.core.Sequence.OutputFilter) NodeList(org.w3c.dom.NodeList) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 7 with StepSource

use of com.twinsoft.convertigo.beans.core.StepSource in project convertigo by convertigo.

the class XMLCopyStep method getTargetXPath.

protected String getTargetXPath() throws EngineException {
    String xpath = "";
    StepSource source = getSource();
    if (!source.isEmpty()) {
        Step sourceStep = source.getStep();
        if (sourceStep instanceof IteratorStep) {
            xpath = source.getXpath().substring(1);
        }
    }
    return xpath;
}
Also used : StepSource(com.twinsoft.convertigo.beans.core.StepSource) Step(com.twinsoft.convertigo.beans.core.Step)

Example 8 with StepSource

use of com.twinsoft.convertigo.beans.core.StepSource in project convertigo by convertigo.

the class XMLCopyStep method getXmlSchemaObject.

@Override
public XmlSchemaObject getXmlSchemaObject(XmlSchemaCollection collection, XmlSchema schema) {
    try {
        StepSource source = getTargetSource();
        if (!source.isEmpty()) {
            XmlSchemaObject object = SchemaMeta.getXmlSchemaObject(schema, source.getStep());
            if (object != null) {
                SchemaMeta.setSchema(object, schema);
                String xpath = source.getXpath();
                String anchor = source.getAnchor() + getTargetXPath();
                if (!".".equals(xpath)) {
                    Map<Node, XmlSchemaObject> references = new HashMap<Node, XmlSchemaObject>();
                    Document doc = XmlSchemaUtils.getDomInstance(object, references);
                    // String sDoc = XMLUtils.prettyPrintDOM(doc);
                    Element contextNode = doc.getDocumentElement();
                    if (anchor.startsWith("//" + contextNode.getNodeName() + "/")) {
                        anchor = anchor.replaceFirst("//" + contextNode.getNodeName() + "/", "./");
                    }
                    NodeList list = getXPathAPI().selectNodeList(contextNode, anchor);
                    if (list != null) {
                        boolean isList = false;
                        if (list.getLength() > 1) {
                            isList = true;
                            object = XmlSchemaUtils.makeDynamic(this, new XmlSchemaSequence());
                        }
                        for (int i = 0; i < list.getLength(); i++) {
                            Node node = list.item(i);
                            XmlSchemaObject referenced = references.get(node);
                            if (referenced != null) {
                                if (isList) {
                                    XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) object;
                                    xmlSchemaSequence.getItems().add(referenced);
                                } else {
                                    object = referenced;
                                }
                            }
                        }
                    }
                }
                return object;
            }
        }
    } catch (Exception e) {
        // TODO: handle exception
        e.printStackTrace();
    }
    return super.getXmlSchemaObject(collection, schema);
}
Also used : HashMap(java.util.HashMap) Node(org.w3c.dom.Node) Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Document(org.w3c.dom.Document) EngineException(com.twinsoft.convertigo.engine.EngineException) StepSource(com.twinsoft.convertigo.beans.core.StepSource) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject)

Example 9 with StepSource

use of com.twinsoft.convertigo.beans.core.StepSource in project convertigo by convertigo.

the class TransactionStep method getConnectionStringValue.

public String getConnectionStringValue() throws EngineException {
    String connectionStringValue = "";
    if (connectionStringDefinition.size() != 0) {
        StepSource source = new StepSource(this, connectionStringDefinition);
        Object value = source.getContextValues();
        if (value != null) {
            if (value instanceof NodeList) {
                NodeList list = (NodeList) value;
                if ((list != null) && (list.getLength() > 0)) {
                    connectionStringValue = getNodeValue(list.item(0));
                }
            } else {
                connectionStringValue = value.toString();
            }
        }
    }
    return connectionStringValue;
}
Also used : StepSource(com.twinsoft.convertigo.beans.core.StepSource) NodeList(org.w3c.dom.NodeList)

Example 10 with StepSource

use of com.twinsoft.convertigo.beans.core.StepSource in project convertigo by convertigo.

the class ShowStepInPickerAction method run2.

@Override
protected void run2() throws Exception {
    try {
        WrapDatabaseObject treeObject = (WrapDatabaseObject) studio.getFirstSelectedTreeObject();
        if (treeObject != null) {
            if (treeObject.instanceOf(DatabaseObject.class)) {
                DatabaseObject selectedDbo = ((DatabaseObjectView) treeObject).getObject();
                if (selectedDbo != null) {
                    StepSourceEventWrap event = null;
                    if (showSource) {
                        if (selectedDbo instanceof Step) {
                            Step step = (Step) selectedDbo;
                            Set<StepSource> sources = step.getSources();
                            if (!sources.isEmpty()) {
                                event = new StepSourceEventWrap(sources.iterator().next());
                            } else {
                                throw new Exception("No Source defined");
                            }
                        }
                    } else {
                        event = new StepSourceEventWrap(selectedDbo);
                    }
                    if (event != null) {
                        SourcePickerViewWrap spv = studio.getSourcePickerView();
                        spv.sourceSelected(event);
                    }
                }
            }
        }
    } catch (Exception e) {
        throw e;
    // ConvertigoPlugin.logException(e, "Unable to show object in Picker!");
    }
}
Also used : StepSource(com.twinsoft.convertigo.beans.core.StepSource) SourcePickerViewWrap(com.twinsoft.convertigo.engine.studio.views.sourcepicker.SourcePickerViewWrap) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) WrapDatabaseObject(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.WrapDatabaseObject) DatabaseObjectView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.DatabaseObjectView) StepSourceEventWrap(com.twinsoft.convertigo.engine.studio.views.projectexplorer.StepSourceEventWrap) WrapDatabaseObject(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.WrapDatabaseObject) Step(com.twinsoft.convertigo.beans.core.Step)

Aggregations

StepSource (com.twinsoft.convertigo.beans.core.StepSource)18 NodeList (org.w3c.dom.NodeList)7 EngineException (com.twinsoft.convertigo.engine.EngineException)5 Step (com.twinsoft.convertigo.beans.core.Step)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 CommunicationException (javapns.communication.exceptions.CommunicationException)3 KeystoreException (javapns.communication.exceptions.KeystoreException)3 JSONException (org.codehaus.jettison.json.JSONException)3 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)2 Undefined (org.mozilla.javascript.Undefined)2 Message (com.google.android.gcm.server.Message)1 MulticastResult (com.google.android.gcm.server.MulticastResult)1 Result (com.google.android.gcm.server.Result)1 Sender (com.google.android.gcm.server.Sender)1 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)1 OutputFilter (com.twinsoft.convertigo.beans.core.Sequence.OutputFilter)1 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)1 StepSourceEvent (com.twinsoft.convertigo.eclipse.views.projectexplorer.StepSourceEvent)1 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)1