Search in sources :

Example 71 with DatabaseObject

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

the class Set method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    Element root = document.getDocumentElement();
    Document post = null;
    Element response = document.createElement("response");
    try {
        Map<String, DatabaseObject> map = com.twinsoft.convertigo.engine.admin.services.projects.Get.getDatabaseObjectByQName(request);
        xpath = new TwsCachedXPathAPI();
        post = XMLUtils.parseDOM(request.getInputStream());
        postElt = document.importNode(post.getFirstChild(), true);
        String objectQName = xpath.selectSingleNode(postElt, "./@qname").getNodeValue();
        DatabaseObject object = map.get(objectQName);
        if (object instanceof Project) {
            Project project = (Project) object;
            String objectNewName = getPropertyValue(object, "name").toString();
            Engine.theApp.databaseObjectsManager.renameProject(project, objectNewName);
            map.remove(objectQName);
            map.put(project.getQName(), project);
        }
        BeanInfo bi = CachedIntrospector.getBeanInfo(object.getClass());
        PropertyDescriptor[] propertyDescriptors = bi.getPropertyDescriptors();
        for (PropertyDescriptor propertyDescriptor : propertyDescriptors) {
            String propertyName = propertyDescriptor.getName();
            Method setter = propertyDescriptor.getWriteMethod();
            Class<?> propertyTypeClass = propertyDescriptor.getReadMethod().getReturnType();
            if (propertyTypeClass.isPrimitive()) {
                propertyTypeClass = ClassUtils.primitiveToWrapper(propertyTypeClass);
            }
            try {
                String propertyValue = getPropertyValue(object, propertyName).toString();
                Object oPropertyValue = createObject(propertyTypeClass, propertyValue);
                if (object.isCipheredProperty(propertyName)) {
                    Method getter = propertyDescriptor.getReadMethod();
                    String initialValue = (String) getter.invoke(object, (Object[]) null);
                    if (oPropertyValue.equals(initialValue) || DatabaseObject.encryptPropertyValue(initialValue).equals(oPropertyValue)) {
                        oPropertyValue = initialValue;
                    } else {
                        object.hasChanged = true;
                    }
                }
                if (oPropertyValue != null) {
                    Object[] args = { oPropertyValue };
                    setter.invoke(object, args);
                }
            } catch (IllegalArgumentException e) {
            }
        }
        Engine.theApp.databaseObjectsManager.exportProject(object.getProject());
        response.setAttribute("state", "success");
        response.setAttribute("message", "Project have been successfully updated!");
    } catch (Exception e) {
        Engine.logAdmin.error("Error during saving the properties!\n" + e.getMessage());
        response.setAttribute("state", "error");
        response.setAttribute("message", "Error during saving the properties!");
        Element stackTrace = document.createElement("stackTrace");
        stackTrace.setTextContent(e.getMessage());
        root.appendChild(stackTrace);
    } finally {
        xpath.resetCache();
    }
    root.appendChild(response);
}
Also used : PropertyDescriptor(java.beans.PropertyDescriptor) Element(org.w3c.dom.Element) BeanInfo(java.beans.BeanInfo) Method(java.lang.reflect.Method) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) ServiceException(com.twinsoft.convertigo.engine.admin.services.ServiceException) Project(com.twinsoft.convertigo.beans.core.Project) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) TwsCachedXPathAPI(com.twinsoft.convertigo.engine.util.TwsCachedXPathAPI)

Example 72 with DatabaseObject

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

the class Get method getServiceResult.

protected void getServiceResult(HttpServletRequest request, Document document) throws Exception {
    String projectName = request.getParameter("projectName");
    Element root = document.getDocumentElement();
    root.setAttribute("name", projectName);
    ProjectUtils.getFullProjectDOM(document, projectName, new StreamSource(getClass().getResourceAsStream("cleanDOM.xsl")));
    final Map<String, DatabaseObject> map = getDatabaseObjectByQName(request);
    map.clear();
    Project project = Engine.theApp.databaseObjectsManager.getOriginalProjectByName(projectName);
    new WalkHelper() {

        @Override
        protected void walk(DatabaseObject databaseObject) throws Exception {
            map.put(databaseObject.getQName(), databaseObject);
            super.walk(databaseObject);
        }
    }.init(project);
}
Also used : Project(com.twinsoft.convertigo.beans.core.Project) Element(org.w3c.dom.Element) StreamSource(javax.xml.transform.stream.StreamSource) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) WalkHelper(com.twinsoft.convertigo.engine.helpers.WalkHelper)

Example 73 with DatabaseObject

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

the class DisableMobilePageComponentAction method selectionChanged.

public void selectionChanged(IAction action, ISelection selection) {
    super.selectionChanged(action, selection);
    IStructuredSelection structuredSelection = (IStructuredSelection) selection;
    TreeObject treeObject = (TreeObject) structuredSelection.getFirstElement();
    if (treeObject instanceof MobilePageComponentTreeObject) {
        DatabaseObject dbo = (DatabaseObject) treeObject.getObject();
        ActionModel actionModel = DatabaseObjectsAction.selectionChanged(getClass().getName(), dbo);
        action.setEnabled(actionModel.isEnabled);
    }
}
Also used : MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) MobilePageComponentTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.MobilePageComponentTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ActionModel(com.twinsoft.convertigo.engine.studio.ActionModel)

Example 74 with DatabaseObject

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

the class DatabaseObjectCreateAction method run.

public void run() {
    Display display = Display.getDefault();
    Cursor waitCursor = new Cursor(display, SWT.CURSOR_WAIT);
    Shell shell = getParentShell();
    shell.setCursor(waitCursor);
    try {
        TreeObject parentTreeObject = null;
        DatabaseObject databaseObject = null;
        ProjectExplorerView explorerView = getProjectExplorerView();
        if (explorerView != null) {
            parentTreeObject = explorerView.getFirstSelectedTreeObject();
            if (parentTreeObject instanceof ObjectsFolderTreeObject) {
                parentTreeObject = ((ObjectsFolderTreeObject) parentTreeObject).getParent();
                databaseObject = (DatabaseObject) parentTreeObject.getObject();
            } else {
                databaseObject = (DatabaseObject) parentTreeObject.getObject();
            }
            NewObjectWizard newObjectWizard = new NewObjectWizard(databaseObject, databaseObjectClassName);
            WizardDialog wzdlg = new WizardDialog(shell, newObjectWizard);
            wzdlg.setPageSize(850, 650);
            wzdlg.open();
            int result = wzdlg.getReturnCode();
            if ((result != Window.CANCEL) && (newObjectWizard.newBean != null)) {
                postCreate(parentTreeObject, newObjectWizard.newBean);
            }
        }
    } catch (Throwable e) {
        ConvertigoPlugin.logException(e, "Unable to create a new database object '" + databaseObjectClassName + "'!");
    } finally {
        shell.setCursor(null);
        waitCursor.dispose();
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) ProjectExplorerView(com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) TreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) Cursor(org.eclipse.swt.graphics.Cursor) ObjectsFolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject) NewObjectWizard(com.twinsoft.convertigo.eclipse.wizards.new_object.NewObjectWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Display(org.eclipse.swt.widgets.Display)

Example 75 with DatabaseObject

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

the class DatabaseObjectIncreasePriorityAction method increasePriority.

private void increasePriority(TreeObject treeObject) throws EngineException {
    int count = counter;
    if (treeObject instanceof DatabaseObjectTreeObject) {
        DatabaseObject databaseObject = (DatabaseObject) treeObject.getObject();
        DatabaseObject parent = databaseObject.getParent();
        if (parent != null && parent instanceof IContainerOrdered) {
            IContainerOrdered containerOrdered = (IContainerOrdered) parent;
            while (count-- > 0) {
                containerOrdered.increasePriority(databaseObject);
            }
            if (parent.hasChanged) {
                TreeParent parentTreeObject = null;
                TreeParent treeParent = treeObject.getParent();
                if (treeParent instanceof FolderTreeObject) {
                    parentTreeObject = treeObject.getParent().getParent();
                } else {
                    parentTreeObject = treeParent;
                }
                if (!treeNodesToUpdate.contains(parentTreeObject)) {
                    treeNodesToUpdate.add(parentTreeObject);
                }
            }
        }
    } else {
        DatabaseObjectTreeObject databaseObjectTreeObject = null;
        if (treeObject instanceof PropertyTableRowTreeObject) {
            PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) treeObject.getParent();
            while (count-- > 0) {
                if ((treeObject = propertyTableTreeObject.moveRow((PropertyTableRowTreeObject) treeObject, true)) != null) {
                    databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
                }
            }
        } else if (treeObject instanceof PropertyTableColumnTreeObject) {
            PropertyTableRowTreeObject propertyTableRowTreeObject = (PropertyTableRowTreeObject) treeObject.getParent();
            PropertyTableTreeObject propertyTableTreeObject = (PropertyTableTreeObject) propertyTableRowTreeObject.getParent();
            while (count-- > 0) {
                if ((treeObject = propertyTableRowTreeObject.moveColumn((PropertyTableColumnTreeObject) treeObject, true)) != null) {
                    databaseObjectTreeObject = (DatabaseObjectTreeObject) propertyTableTreeObject.getParent();
                }
            }
        }
        if (databaseObjectTreeObject != null) {
            if (databaseObjectTreeObject.hasChanged()) {
                DatabaseObjectTreeObject parentTreeObject = null;
                TreeParent treeParent = databaseObjectTreeObject.getParent();
                if (treeParent instanceof FolderTreeObject)
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent.getParent();
                else
                    parentTreeObject = (DatabaseObjectTreeObject) treeParent;
                if (!treeNodesToUpdate.contains(parentTreeObject)) {
                    treeNodesToUpdate.add(parentTreeObject);
                }
            }
        }
    }
}
Also used : PropertyTableRowTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableRowTreeObject) DatabaseObjectTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject) TreeParent(com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent) IContainerOrdered(com.twinsoft.convertigo.beans.core.IContainerOrdered) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) FolderTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.FolderTreeObject) PropertyTableColumnTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableColumnTreeObject) PropertyTableTreeObject(com.twinsoft.convertigo.eclipse.views.projectexplorer.model.PropertyTableTreeObject)

Aggregations

DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)296 TreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.TreeObject)98 DatabaseObjectTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.DatabaseObjectTreeObject)97 EngineException (com.twinsoft.convertigo.engine.EngineException)88 Shell (org.eclipse.swt.widgets.Shell)46 ProjectExplorerView (com.twinsoft.convertigo.eclipse.views.projectexplorer.ProjectExplorerView)45 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)43 Cursor (org.eclipse.swt.graphics.Cursor)42 Display (org.eclipse.swt.widgets.Display)42 Sequence (com.twinsoft.convertigo.beans.core.Sequence)41 Project (com.twinsoft.convertigo.beans.core.Project)38 CoreException (org.eclipse.core.runtime.CoreException)36 IOException (java.io.IOException)35 Step (com.twinsoft.convertigo.beans.core.Step)33 ActionModel (com.twinsoft.convertigo.engine.studio.ActionModel)33 TreeParent (com.twinsoft.convertigo.eclipse.views.projectexplorer.TreeParent)31 Element (org.w3c.dom.Element)30 ObjectsFolderTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.ObjectsFolderTreeObject)27 StepTreeObject (com.twinsoft.convertigo.eclipse.views.projectexplorer.model.StepTreeObject)27 PartInitException (org.eclipse.ui.PartInitException)26