Search in sources :

Example 1 with IValidateService

use of com.amalto.workbench.service.IValidateService in project tmdm-studio-se by Talend.

the class NewProcessAction method generateJobTemplate.

public void generateJobTemplate(int type, String processName, String[] returnMessages, boolean enableRedirect, String redirectUrl, List<IMDMJobTemplate> jobTemplates) {
    if (type == ITransformerV2NodeConsDef.TYPE_SMARTVIEW) {
        // don't create job if smartview
        return;
    }
    if (returnMessages == null || returnMessages.length < 2) {
        throw new IllegalArgumentException();
    }
    String infoType = null;
    String pMessage = null;
    if (type == ITransformerV2NodeConsDef.TYPE_BEFOREDEL || type == ITransformerV2NodeConsDef.TYPE_BEFORESAVE) {
        infoType = returnMessages[0];
        pMessage = returnMessages[1];
    }
    if (type == ITransformerV2NodeConsDef.TYPE_ENTITYACTION || type == ITransformerV2NodeConsDef.TYPE_WELCOMEACTION) {
        if (enableRedirect) {
            pMessage = // $NON-NLS-1$
            "<results><item><attr>" + redirectUrl + // $NON-NLS-1$
            "</attr></item></results>";
        } else {
            // $NON-NLS-1$
            pMessage = "";
        }
    }
    IValidateService validateService = (IValidateService) GlobalServiceRegister.getDefault().getService(IValidateService.class);
    for (IMDMJobTemplate job : jobTemplates) {
        boolean result = true;
        // $NON-NLS-1$//$NON-NLS-2$
        processName = processName.replaceAll("#|\\$", "");
        if (validateService != null) {
            // $NON-NLS-1$
            result = validateService.validateAndAlertObjectExistence(ERepositoryObjectType.PROCESS, processName, "Job");
        }
        if (result) {
            closeEditor(processName);
            job.generateJobTemplate(type, processName, infoType, pMessage);
        }
    }
}
Also used : IMDMJobTemplate(org.talend.mdm.repository.ui.wizards.process.IMDMJobTemplate) IValidateService(com.amalto.workbench.service.IValidateService)

Example 2 with IValidateService

use of com.amalto.workbench.service.IValidateService in project tmdm-studio-se by Talend.

the class GenerateJobTriggerAction method doRun.

@Override
protected void doRun() {
    selectObj = getSelectedObject().get(0);
    JobOptionsDialog dialog = new JobOptionsDialog(getShell(), Messages.JobProcesssDialogTiggerTitle_title, Execution.EMBEDDED);
    dialog.setBlockOnOpen(true);
    int ret = dialog.open();
    if (ret == Dialog.CANCEL) {
        return;
    }
    // $NON-NLS-1$
    String jobName = "";
    // $NON-NLS-1$
    String jobVersion = "";
    if (selectObj instanceof IRepositoryViewObject) {
        jobName = ((IRepositoryViewObject) selectObj).getProperty().getLabel();
        jobVersion = ((IRepositoryViewObject) selectObj).getProperty().getVersion();
    }
    // check exist
    IValidateService validateService = (IValidateService) GlobalServiceRegister.getDefault().getService(IValidateService.class);
    if (validateService != null) {
        boolean result = validateService.validateAndAlertObjectExistence(IServerObjectRepositoryType.TYPE_ROUTINGRULE, getNewTriggerName(jobName), null);
        if (!result) {
            return;
        }
    }
    // 
    WSRoutingRuleE routingRule = createTrigger(jobName, jobVersion, dialog);
    // if the new objectect is opened ,than close it before regenerating
    IRepositoryViewObject toDelete = RepositoryResourceUtil.findViewObjectByName(IServerObjectRepositoryType.TYPE_ROUTINGRULE, PREFIX + jobName);
    if (toDelete != null) {
        IEditorPart openedEditor = UIUtil.findOpenedEditor(toDelete);
        if (openedEditor != null) {
            UIUtil.closeEditor(openedEditor, false);
        }
        // delete directly
        RepositoryResourceUtil.removeViewObjectPhysically(toDelete, jobVersion);
    }
    AttachToTriggerView(jobName, routingRule);
}
Also used : IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) WSRoutingRuleE(org.talend.mdm.repository.model.mdmserverobject.WSRoutingRuleE) IEditorPart(org.eclipse.ui.IEditorPart) JobOptionsDialog(org.talend.mdm.repository.ui.dialogs.job.JobOptionsDialog) IValidateService(com.amalto.workbench.service.IValidateService)

Example 3 with IValidateService

use of com.amalto.workbench.service.IValidateService in project tmdm-studio-se by Talend.

the class AddBrowseItemsWizardR method toRecreateBrowserView.

private boolean toRecreateBrowserView(String viewName) {
    IValidateService validateService = (IValidateService) GlobalServiceRegister.getDefault().getService(IValidateService.class);
    boolean result = validateService.validateAndAlertObjectExistence(TreeObject.VIEW, viewName);
    return result;
}
Also used : IValidateService(com.amalto.workbench.service.IValidateService)

Example 4 with IValidateService

use of com.amalto.workbench.service.IValidateService in project tmdm-studio-se by Talend.

the class GenerateJobTransformerAction method doRun.

@Override
protected void doRun() {
    selectObj = getSelectedObject().get(0);
    JobOptionsDialog dialog = new JobOptionsDialog(getShell(), Messages.JobProcesssOptionsDialogTitle_title, Execution.EMBEDDED);
    dialog.setBlockOnOpen(true);
    int ret = dialog.open();
    if (ret == Dialog.CANCEL) {
        return;
    }
    // $NON-NLS-1$
    String jobName = "";
    // $NON-NLS-1$
    String jobVersion = "";
    // $NON-NLS-1$
    String path = "/other";
    if (selectObj instanceof IRepositoryViewObject) {
        Property property = ((IRepositoryViewObject) selectObj).getProperty();
        if (property != null) {
            jobName = property.getLabel();
            jobVersion = property.getVersion();
        }
    }
    // check exist
    IValidateService validateService = (IValidateService) GlobalServiceRegister.getDefault().getService(IValidateService.class);
    if (validateService != null) {
        boolean result = validateService.validateAndAlertObjectExistence(IServerObjectRepositoryType.TYPE_TRANSFORMERV2, getNewProcessName(jobName), null);
        if (!result) {
            return;
        }
    }
    WSTransformerV2E transformer = createTransformer(jobName, jobVersion, dialog);
    // if the new objectect is opened ,than close it before regenerating
    IRepositoryViewObject toDelete = RepositoryResourceUtil.findViewObjectByName(IServerObjectRepositoryType.TYPE_TRANSFORMERV2, PREFIX + jobName);
    if (toDelete != null) {
        IEditorPart openedEditor = UIUtil.findOpenedEditor(toDelete);
        if (openedEditor != null) {
            UIUtil.closeEditor(openedEditor, false);
        }
        // delete directly
        RepositoryResourceUtil.removeViewObjectPhysically(toDelete, jobVersion);
    }
    AttachToProcessView(jobName, transformer);
}
Also used : WSTransformerV2E(org.talend.mdm.repository.model.mdmserverobject.WSTransformerV2E) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IEditorPart(org.eclipse.ui.IEditorPart) JobOptionsDialog(org.talend.mdm.repository.ui.dialogs.job.JobOptionsDialog) Property(org.talend.core.model.properties.Property) IValidateService(com.amalto.workbench.service.IValidateService)

Aggregations

IValidateService (com.amalto.workbench.service.IValidateService)4 IEditorPart (org.eclipse.ui.IEditorPart)2 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)2 JobOptionsDialog (org.talend.mdm.repository.ui.dialogs.job.JobOptionsDialog)2 Property (org.talend.core.model.properties.Property)1 WSRoutingRuleE (org.talend.mdm.repository.model.mdmserverobject.WSRoutingRuleE)1 WSTransformerV2E (org.talend.mdm.repository.model.mdmserverobject.WSTransformerV2E)1 IMDMJobTemplate (org.talend.mdm.repository.ui.wizards.process.IMDMJobTemplate)1