Search in sources :

Example 1 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class ImportWizard method performFinish.

/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.Wizard#performFinish()
	 */
public boolean performFinish() {
    ProjectExplorerView explorerView = ConvertigoPlugin.getDefault().getProjectExplorerView();
    ProjectUrlParser parser = fileChooserPage.getParser();
    String filePath = fileChooserPage.getFilePath();
    if (parser.isValid()) {
        ConvertigoPlugin.infoMessageBox("Loading " + parser.getProjectName() + " in a background job.");
        Job.create("Import project " + parser.getProjectName(), (mon) -> {
            try {
                Project project = Engine.theApp.referencedProjectManager.importProject(parser, true);
                if (project != null) {
                    TreeObject tree = explorerView.getProjectRootObject(project.getName());
                    if (tree != null) {
                        explorerView.reloadProject(tree);
                    }
                    explorerView.refreshProjects();
                }
            } catch (Exception e) {
                Engine.logStudio.debug("Loading from remote URL failed", e);
            }
        }).schedule();
    }
    try {
        if (explorerView != null) {
            if (filePath != null) {
                explorerView.importProject(filePath, getTargetProjectName());
            }
        }
    } catch (Exception e) {
        ConvertigoPlugin.logException(e, "Unable to import project !");
    }
    return true;
}
Also used : IWizardPage(org.eclipse.jface.wizard.IWizardPage) Job(org.eclipse.core.runtime.jobs.Job) Engine(com.twinsoft.convertigo.engine.Engine) DatabaseObjectsManager(com.twinsoft.convertigo.engine.DatabaseObjectsManager) IOException(java.io.IOException) Wizard(org.eclipse.jface.wizard.Wizard) ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) IImportWizard(org.eclipse.ui.IImportWizard) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) File(java.io.File) Project(com.twinsoft.convertigo.beans.core.Project) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ConvertigoPlugin(com.twinsoft.convertigo.eclipse.ConvertigoPlugin) ZipUtils(com.twinsoft.convertigo.engine.util.ZipUtils) IWorkbench(org.eclipse.ui.IWorkbench) EngineException(com.twinsoft.convertigo.engine.EngineException) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) Project(com.twinsoft.convertigo.beans.core.Project) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) IOException(java.io.IOException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 2 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class NewProjectWizard method setInitializationData.

@Override
public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
    String value = config.getValue();
    try {
        wizardId = config.getAttribute("id");
        JSONObject json = new JSONObject(value);
        String url = json.getString("url");
        projectUrlParser = new ProjectUrlParser(url);
        projectName = projectUrlParser.getProjectName();
        doPage1 = json.has("doPage1") && json.getBoolean("doPage1");
        doPage2 = json.has("doPage2") && json.getBoolean("doPage2");
        doPage4 = json.has("doPage4") && json.getBoolean("doPage4");
        doPage5 = json.has("doPage5") && json.getBoolean("doPage5");
        doPage6 = json.has("doPage6") && json.getBoolean("doPage6");
        doPage7 = json.has("doPage7") && json.getBoolean("doPage7");
        doPage8 = json.has("doPage8") && json.getBoolean("doPage8");
        doPage9 = json.has("doPage9") && json.getBoolean("doPage9");
        doPage10 = json.has("doPage10") && json.getBoolean("doPage10");
        doPage11 = json.has("doPage11") && json.getBoolean("doPage11");
        doPageSummarySampleProject = json.has("doPageSummarySampleProject") && json.getBoolean("doPageSummarySampleProject");
        doConfigureSQLConnectorPage = json.has("doConfigureSQLConnectorPage") && json.getBoolean("doConfigureSQLConnectorPage");
        doConfigureSAPConnectorPage = json.has("doConfigureSAPConnectorPage") && json.getBoolean("doConfigureSAPConnectorPage");
    } catch (JSONException e) {
    }
}
Also used : ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) JSONObject(org.codehaus.jettison.json.JSONObject) JSONException(org.codehaus.jettison.json.JSONException)

Example 3 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class ReferencedProjectManager method check.

private boolean check(Map<String, ProjectUrlParser> refs) {
    List<String> loaded = new LinkedList<>();
    for (Entry<String, ProjectUrlParser> entry : refs.entrySet()) {
        String projectName = entry.getKey();
        try {
            ProjectUrlParser parser = entry.getValue();
            Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(parser.getProjectName(), false);
            Project nProject = importProject(parser);
            if (nProject != null && nProject != project) {
                loaded.add(projectName);
            }
        } catch (Exception e) {
            Engine.logEngine.warn("(ReferencedProjectManager) Failed to load '" + projectName + "'", e);
        }
    }
    if (!loaded.isEmpty()) {
        check(loaded);
        return true;
    }
    return false;
}
Also used : ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) Project(com.twinsoft.convertigo.beans.core.Project) LinkedList(java.util.LinkedList)

Example 4 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class ImportURL method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    String error = null;
    try {
        String url = request.getParameter("url");
        ProjectUrlParser parser = new ProjectUrlParser(url);
        if (parser.isValid()) {
            Project project;
            if ((project = Engine.theApp.referencedProjectManager.importProject(parser, true)) == null) {
                error = "No project loaded with: " + url;
            } else {
                String projectName = project.getName();
                Project.executeAutoStartSequences(projectName);
            }
        } else {
            error = "The format is invalid";
        }
    } catch (Exception e) {
        error = "Failed to import project from URL, " + e.getClass().getSimpleName() + ": " + e.getMessage();
        Engine.logAdmin.warn(error, e);
    }
    Element root = document.getDocumentElement();
    Element elt;
    if (error == null) {
        elt = document.createElement("success");
        elt.setTextContent("true");
    } else {
        elt = document.createElement("error");
        elt.setTextContent(error);
    }
    root.appendChild(elt);
}
Also used : ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) Project(com.twinsoft.convertigo.beans.core.Project) Element(org.w3c.dom.Element)

Example 5 with ProjectUrlParser

use of com.twinsoft.convertigo.engine.util.ProjectUrlParser in project convertigo by convertigo.

the class ImportWizardPage method updateStatus.

private void updateStatus() {
    String message = null;
    ProjectUrlParser parser = getParser();
    if (parser != null) {
        if (StringUtils.isEmpty(parser.getProjectUrl())) {
            if (filePath.equals("")) {
                message = "Please select a file";
            } else if (!Engine.isProjectFile(filePath) && !filePath.endsWith(".car") && !filePath.endsWith(".zip")) {
                message = "Please select a compatible file extension";
            } else if (!new File(filePath).exists()) {
                message = "Please select an existing compatible file";
            } else {
                try {
                    String projectName = DatabaseObjectsManager.getProjectName(new File(filePath));
                    if (StringUtils.isNotBlank(projectName)) {
                        setMessage("Current project to import is '" + projectName + "'.");
                    }
                } catch (Exception e) {
                }
            }
        }
    }
    setErrorMessage(message);
    setPageComplete(message == null);
}
Also used : ProjectUrlParser(com.twinsoft.convertigo.engine.util.ProjectUrlParser) File(java.io.File)

Aggregations

ProjectUrlParser (com.twinsoft.convertigo.engine.util.ProjectUrlParser)10 Project (com.twinsoft.convertigo.beans.core.Project)5 ProjectSchemaReference (com.twinsoft.convertigo.beans.references.ProjectSchemaReference)2 ConvertigoPlugin (com.twinsoft.convertigo.eclipse.ConvertigoPlugin)2 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)2 Engine (com.twinsoft.convertigo.engine.Engine)2 EngineException (com.twinsoft.convertigo.engine.EngineException)2 File (java.io.File)2 HashMap (java.util.HashMap)2 IPath (org.eclipse.core.runtime.IPath)2 Path (org.eclipse.core.runtime.Path)2 CouchDbConnector (com.twinsoft.convertigo.beans.connectors.CouchDbConnector)1 Connector (com.twinsoft.convertigo.beans.core.Connector)1 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)1 Reference (com.twinsoft.convertigo.beans.core.Reference)1 RequestableStep (com.twinsoft.convertigo.beans.core.RequestableStep)1 Sequence (com.twinsoft.convertigo.beans.core.Sequence)1 Step (com.twinsoft.convertigo.beans.core.Step)1 StepWithExpressions (com.twinsoft.convertigo.beans.core.StepWithExpressions)1 Transaction (com.twinsoft.convertigo.beans.core.Transaction)1