Search in sources :

Example 6 with Project

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

the class NgxPickerContentProvider method addSequences.

private void addSequences(Map<String, Set<String>> map, TVObject tvs, Object object, boolean isReferenced) {
    if (object != null) {
        if (object instanceof Project) {
            Project project = (Project) object;
            for (Sequence s : project.getSequencesList()) {
                String label = isReferenced ? s.getQName() : s.getName();
                SourceData sd = null;
                try {
                    sd = Filter.Sequence.toSourceData(new JSONObject().put("sequence", s.getQName()));
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                tvs.add(new TVObject(label, s, sd));
                Set<String> infos = map.get(s.getQName());
                if (infos != null) {
                    for (String info : infos) {
                        try {
                            JSONObject jsonInfo = new JSONObject(info);
                            if (jsonInfo.has("marker")) {
                                String marker = jsonInfo.getString("marker");
                                if (!marker.isEmpty()) {
                                    sd = Filter.Sequence.toSourceData(new JSONObject().put("sequence", s.getQName()).put("marker", marker));
                                    tvs.add(new TVObject(label + "#" + marker, s, sd, jsonInfo));
                                }
                            }
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
        }
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) JSONObject(org.codehaus.jettison.json.JSONObject) JSONException(org.codehaus.jettison.json.JSONException) Sequence(com.twinsoft.convertigo.beans.core.Sequence) SourceData(com.twinsoft.convertigo.beans.ngx.components.MobileSmartSource.SourceData)

Example 7 with Project

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

the class OpenApiUtils method parse.

public static OpenAPI parse(String requestUrl, UrlMapper urlMapper, boolean useExternalRef) {
    Project project = urlMapper.getProject();
    String projectName = project.getName();
    File targetDir = new File(Engine.PROJECTS_PATH + "/" + projectName + "/" + jsonSchemaDirectory);
    File yamlFile = new File(targetDir, projectName + ".yaml");
    // generate yaml file if needed
    if (Engine.isStudioMode() || !yamlFile.exists()) {
        try {
            writeOpenApiToFile(requestUrl, urlMapper, yamlFile, useExternalRef);
        } catch (Exception e) {
            e.printStackTrace();
            Engine.logEngine.error("Unexpected exception while generating project YAML file", e);
        }
    }
    OpenAPI openAPI = null;
    // read generated yaml file
    try {
        openAPI = readOpenApiFromFile(yamlFile);
    } catch (Exception e) {
        e.printStackTrace();
        Engine.logEngine.error("Unexpected exception while reading project YAML file", e);
    }
    return openAPI;
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) File(java.io.File) OpenAPI(io.swagger.v3.oas.models.OpenAPI) JSONException(org.codehaus.jettison.json.JSONException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 8 with Project

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

the class TransactionStep method getTransactionNames.

public String[] getTransactionNames() {
    try {
        if (!projectName.equals("") && !connectorName.equals("")) {
            Project p = getTargetProject(projectName);
            Connector connector = p.getConnectorByName(connectorName);
            List<Transaction> v = new ArrayList<Transaction>(connector.getTransactionsList());
            v = GenericUtils.cast(sort((Vector<?>) v, true));
            String[] transactionNames = new String[v.size() + 1];
            transactionNames[0] = "";
            int i = 0;
            for (Transaction transaction : v) {
                transactionNames[i + 1] = transaction.getName();
                i++;
            }
            return transactionNames;
        }
    } catch (EngineException e) {
    }
    return new String[] {};
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ArrayList(java.util.ArrayList) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 9 with Project

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

the class TransactionStep method getTagsForProperty.

@Override
public String[] getTagsForProperty(String propertyName) {
    if (propertyName.equals("sourceTransaction")) {
        List<String> transactionsList = new ArrayList<String>();
        try {
            List<String> projectNames = Engine.theApp.databaseObjectsManager.getAllProjectNamesList();
            for (String projectName : projectNames) {
                Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
                List<Connector> connectors = project.getConnectorsList();
                for (Connector connector : connectors) {
                    String connectorName = connector.getName();
                    List<Transaction> transactions = connector.getTransactionsList();
                    for (Transaction transaction : transactions) {
                        transactionsList.add(projectName + SOURCE_SEPARATOR + connectorName + SOURCE_SEPARATOR + transaction.getName());
                    }
                }
            }
        } catch (EngineException e) {
        // Just ignore, should never happen
        }
        return transactionsList.toArray(new String[] {});
    }
    return super.getTagsForProperty(propertyName);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) Transaction(com.twinsoft.convertigo.beans.core.Transaction) ArrayList(java.util.ArrayList) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 10 with Project

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

the class SequenceExecuteSelectedAction method openEditors.

private void openEditors(/*ProjectExplorerView explorerView, */
List<Step> steps, Set<SequenceStep> alreadyOpened) {
    for (Step step : steps) {
        if (step.isEnabled()) {
            if (step instanceof SequenceStep) {
                SequenceStep sequenceStep = (SequenceStep) step;
                String projectName = sequenceStep.getProjectName();
                // load project if necessary
                if (!step.getSequence().getProject().getName().equals(projectName)) {
                // loadProject(explorerView, projectName);
                }
                if (alreadyOpened.contains(sequenceStep)) {
                    // avoid sequence recursion
                    return;
                }
                alreadyOpened.add(sequenceStep);
                try {
                    // ProjectTreeObject projectTreeObject = (ProjectTreeObject)explorerView.getProjectRootObject(projectName);
                    Project p = step.getProject();
                    Sequence subSequence = p.getSequenceByName(sequenceStep.getSequenceName());
                    SequenceView subSequenceTreeObject = (SequenceView) Studio.getViewFromDbo(subSequence, studio);
                    // recurse on sequence
                    openEditors(/*explorerView, */
                    subSequenceTreeObject, alreadyOpened);
                } catch (EngineException e) {
                }
            } else if (step instanceof TransactionStep) {
                TransactionStep transactionStep = (TransactionStep) step;
                String projectName = transactionStep.getProjectName();
                if (!step.getSequence().getProject().getName().equals(projectName)) {
                // loadProject(explorerView, projectName); // load project if necessary
                }
                try {
                    // ProjectTreeObject projectTreeObject = (ProjectTreeObject)explorerView.getProjectRootObject(projectName);
                    Project project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
                    ProjectView projectTreeObject = new ProjectView(project, studio);
                    Connector connector = projectTreeObject.getObject().getConnectorByName(transactionStep.getConnectorName());
                    ConnectorView connectorTreeObject = new ConnectorView(connector, studio);
                    // open connector editor
                    connectorTreeObject.openConnectorEditor();
                } catch (EngineException e) {
                }
            } else if (step instanceof StepWithExpressions) {
                openEditors(/*explorerView, */
                ((StepWithExpressions) step).getSteps(), alreadyOpened);
            }
        }
    }
}
Also used : TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) SequenceView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.SequenceView) ConnectorView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.ConnectorView) EngineException(com.twinsoft.convertigo.engine.EngineException) StepWithExpressions(com.twinsoft.convertigo.beans.core.StepWithExpressions) Step(com.twinsoft.convertigo.beans.core.Step) SequenceStep(com.twinsoft.convertigo.beans.steps.SequenceStep) TransactionStep(com.twinsoft.convertigo.beans.steps.TransactionStep) Sequence(com.twinsoft.convertigo.beans.core.Sequence) ProjectView(com.twinsoft.convertigo.engine.studio.views.projectexplorer.model.ProjectView)

Aggregations

Project (com.twinsoft.convertigo.beans.core.Project)148 EngineException (com.twinsoft.convertigo.engine.EngineException)56 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)47 IOException (java.io.IOException)39 File (java.io.File)37 Sequence (com.twinsoft.convertigo.beans.core.Sequence)35 Connector (com.twinsoft.convertigo.beans.core.Connector)33 ArrayList (java.util.ArrayList)29 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)26 JSONException (org.codehaus.jettison.json.JSONException)26 Transaction (com.twinsoft.convertigo.beans.core.Transaction)24 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)22 SAXException (org.xml.sax.SAXException)21 CoreException (org.eclipse.core.runtime.CoreException)20 Step (com.twinsoft.convertigo.beans.core.Step)19 Element (org.w3c.dom.Element)19 Shell (org.eclipse.swt.widgets.Shell)18 JSONObject (org.codehaus.jettison.json.JSONObject)17 IProject (org.eclipse.core.resources.IProject)17 Cursor (org.eclipse.swt.graphics.Cursor)17