Search in sources :

Example 21 with MobileApplication

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

the class MobileResourceHelper method getMobilePlatform.

private static MobilePlatform getMobilePlatform(String projectName, String platform) throws ServiceException, EngineException {
    if (!Engine.theApp.databaseObjectsManager.existsProject(projectName)) {
        throw new ServiceException("Unable to get resources of the application '" + projectName + "'; reason: the project does not exist");
    }
    Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
    MobileApplication mobileApplication = project.getMobileApplication();
    if (mobileApplication == null) {
        throw new ServiceException("The application " + project.getName() + " doesn't contain a mobileApplication object.");
    }
    return mobileApplication.getMobilePlatformByName(platform);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) ServiceException(com.twinsoft.convertigo.engine.admin.services.ServiceException) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication)

Example 22 with MobileApplication

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

the class GetStoreContent method getServiceResult.

@Override
protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element root = document.getDocumentElement();
    Element projectsListElement = document.createElement("projects");
    root.appendChild(projectsListElement);
    String requestedPlatform = ServiceUtils.getRequiredParameter(request, "platform");
    HttpSession httpSession = request.getSession();
    boolean bAdminRole = hasRole(httpSession, Role.WEB_ADMIN);
    boolean bAuthRole = hasRole(httpSession, Role.AUTHENTICATED);
    for (String projectName : Engine.theApp.databaseObjectsManager.getAllProjectNamesList()) {
        try {
            Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
            Element projectElement = null;
            MobileApplication mobileApplication = project.getMobileApplication();
            if (mobileApplication != null) {
                Accessibility accessibylity = mobileApplication.getAccessibility();
                if (accessibylity == Accessibility.Public || (accessibylity == Accessibility.Private && bAuthRole) || bAdminRole) {
                    projectElement = createProjectElement(document, mobileApplication, projectName);
                    for (MobilePlatform platform : mobileApplication.getMobilePlatformList()) {
                        if (isRequestedPlatformValid(requestedPlatform, platform)) {
                            projectElement.getLastChild().appendChild(createPlatform(document, platform));
                        }
                    }
                    projectsListElement.appendChild(projectElement);
                }
            }
        } catch (EngineException e) {
            String message = "Unable to get project information ('" + projectName + "')";
            Engine.logAdmin.error(message, e);
        }
    }
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) Accessibility(com.twinsoft.convertigo.engine.enums.Accessibility) HttpSession(javax.servlet.http.HttpSession) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) Element(org.w3c.dom.Element) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 23 with MobileApplication

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

the class GetTestPlatform method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element root = document.getDocumentElement();
    String projectName = request.getParameter("projectName");
    Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
    Element e_project = createDatabaseObjectElement(document, project);
    Connector defaultConnector = project.getDefaultConnector();
    e_project.setAttribute("defaultConnector", defaultConnector.getName());
    e_project.setAttribute("defaultTransaction", defaultConnector.getDefaultTransaction().getName());
    boolean bTpHiddenRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_HIDDEN);
    boolean bTpPrivateRole = Engine.authenticatedSessionManager.hasRole(request.getSession(), Role.TEST_PLATFORM_PRIVATE);
    for (Connector connector : project.getConnectorsList()) {
        Element e_connector = createDatabaseObjectElement(document, connector);
        for (Transaction transaction : connector.getTransactionsList()) {
            // WEB_ADMIN role is allowed to execute all requestables
            if (transaction.isPublicAccessibility() || (transaction.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
                e_connector.appendChild(createRequestableElement(document, transaction));
            }
        }
        e_project.appendChild(e_connector);
    }
    for (Sequence sequence : project.getSequencesList()) {
        // WEB_ADMIN role is allowed to execute all requestables
        if (sequence.isPublicAccessibility() || (sequence.isHiddenAccessibility() && bTpHiddenRole) || bTpPrivateRole) {
            e_project.appendChild(createRequestableElement(document, sequence));
        }
    }
    MobileApplication mobileApplication = project.getMobileApplication();
    if (mobileApplication != null && (mobileApplication.getAccessibility() == Accessibility.Public || (mobileApplication.getAccessibility() == Accessibility.Hidden && bTpHiddenRole) || bTpPrivateRole)) {
        Element e_mobileApplication = createDatabaseObjectElement(document, mobileApplication);
        String applicationID = mobileApplication.getComputedApplicationId();
        e_mobileApplication.setAttribute("applicationID", applicationID);
        String endpoint = mobileApplication.getComputedEndpoint(request);
        e_mobileApplication.setAttribute("endpoint", endpoint);
        String version = mobileApplication.getComputedApplicationVersion();
        e_mobileApplication.setAttribute("applicationVersion", version);
        e_project.appendChild(e_mobileApplication);
        for (MobilePlatform platform : mobileApplication.getMobilePlatformList()) {
            Element e_device = createDatabaseObjectElement(document, platform);
            e_device.setAttribute("classname", platform.getClass().getSimpleName());
            e_device.setAttribute("displayName", CachedIntrospector.getBeanInfo(platform.getClass()).getBeanDescriptor().getDisplayName());
            e_device.setAttribute("packageType", platform.getPackageType());
            e_device.setAttribute("revision", "computing...");
            e_mobileApplication.appendChild(e_device);
        }
        try {
            String mobileProjectName = mobileApplication.getComputedApplicationName();
            e_mobileApplication.setAttribute("mobileProjectName", mobileProjectName);
        } catch (Exception e) {
            Engine.logAdmin.error("Failed to retrieve the application mobile name", e);
        }
        IApplicationComponent app = mobileApplication.getApplicationComponent();
        String msg = app != null ? app.getUnbuiltMessage() : null;
        if (msg != null) {
            e_mobileApplication.setAttribute("unbuiltMessage", msg);
        }
    }
    root.appendChild(e_project);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Connector(com.twinsoft.convertigo.beans.core.Connector) MobilePlatform(com.twinsoft.convertigo.beans.core.MobilePlatform) Transaction(com.twinsoft.convertigo.beans.core.Transaction) MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) Element(org.w3c.dom.Element) Sequence(com.twinsoft.convertigo.beans.core.Sequence) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent)

Example 24 with MobileApplication

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

the class NgxBuilder method pageRemoved.

@Override
public void pageRemoved(final IPageComponent pageComponent) throws EngineException {
    PageComponent page = (PageComponent) pageComponent;
    if (page != null && page.isEnabled() && initDone) {
        synchronized (page) {
            MobileApplication mobileApplication = project.getMobileApplication();
            if (mobileApplication != null) {
                ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
                if (application != null) {
                    writeAppSourceFiles(application);
                    deleteUselessPageDir(page.getName());
                    moveFiles();
                    Engine.logEngine.trace("(MobileBuilder) Handled 'pageRemoved'");
                }
            }
        }
    }
}
Also used : MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) IPageComponent(com.twinsoft.convertigo.beans.core.IPageComponent) PageComponent(com.twinsoft.convertigo.beans.ngx.components.PageComponent)

Example 25 with MobileApplication

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

the class NgxBuilder method compRemoved.

@Override
public void compRemoved(final ISharedComponent sharedComponent) throws EngineException {
    UISharedComponent comp = (UISharedComponent) sharedComponent;
    if (comp != null && initDone) {
        synchronized (comp) {
            MobileApplication mobileApplication = project.getMobileApplication();
            if (mobileApplication != null) {
                ApplicationComponent application = (ApplicationComponent) mobileApplication.getApplicationComponent();
                if (application != null) {
                    writeAppSourceFiles(application);
                    deleteUselessCompDir(comp.getName(), comp.getQName());
                    moveFiles();
                    Engine.logEngine.trace("(MobileBuilder) Handled 'compRemoved'");
                    ComponentRefManager.get(Mode.use).removeKey(comp.getQName());
                }
            }
        }
    }
}
Also used : MobileApplication(com.twinsoft.convertigo.beans.core.MobileApplication) ApplicationComponent(com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent) IApplicationComponent(com.twinsoft.convertigo.beans.core.IApplicationComponent) UISharedComponent(com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)

Aggregations

MobileApplication (com.twinsoft.convertigo.beans.core.MobileApplication)36 IApplicationComponent (com.twinsoft.convertigo.beans.core.IApplicationComponent)16 ApplicationComponent (com.twinsoft.convertigo.beans.ngx.components.ApplicationComponent)12 IPageComponent (com.twinsoft.convertigo.beans.core.IPageComponent)8 MobilePlatform (com.twinsoft.convertigo.beans.core.MobilePlatform)8 IOException (java.io.IOException)8 UISharedComponent (com.twinsoft.convertigo.beans.ngx.components.UISharedComponent)7 Element (org.w3c.dom.Element)7 Project (com.twinsoft.convertigo.beans.core.Project)6 ApplicationComponent (com.twinsoft.convertigo.beans.mobile.components.ApplicationComponent)6 ServiceException (com.twinsoft.convertigo.engine.admin.services.ServiceException)6 File (java.io.File)6 EngineException (com.twinsoft.convertigo.engine.EngineException)5 IOs (com.twinsoft.convertigo.beans.mobileplatforms.IOs)4 AuthenticationException (com.twinsoft.convertigo.engine.AuthenticationException)4 PageComponent (com.twinsoft.convertigo.beans.mobile.components.PageComponent)3 Android (com.twinsoft.convertigo.beans.mobileplatforms.Android)3 PageComponent (com.twinsoft.convertigo.beans.ngx.components.PageComponent)3 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)3 Cursor (org.eclipse.swt.graphics.Cursor)3