Search in sources :

Example 1 with StepSourceWrap

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));
            }
        }
    }
}
Also used : CheStudio(com.twinsoft.convertigo.engine.studio.CheStudio) XMLVector(com.twinsoft.convertigo.beans.common.XMLVector) SetPropertyResponse(com.twinsoft.convertigo.engine.studio.responses.SetPropertyResponse) HttpSession(javax.servlet.http.HttpSession) Element(org.w3c.dom.Element) SourcePickerViewWrap(com.twinsoft.convertigo.engine.studio.views.sourcepicker.SourcePickerViewWrap) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStepSourceContainer(com.twinsoft.convertigo.beans.core.IStepSourceContainer) StepSourceWrap(com.twinsoft.convertigo.engine.studio.dnd.StepSourceWrap)

Example 2 with StepSourceWrap

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;
}
Also used : ArrayList(java.util.ArrayList) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Step(com.twinsoft.convertigo.beans.core.Step) StepVariable(com.twinsoft.convertigo.beans.variables.StepVariable) IStepSourceContainer(com.twinsoft.convertigo.beans.core.IStepSourceContainer) StepSourceWrap(com.twinsoft.convertigo.engine.studio.dnd.StepSourceWrap)

Example 3 with StepSourceWrap

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)));
        }
    }
}
Also used : CheStudio(com.twinsoft.convertigo.engine.studio.CheStudio) HttpSession(javax.servlet.http.HttpSession) SourcePickerViewWrap(com.twinsoft.convertigo.engine.studio.views.sourcepicker.SourcePickerViewWrap) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) StepSourceWrap(com.twinsoft.convertigo.engine.studio.dnd.StepSourceWrap)

Aggregations

DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)3 StepSourceWrap (com.twinsoft.convertigo.engine.studio.dnd.StepSourceWrap)3 IStepSourceContainer (com.twinsoft.convertigo.beans.core.IStepSourceContainer)2 CheStudio (com.twinsoft.convertigo.engine.studio.CheStudio)2 SourcePickerViewWrap (com.twinsoft.convertigo.engine.studio.views.sourcepicker.SourcePickerViewWrap)2 HttpSession (javax.servlet.http.HttpSession)2 XMLVector (com.twinsoft.convertigo.beans.common.XMLVector)1 Step (com.twinsoft.convertigo.beans.core.Step)1 StepVariable (com.twinsoft.convertigo.beans.variables.StepVariable)1 SetPropertyResponse (com.twinsoft.convertigo.engine.studio.responses.SetPropertyResponse)1 ArrayList (java.util.ArrayList)1 Element (org.w3c.dom.Element)1