use of com.twinsoft.convertigo.engine.studio.dnd.StepSourceWrap 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));
}
}
}
}
use of com.twinsoft.convertigo.engine.studio.dnd.StepSourceWrap in project convertigo by convertigo.
the class CanCreateSource method canCreateSource.
public static boolean canCreateSource(Object obj, StepSourceWrap ssw) {
// if (target instanceof TreeObject) {
// TreeObject targetTreeObject = (TreeObject) target;
// Check for drop to a step which contains a stepSource definition
// if (targetTreeObject.getObject() instanceof IStepSourceContainer) {
DatabaseObject targetDbo = (DatabaseObject) obj;
if (targetDbo instanceof Step && ((Step) targetDbo).canWorkOnSource() || targetDbo instanceof IStepSourceContainer) {
// StepSourceTransfer.getInstance().getStepSource();
StepSourceWrap stepSource = ssw;
if (stepSource != null) {
Step targetStep = (Step) ((targetDbo instanceof StepVariable) ? ((StepVariable) targetDbo).getParent() : targetDbo);
// 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<DatabaseObject> siblings = new ArrayList<>();
getNextSiblings(siblings, targetDbo.getProject(), sourceStep);
// System.out.println("siblings: "+siblings.toString());
return siblings.contains(targetDbo);
} catch (Exception e) {
e.printStackTrace(System.out);
}
;
}
}
}
// }
return false;
}
use of com.twinsoft.convertigo.engine.studio.dnd.StepSourceWrap in project convertigo by convertigo.
the class CanCreateSource method getServiceResult.
@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
HttpSession session = request.getSession();
CheStudio cheStudio = CallAction.getStudio(session);
if (cheStudio != null) {
SourcePickerViewWrap spv = cheStudio.getSourcePickerView();
if (spv != null) {
String qname = request.getParameter("qname");
DatabaseObject dbo = Engine.theApp.databaseObjectsManager.getDatabaseObjectByQName(qname);
StepSourceWrap ssw = (StepSourceWrap) spv.getDragData();
boolean canCreateSource = canCreateSource(dbo, ssw);
document.getDocumentElement().appendChild(DOMUtils.createElementWithText(document, "response", Boolean.toString(canCreateSource)));
}
}
}
Aggregations