Search in sources :

Example 96 with Project

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

the class NewProjectWizard method doFinish.

/**
 * The worker method. We create the project here according to the templateId
 * variable
 */
private void doFinish(IProgressMonitor monitor) throws CoreException {
    try {
        if (page10 != null) {
            projectName = page1.getProjectName();
            monitor.beginTask("Creating project " + projectName, 7);
            Project project = createFromBlankProject(monitor, false);
            boolean needAuth = page10.useAuthentication();
            String wsURL = page10.getWsdlURL().toString();
            String login = page10.getLogin();
            String password = page10.getPassword();
            WebServiceReference webWsReference = null;
            RestServiceReference restWsReference = null;
            RemoteFileReference reference = null;
            if (wizardId.equals("com.twinsoft.convertigo.eclipse.wizards.NewWebServiceSoapReferenceWizard")) {
                reference = webWsReference = new WebServiceReference();
            } else if (wizardId.equals("com.twinsoft.convertigo.eclipse.wizards.NewWebServiceSwaggerReferenceWizard")) {
                reference = restWsReference = new RestServiceReference();
            }
            reference.setUrlpath(wsURL);
            reference.setNeedAuthentication(needAuth);
            reference.setAuthUser(login == null ? "" : login);
            reference.setAuthUser(password == null ? "" : password);
            reference.bNew = true;
            ImportWsReference wsr = webWsReference != null ? new ImportWsReference(webWsReference) : new ImportWsReference(restWsReference);
            HttpConnector httpConnector = wsr.importInto(project);
            if (httpConnector != null) {
                Connector defaultConnector = project.getDefaultConnector();
                project.setDefaultConnector(httpConnector);
                defaultConnector.delete();
                project.hasChanged = true;
            }
            updateProjectTreeView();
        } else if (page1 != null) {
            projectName = page1.getProjectName();
            monitor.beginTask("Creating project " + projectName, 7);
            createFromBlankProject(monitor);
            return;
        } else if (pageSummarySampleProject != null) {
            monitor.beginTask("Creating project", 7);
            createFromArchiveProject(monitor);
            return;
        }
    } catch (Exception e) {
        ConvertigoPlugin.logException(e, "An error occured while creating the project", false);
        String message = "An error occured while creating the project (see Error log):\n" + e.getMessage();
        IStatus status = new Status(Status.ERROR, ConvertigoPlugin.PLUGIN_UNIQUE_ID, message, e);
        throw new CoreException(status);
    }
}
Also used : RestServiceReference(com.twinsoft.convertigo.beans.references.RestServiceReference) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) Connector(com.twinsoft.convertigo.beans.core.Connector) SapJcoConnector(com.twinsoft.convertigo.beans.connectors.SapJcoConnector) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) JSONException(org.codehaus.jettison.json.JSONException) EngineException(com.twinsoft.convertigo.engine.EngineException) Project(com.twinsoft.convertigo.beans.core.Project) CoreException(org.eclipse.core.runtime.CoreException) RemoteFileReference(com.twinsoft.convertigo.beans.references.RemoteFileReference) ImportWsReference(com.twinsoft.convertigo.engine.util.ImportWsReference) WebServiceReference(com.twinsoft.convertigo.beans.references.WebServiceReference)

Example 97 with Project

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

the class NewProjectWizard method createFromBlankProject.

private Project createFromBlankProject(IProgressMonitor monitor, boolean updateTreeView) throws Exception {
    String newProjectName = projectName;
    String oldProjectName = projectUrlParser.getProjectName();
    monitor.setTaskName("Creating new project");
    monitor.worked(1);
    if (Engine.theApp.databaseObjectsManager.existsProject(newProjectName)) {
        throw new EngineException("Unable to create new project ! A project with the same name (\"" + newProjectName + "\") already exists.");
    }
    monitor.setTaskName("Loading the projet");
    monitor.worked(1);
    projectUrlParser.setProjectName(projectName);
    Project newProject = Engine.theApp.referencedProjectManager.importProject(projectUrlParser, true);
    monitor.worked(1);
    try {
        // set values of elements to configure on the new project
        String newEmulatorTechnology = "";
        String emulatorTechnologyName = "";
        String newIbmTerminalType = "";
        switch(wizardId) {
            case "com.twinsoft.convertigo.eclipse.wizards.New3270ConnectorWizard":
            case "com.twinsoft.convertigo.eclipse.wizards.New3270WebWizard":
                newEmulatorTechnology = Session.SNA;
                newIbmTerminalType = "IBM-3279";
                emulatorTechnologyName = "IBM3270";
                break;
            case "com.twinsoft.convertigo.eclipse.wizards.New5250ConnectorWizard":
            case "com.twinsoft.convertigo.eclipse.wizards.New5250WebWizard":
                newEmulatorTechnology = Session.AS400;
                newIbmTerminalType = "IBM-3179";
                emulatorTechnologyName = "IBM5250";
                break;
            case "com.twinsoft.convertigo.eclipse.wizards.NewDKUConnectorWizard":
            case "com.twinsoft.convertigo.eclipse.wizards.NewDKUWebWizard":
                newEmulatorTechnology = Session.DKU;
                emulatorTechnologyName = "BullDKU7107";
                break;
            case "com.twinsoft.convertigo.eclipse.wizards.NewVT220ConnectorWizard":
                newEmulatorTechnology = Session.VT;
                emulatorTechnologyName = "UnixVT220";
                break;
        }
        monitor.setTaskName("Reset project version");
        monitor.worked(1);
        newProject.setVersion("");
        monitor.setTaskName("Change connector name");
        monitor.worked(1);
        String oldConnectorName = "void";
        String newConnectorName = "void";
        boolean connectorChanged = false;
        if (page2 != null) {
            newConnectorName = page2.getConnectorName();
            monitor.setTaskName("Connector renamed");
            monitor.worked(1);
            oldConnectorName = newProject.getDefaultConnector().getName();
            newProject.getDefaultConnector().setName(newConnectorName);
            connectorChanged = true;
        }
        if (page5 != null) {
            CicsConnector cicsConnector = (CicsConnector) newProject.getDefaultConnector();
            monitor.setTaskName("Update connector mainframe name");
            monitor.worked(1);
            cicsConnector.setMainframeName(page5.getCtgName());
            monitor.setTaskName("Update connector server");
            monitor.worked(1);
            cicsConnector.setServer(page5.getCtgServer());
            monitor.setTaskName("Update connector port");
            monitor.worked(1);
            try {
                cicsConnector.setPort(Integer.parseInt(page5.getCtgPort()));
            } catch (Exception e) {
            }
        }
        if (page6 != null) {
            monitor.setTaskName("Update connector server");
            monitor.worked(1);
            // change connector server and port,
            // change https mode
            // and change proxy server and proxy port
            HttpConnector httpConnector = (HttpConnector) newProject.getDefaultConnector();
            httpConnector.setServer(page6.getHttpServer());
            monitor.setTaskName("Update connector port");
            monitor.worked(1);
            try {
                httpConnector.setPort(Integer.parseInt(page6.getHttpPort()));
            } catch (Exception e) {
            }
            monitor.setTaskName("Update connector https mode");
            monitor.worked(1);
            httpConnector.setHttps(page6.isBSSL());
        }
        if (page7 != null) {
            // change emulator technology
            // and change service code
            monitor.setTaskName("Set connector service code");
            monitor.worked(1);
            JavelinConnector javelinConnector = (JavelinConnector) newProject.getDefaultConnector();
            javelinConnector.setServiceCode(page7.getServiceCode());
            monitor.setTaskName("Set connector emulator technology");
            monitor.worked(1);
            javelinConnector.setEmulatorTechnology(newEmulatorTechnology);
            monitor.setTaskName("Set terminal type");
            monitor.worked(1);
            javelinConnector.setIbmTerminalType(newIbmTerminalType);
            // rename emulatorTechnology criteria
            monitor.setTaskName("Rename emulator technology criteria");
            monitor.worked(1);
            javelinConnector.getDefaultScreenClass().getLocalCriterias().get(0).setName(emulatorTechnologyName);
        }
        if (page11 != null) {
            SiteClipperConnector scConnector = (SiteClipperConnector) newProject.getDefaultConnector();
            monitor.setTaskName("Update connector certificates policy");
            monitor.worked(1);
            scConnector.setTrustAllServerCertificates(page11.isTrustAllServerCertificates());
            monitor.setTaskName("Update host url");
            monitor.worked(1);
            scConnector.getDefaultTransaction().setTargetURL(page11.getTargetURL());
        }
        if (configureSQLConnectorPage != null) {
            SqlConnector sqlConnector = (SqlConnector) newProject.getDefaultConnector();
            monitor.setTaskName("Update JDBC URL");
            monitor.worked(1);
            sqlConnector.setJdbcURL(configureSQLConnectorPage.getJdbcURL());
            monitor.setTaskName("Update JDBC driver");
            monitor.worked(1);
            sqlConnector.setJdbcDriverClassName(configureSQLConnectorPage.getJdbcDriver());
            monitor.setTaskName("Update Username");
            monitor.worked(1);
            sqlConnector.setJdbcUserName(configureSQLConnectorPage.getUsername());
            monitor.setTaskName("Update Password");
            monitor.worked(1);
            sqlConnector.setJdbcUserPassword(configureSQLConnectorPage.getPassword());
        }
        if (configureSAPConnectorPage != null) {
            SapJcoConnector sapConnector = (SapJcoConnector) newProject.getDefaultConnector();
            // Application Server Host
            monitor.setTaskName("Update application Server Host");
            monitor.worked(1);
            sapConnector.setAsHost(configureSAPConnectorPage.getAsHost());
            // System Number
            monitor.setTaskName("Update system number");
            monitor.worked(1);
            sapConnector.setSystemNumber(configureSAPConnectorPage.getSystemNumber());
            // Client
            monitor.setTaskName("Update client");
            monitor.worked(1);
            sapConnector.setClient(configureSAPConnectorPage.getClient());
            // User
            monitor.setTaskName("Update user");
            monitor.worked(1);
            sapConnector.setUser(configureSAPConnectorPage.getUser());
            // Password
            monitor.setTaskName("Update password");
            monitor.worked(1);
            sapConnector.setPassword(configureSAPConnectorPage.getPassword());
            // Language
            monitor.setTaskName("Update language");
            monitor.worked(1);
            sapConnector.setLanguage(configureSAPConnectorPage.getLanguage());
        }
        monitor.setTaskName("Saving updated project");
        monitor.worked(1);
        Engine.theApp.databaseObjectsManager.exportProject(newProject);
        monitor.setTaskName("New project saved");
        monitor.worked(1);
        try {
            File eProject = new File(newProject.getDirPath(), ".project");
            if (eProject.exists()) {
                String txt = FileUtils.readFileToString(eProject, StandardCharsets.UTF_8);
                txt = txt.replaceFirst("(<name>)(.*?)(</name>)", "$1" + newProjectName + "$3");
                FileUtils.writeStringToFile(eProject, txt, StandardCharsets.UTF_8);
            }
            String xsdInternalPath = newProject.getDirPath() + "/" + Project.XSD_FOLDER_NAME + "/" + Project.XSD_INTERNAL_FOLDER_NAME;
            File xsdInternalDir = new File(xsdInternalPath).getCanonicalFile();
            if (xsdInternalDir.exists() && connectorChanged) {
                boolean needConnectorRename = !oldConnectorName.equals(newConnectorName);
                if (needConnectorRename) {
                    File srcDir = new File(xsdInternalDir, oldConnectorName);
                    File destDir = new File(xsdInternalDir, newConnectorName);
                    if (oldConnectorName.equalsIgnoreCase(newConnectorName)) {
                        File destDirTmp = new File(xsdInternalDir, "tmp" + oldConnectorName).getCanonicalFile();
                        FileUtils.moveDirectory(srcDir, destDirTmp);
                        srcDir = destDirTmp;
                    }
                    FileUtils.moveDirectory(srcDir, destDir);
                }
                for (File connectorDir : xsdInternalDir.listFiles()) {
                    if (connectorDir.isDirectory()) {
                        String connectorName = connectorDir.getName();
                        for (File transactionXsdFile : connectorDir.listFiles()) {
                            String xsdFilePath = transactionXsdFile.getCanonicalPath();
                            ProjectUtils.xsdRenameProject(xsdFilePath, oldProjectName, newProjectName);
                            if (needConnectorRename && connectorName.equals(newConnectorName)) {
                                ProjectUtils.xsdRenameConnector(xsdFilePath, oldConnectorName, newConnectorName);
                            }
                        }
                    }
                }
            }
            monitor.setTaskName("Schemas updated");
            monitor.worked(1);
            if (updateTreeView) {
                updateProjectTreeView();
            }
        } catch (Exception e) {
            Engine.logDatabaseObjectManager.error("An error occured while updating transaction schemas", e);
        }
    } catch (Exception e) {
        // Delete everything
        try {
            Engine.logBeans.error("An error occured while creating project, everything will be deleted. Please see Studio logs for more informations.", null);
            // TODO : see if we can delete oldProjectName : a real project
            // could exist with this oldProjectName ?
            // Engine.theApp.databaseObjectsManager.deleteProject(oldProjectName,
            // false, false);
            Engine.theApp.databaseObjectsManager.deleteProject(newProjectName, false, false);
            projectName = null;
        } catch (Exception ex) {
        }
        throw new Exception("Unable to create project from template", e);
    }
    return newProject;
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) JavelinConnector(com.twinsoft.convertigo.beans.connectors.JavelinConnector) HttpConnector(com.twinsoft.convertigo.beans.connectors.HttpConnector) SiteClipperConnector(com.twinsoft.convertigo.beans.connectors.SiteClipperConnector) CicsConnector(com.twinsoft.convertigo.beans.connectors.CicsConnector) SapJcoConnector(com.twinsoft.convertigo.beans.connectors.SapJcoConnector) EngineException(com.twinsoft.convertigo.engine.EngineException) SqlConnector(com.twinsoft.convertigo.beans.connectors.SqlConnector) File(java.io.File) CoreException(org.eclipse.core.runtime.CoreException) InvocationTargetException(java.lang.reflect.InvocationTargetException) JSONException(org.codehaus.jettison.json.JSONException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 98 with Project

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

the class XPathToCheck method migrate.

public static void migrate(String projectName) {
    try {
        Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName, false);
        MobileApplication mobileApplication = project.getMobileApplication();
        if (mobileApplication != null) {
            TwsCachedXPathAPI xpathApi = new TwsCachedXPathAPI();
            // Tags to change for all platforms
            List<XPathToCheck> xPathToCheckDefault = new LinkedList<XPathToCheck>();
            xPathToCheckDefault.add(new XPathToCheck("/widget/preference[@name='phonegap-version']", "", true));
            xPathToCheckDefault.add(new XPathToCheck("/widget/preference[@name='SplashScreen']", "", true));
            xPathToCheckDefault.add(new XPathToCheck("/widget/preference[@name='ShowSplashScreenSpinner']", "", true));
            String[][] pluginList = new String[][] { { "org.apache.cordova.device", "org.apache.cordova.file", "org.apache.cordova.file-transfer", "org.apache.cordova.splashscreen", "cordova-plugin-whitelist", "org.apache.cordova.console" }, { "cordova-plugin-device", "cordova-plugin-file", "cordova-plugin-file-transfer", "cordova-plugin-splashscreen", "cordova-plugin-whitelist", "cordova-plugin-console" } };
            for (int i = 0; i < pluginList[0].length; i++) {
                xPathToCheckDefault.add(new XPathToCheck("/widget/*[local-name()='plugin' and @name='" + pluginList[0][i] + "']", "/widget/plugin[@name='" + pluginList[1][i] + "']", true));
                xPathToCheckDefault.add(new XPathToCheck("/widget/*[local-name()='plugin' and @name='" + pluginList[1][i] + "']", "/widget/plugin[@name='" + pluginList[1][i] + "']", true));
            }
            pluginList = new String[][] { { "com.couchbase.lite.phonegap", "org.apache.cordova.battery-status", "org.apache.cordova.camera", "org.apache.cordova.media-capture", "org.apache.cordova.contacts", "org.apache.cordova.device-motion", "org.apache.cordova.device-orientation", "org.apache.cordova.dialogs", "org.apache.cordova.geolocation", "org.apache.cordova.globalization", "org.apache.cordova.inappbrowser", "org.apache.cordova.media", "org.apache.cordova.network-information", "org.apache.cordova.vibration", "org.apache.cordova.statusbar", "com.phonegap.plugins.pushplugin", "com.phonegap.plugins.barcodescanner" }, { "couchbase-lite-phonegap-plugin", "cordova-plugin-battery-status", "cordova-plugin-camera", "cordova-plugin-media-capture", "cordova-plugin-contacts", "cordova-plugin-device-motion", "cordova-plugin-device-orientation", "cordova-plugin-dialogs", "cordova-plugin-geolocation", "cordova-plugin-globalization", "cordova-plugin-inappbrowser", "cordova-plugin-media", "cordova-plugin-network-information", "cordova-plugin-vibration", "cordova-plugin-statusbar", "phonegap-plugin-push", "phonegap-plugin-barcodescanner" } };
            // Tags to change only for Android
            List<XPathToCheck> xPathToCheckAndroid = new LinkedList<XPathToCheck>();
            xPathToCheckAndroid.addAll(xPathToCheckDefault);
            xPathToCheckAndroid.add(new XPathToCheck("/widget/platform[@name='android' and not(*)]", "/widget/engine[@name='$(CordovaPlatform)$']", true));
            xPathToCheckAndroid.add(new XPathToCheck("/widget/preference[@name='android-minSdkVersion']", "", true));
            xPathToCheckAndroid.add(new XPathToCheck("/widget/preference[@name='android-build-tool']", "", true));
            String[] androidResList = new String[] { "ldpi", "mdpi", "hdpi", "xhdpi" };
            for (String androidRes : androidResList) {
                xPathToCheckAndroid.add(new XPathToCheck("/widget/icon[@gap:platform='android' and @gap:qualifier='" + androidRes + "']", "/widget/platform[@name='android']/icon[@density='" + androidRes + "']", false));
            }
            androidResList = new String[] { "ldpi", "mdpi", "hdpi", "xhdpi", "land-ldpi", "land-mdpi", "land-hdpi", "land-xhdpi" };
            for (String androidRes : androidResList) {
                xPathToCheckAndroid.add(new XPathToCheck("/widget/splash[@gap:platform='android' and @gap:qualifier='" + androidRes + "']", "/widget/platform[@name='android']/splash[@density='" + androidRes + "']", false));
            }
            // Tags to change only for iOS
            List<XPathToCheck> xPathToCheckIOs = new LinkedList<XPathToCheck>();
            xPathToCheckIOs.addAll(xPathToCheckDefault);
            xPathToCheckIOs.add(new XPathToCheck("/widget/platform[@name='ios']", "/widget/engine[@name='$(CordovaPlatform)$']", true));
            xPathToCheckIOs.add(new XPathToCheck("/widget/preference[@name='target-device' and @value='universal']", null, true));
            String[] iosResList = new String[] { "180", "120", "57", "72", "114", "144" };
            for (String iosRes : iosResList) {
                xPathToCheckIOs.add(new XPathToCheck("/widget/icon[@gap:platform='ios' and @width='" + iosRes + "']", "/widget/platform[@name='ios']/icon[@width='" + iosRes + "']", false));
            }
            iosResList = new String[] { "2208", "1334", "1136", "1496", "748", "2008", "1004", "960", "480" };
            for (String iosRes : iosResList) {
                xPathToCheckIOs.add(new XPathToCheck("/widget/splash[@gap:platform='ios' and @height='" + iosRes + "']", "/widget/platform[@name='ios']/splash[@height='" + iosRes + "']", false));
            }
            xPathToCheckIOs.add(new XPathToCheck("/widget/access", "", true));
            // Tags to change only for Windows Phone 8
            List<XPathToCheck> xPathToCheckWinPhone8 = new LinkedList<XPathToCheck>();
            xPathToCheckWinPhone8.addAll(xPathToCheckDefault);
            xPathToCheckWinPhone8.add(new XPathToCheck("/widget/platform[@name='winphone' and not(*)]", "/widget/engine[@name='$(CordovaPlatform)$']", true));
            xPathToCheckWinPhone8.add(new XPathToCheck("/widget/icon[@gap:platform='winphone' and not(@gap:role)]", "/widget/platform[@name='wp8']/icon[not(@role)]", false));
            xPathToCheckWinPhone8.add(new XPathToCheck("/widget/icon[@gap:platform='winphone' and @gap:role='background']", "/widget/platform[@name='wp8']/icon[@role='background']", false));
            xPathToCheckWinPhone8.add(new XPathToCheck("/widget/splash[@gap:platform='winphone']", "/widget/platform[@name='wp8']/splash[@src]", false));
            // Iterates on each platforms
            List<MobilePlatform> mobilePlatformList = mobileApplication.getMobilePlatformList();
            for (MobilePlatform mobilePlatform : mobilePlatformList) {
                // Get the config.xml file and load the xml
                File configFile = new File(mobilePlatform.getResourceFolder(), "config.xml");
                if (configFile.exists()) {
                    Document oldDoc = XMLUtils.loadXml(configFile);
                    // Gets the tags to change depending to the platform
                    List<XPathToCheck> xPathToCheckList = null;
                    String platformName = null;
                    if (mobilePlatform instanceof Android) {
                        xPathToCheckList = xPathToCheckAndroid;
                        platformName = "Android";
                    } else if (mobilePlatform instanceof IOs) {
                        xPathToCheckList = xPathToCheckIOs;
                        platformName = "IOs";
                    } else if (mobilePlatform instanceof WindowsPhone8) {
                        xPathToCheckList = xPathToCheckWinPhone8;
                        platformName = "WindowsPhone8";
                    } else {
                        continue;
                    }
                    // Gets the template config.xml file and load the xml
                    String configTemplatePath = Engine.TEMPLATES_PATH + "/base/DisplayObjects/platforms/" + platformName + "/config.xml";
                    File configTemplateFile = new File(configTemplatePath);
                    if (!configTemplateFile.exists()) {
                        throw new Exception("Can't find template config.xml at " + configTemplatePath);
                    }
                    Document templateDoc = XMLUtils.loadXml(configTemplateFile);
                    for (XPathToCheck xPathToCheck : xPathToCheckList) {
                        Element oldElement = (Element) xpathApi.selectSingleNode(oldDoc, xPathToCheck.oldXpath);
                        // If the goal is to remove the old node
                        if (xPathToCheck.templateXpath == null) {
                            if (oldElement != null) {
                                oldElement.getParentNode().removeChild(oldElement);
                            }
                            continue;
                        }
                        Element templateElement = (Element) xpathApi.selectSingleNode(templateDoc, xPathToCheck.templateXpath);
                        // Can't do anything if the element is not found in the template file
                        if (templateElement == null) {
                            continue;
                        }
                        // Replace the old element by the template
                        if (oldElement != null || xPathToCheck.required) {
                            // If the template is already in the old config.xml
                            Element templateOldElement = (Element) xpathApi.selectSingleNode(oldDoc, xPathToCheck.templateXpath);
                            if (templateOldElement != null && templateElement.isEqualNode(templateOldElement)) {
                                continue;
                            }
                            String xPathTemplateParent = xPathToCheck.templateXpath.substring(0, xPathToCheck.templateXpath.lastIndexOf('/'));
                            Node parentNode = createSameTree(oldDoc, templateElement.getParentNode(), xPathTemplateParent, xpathApi);
                            Node newNode = oldDoc.adoptNode(templateElement.cloneNode(true));
                            if (oldElement != null) {
                                if (parentNode.isSameNode(oldElement.getParentNode())) {
                                    parentNode.replaceChild(newNode, oldElement);
                                } else {
                                    parentNode.appendChild(newNode);
                                    oldElement.getParentNode().removeChild(oldElement);
                                }
                            } else {
                                parentNode.appendChild(newNode);
                            }
                        }
                    }
                    for (int i = 0; i < pluginList[0].length; i++) {
                        Node comment = xpathApi.selectNode(oldDoc, "//comment()[contains(.,\"" + pluginList[1][i] + "\")]");
                        if (comment == null) {
                            comment = xpathApi.selectNode(oldDoc, "//comment()[contains(.,\"" + pluginList[0][i] + "\")]");
                        }
                        if (comment != null) {
                            Node newComment = xpathApi.selectNode(templateDoc, "//comment()[contains(.,\"" + pluginList[1][i] + "\")]");
                            comment.getParentNode().replaceChild(oldDoc.adoptNode(newComment), comment);
                        }
                    }
                    File oldConfigFile = new File(configFile.getParent(), "config.xml.old");
                    if (!oldConfigFile.exists()) {
                        oldConfigFile.createNewFile();
                    }
                    FileUtils.copyFile(configFile, oldConfigFile);
                    File newConfigFile = new File(mobilePlatform.getResourceFolder(), "config.xml");
                    if (!newConfigFile.exists()) {
                        newConfigFile.createNewFile();
                    }
                    XMLUtils.saveXml(oldDoc, newConfigFile.getAbsolutePath());
                }
            }
        }
    } catch (Exception e) {
        Engine.logDatabaseObjectManager.error("[Migration 7.4.0] An error occured while migrating project \"" + projectName + "\"", e);
    }
}
Also used : WindowsPhone8(com.twinsoft.convertigo.beans.mobileplatforms.WindowsPhone8) Element(org.w3c.dom.Element) Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) IOs(com.twinsoft.convertigo.beans.mobileplatforms.IOs) LinkedList(java.util.LinkedList) Android(com.twinsoft.convertigo.beans.mobileplatforms.Android) Project(com.twinsoft.convertigo.beans.core.Project) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) File(java.io.File) TwsCachedXPathAPI(com.twinsoft.convertigo.engine.util.TwsCachedXPathAPI)

Example 99 with Project

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

the class DirectoryWatcherService method processFiles.

private synchronized void processFiles() {
    /*
         * Iterate over the set of file to be processed
         */
    for (Iterator<String> it = filesToProcess.iterator(); it.hasNext(); ) {
        String filename = it.next();
        Path p = Paths.get(filename);
        File src = new File(filename);
        String filepath = getFilePath(filename);
        // copy
        if (src.exists()) {
            if (src.isDirectory()) {
                try {
                    registerAll(p);
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            String compName = src.isDirectory() ? p.getFileName().toString() : p.getParent().getFileName().toString();
            if (compName != null) {
                for (String useQName : ComponentRefManager.get(Mode.use).getAllConsumers(getCompQName(compName))) {
                    if (pname(useQName).equals(project.getName()))
                        continue;
                    try {
                        String destSubPath = filepath.substring(filepath.indexOf("_private/ionic/src"));
                        File dest = new File(Engine.projectDir(pname(useQName)), destSubPath);
                        if (!dest.getCanonicalPath().equals(src.getCanonicalPath()) && shouldUpdate(src, dest)) {
                            Engine.logEngine.debug("(DirectoryWatcherService) Copying " + src + " to " + dest);
                            if (src.isDirectory()) {
                                FileUtils.copyDirectory(src, dest, true);
                            } else {
                                FileUtils.copyFile(src, dest, true);
                            }
                            Project dest_project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(pname(useQName), false);
                            if (dest_project != null && dest_project.isMobileBuilderInitialized()) {
                                dest_project.getMobileBuilder().updateEnvFile();
                            }
                        }
                    } catch (Exception e) {
                        Engine.logEngine.warn("(DirectoryWatcherService) unabled to process file '" + filename + "': " + e.getMessage());
                    }
                }
            }
        } else // delete
        {
            Engine.logEngine.debug("(DirectoryWatcherService) Deleted " + filename);
        }
        /*
             * Remove this file from the set.
             */
        it.remove();
    }
}
Also used : Path(java.nio.file.Path) Project(com.twinsoft.convertigo.beans.core.Project) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException)

Example 100 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, String projectName) {
    OpenAPI openAPI;
    Project project;
    try {
        project = Engine.theApp.databaseObjectsManager.getProjectByName(projectName);
        openAPI = parseCommon(requestUrl, project);
        List<Tag> tags = new ArrayList<>();
        Tag tag = new Tag();
        tag.setName(projectName);
        tag.setDescription(project.getComment());
        tags.add(tag);
        openAPI.setTags(tags);
    } catch (Exception e) {
        e.printStackTrace();
        openAPI = new OpenAPI();
    }
    return openAPI;
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ArrayList(java.util.ArrayList) Tag(io.swagger.v3.oas.models.tags.Tag) OpenAPI(io.swagger.v3.oas.models.OpenAPI) JSONException(org.codehaus.jettison.json.JSONException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

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