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;
}
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;
}
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);
}
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;
}
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!");
}
}
Aggregations