Search in sources :

Example 91 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.

the class SimpleBusinessCreationWizard method performFinish.

public boolean performFinish() {
    IProxyRepositoryFactory repositoryFactory = ProxyRepositoryFactory.getInstance();
    String nextId = repositoryFactory.getNextId();
    property.setId(nextId);
    //changed by hqzhang for TDI-19527, label=displayName
    property.setLabel(property.getDisplayName());
    DiagramResourceManager diagramResourceManager = new DiagramResourceManager(getWorkbench().getActiveWorkbenchWindow().getActivePage(), new NullProgressMonitor());
    IFile file = diagramResourceManager.createDiagramFile();
    diagramResourceManager.updateFromResource(businessProcessItem, file);
    try {
        repositoryFactory.create(businessProcessItem, mainPage.getDestinationPath());
    } catch (PersistenceException e1) {
        throw new IllegalStateException(e1);
    }
    diagramResourceManager.openEditor(businessProcessItem, file, false);
    return true;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) PersistenceException(org.talend.commons.exception.PersistenceException) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 92 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.

the class BusinessDiagramEditor method dispose.

@Override
public void dispose() {
    getSite().setSelectionProvider(null);
    getSite().getWorkbenchWindow().getSelectionService().removeSelectionListener(this);
    super.dispose();
    if (isKeepPropertyLocked()) {
        return;
    }
    // Unlock the process :
    IProxyRepositoryFactory repFactory = ProxyRepositoryFactory.getInstance();
    try {
        // Property property = repFactory.reload(repositoryEditorInput.getItem().getProperty());
        Property property = repFactory.getUptodateProperty(repositoryEditorInput.getItem().getProperty());
        repositoryEditorInput.setItem(property.getItem());
        repFactory.unlock(repositoryEditorInput.getItem());
    } catch (PersistenceException e) {
        ExceptionHandler.process(e);
    } catch (LoginException e) {
        ExceptionHandler.process(e);
    }
    RepositoryNode repositoryNode = repositoryEditorInput.getRepositoryNode();
    if (repositoryNode == null) {
        // retrieve the node.
        repositoryEditorInput.setRepositoryNode(null);
        repositoryNode = repositoryEditorInput.getRepositoryNode();
    }
// if (repositoryNode != null) {
// if (repFactory.getStatus(repositoryEditorInput.getItem()) == ERepositoryStatus.DELETED) {
// RepositoryManager.refreshDeletedNode(null);
// } else {
// RepositoryManager.refreshSavedNode(repositoryNode);
// }
// }
}
Also used : PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) RepositoryNode(org.talend.repository.model.RepositoryNode) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 93 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tdi-studio-se by Talend.

the class BusinessDiagramEditor method doSave.

@Override
public void doSave(IProgressMonitor progressMonitor) {
    if (repositoryEditorInput != null) {
        final BusinessProcessItem businessProcessItem = (BusinessProcessItem) repositoryEditorInput.getItem();
        IRepositoryService service = CorePlugin.getDefault().getRepositoryService();
        IProxyRepositoryFactory repFactory = service.getProxyRepositoryFactory();
        try {
            repFactory.updateLockStatus();
            // For TDI-23825, if not lock by user try to lock again.
            boolean locked = repFactory.getStatus(businessProcessItem) == ERepositoryStatus.LOCK_BY_USER;
            if (!locked) {
                repFactory.lock(businessProcessItem);
            }
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
        ERepositoryStatus status = repFactory.getStatus(businessProcessItem);
        if (!status.equals(ERepositoryStatus.LOCK_BY_USER) && !repFactory.getRepositoryContext().isEditableAsReadOnly()) {
            MessageDialog.openWarning(getEditorSite().getShell(), //$NON-NLS-1$
            Messages.getString("BusinessDiagramEditor.canNotSaveTitle"), //$NON-NLS-1$
            Messages.getString("BusinessDiagramEditor.canNotSaveMessage"));
            return;
        }
        super.doSave(progressMonitor);
        DiagramResourceManager diagramResourceManager = new DiagramResourceManager();
        diagramResourceManager.updateFromResource(businessProcessItem, repositoryEditorInput.getFile());
        final IProxyRepositoryFactory factory = service.getProxyRepositoryFactory();
        RepositoryWorkUnit rwu = new RepositoryWorkUnit("save Business") {

            @Override
            protected void run() throws LoginException, PersistenceException {
                ProxyRepositoryFactory.getInstance().save(businessProcessItem);
            }
        };
        rwu.setAvoidUnloadResources(true);
        rwu.setAvoidSvnUpdate(true);
        factory.executeRepositoryWorkUnit(rwu);
        propertyIsDirty = false;
        firePropertyChange(IEditorPart.PROP_DIRTY);
    }
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) DiagramResourceManager(org.talend.designer.business.diagram.custom.actions.DiagramResourceManager) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) PartInitException(org.eclipse.ui.PartInitException) LoginException(org.talend.commons.exception.LoginException) PersistenceException(org.talend.commons.exception.PersistenceException) IRepositoryService(org.talend.repository.model.IRepositoryService)

Example 94 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tmdm-studio-se by Talend.

the class DeployOnMDMExportWizardPage method getExportResources.

/**
 * Returns resources to be exported. This returns file - for just the files use getSelectedResources.
 *
 * @return a collection of resources currently selected for export (element type: <code>IResource</code>)
 * @throws ProcessorException
 */
protected List<ExportFileResource> getExportResources(ExportFileResource p) throws ProcessorException {
    Item item = p.getItem();
    Resource eResource = item.eResource();
    Property property = item.getProperty();
    if (eResource == null && property != null) {
        IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        try {
            IRepositoryViewObject newViewObj = factory.getLastVersion(property.getId());
            Item newItem = newViewObj.getProperty().getItem();
            p.setProcess((ProcessItem) newItem);
        } catch (PersistenceException e) {
            log.error(e.getMessage(), e);
        }
    }
    return manager.getExportResources(new ExportFileResource[] { p });
}
Also used : Item(org.talend.core.model.properties.Item) ProcessItem(org.talend.core.model.properties.ProcessItem) Resource(org.eclipse.emf.ecore.resource.Resource) ExportFileResource(org.talend.repository.documentation.ExportFileResource) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Property(org.talend.core.model.properties.Property) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Example 95 with IProxyRepositoryFactory

use of org.talend.repository.model.IProxyRepositoryFactory in project tmdm-studio-se by Talend.

the class DeployOnMDMAction method doRun.

@Override
protected void doRun() {
    List<IRepositoryViewObject> viewObjs = getSelectedViewObject();
    DeployOnMDMExportWizard publishWizard = new DeployOnMDMExportWizard();
    publishWizard.setWindowTitle(EXPORTJOBSCRIPTS);
    publishWizard.init(getWorkbench(), (IStructuredSelection) this.getSelection());
    Shell activeShell = Display.getCurrent().getActiveShell();
    WizardDialog dialog = new WizardDialog(activeShell, publishWizard);
    dialog.open();
    boolean deploySucceed = publishWizard.isDeploySucceed();
    if (deploySucceed) {
        IRemoveCommandService service = (IRemoveCommandService) GlobalServiceRegister.getDefault().getService(IRemoveCommandService.class);
        SpagoBiServer spagoBiServer = publishWizard.getMdmServer();
        MDMServerDef mdmServer = getMdmServer(spagoBiServer);
        IProxyRepositoryFactory factory = CoreRuntimePlugin.getInstance().getProxyRepositoryFactory();
        try {
            for (IRepositoryViewObject viewObj : viewObjs) {
                Item item = viewObj.getProperty().getItem();
                Property property = item.getProperty();
                if (property != null) {
                    boolean eDeliver = property.eDeliver();
                    property.eSetDeliver(false);
                    property.getAdditionalProperties().put(PROP_LAST_SERVER_DEF, mdmServer.getName());
                    factory.save(item);
                    property.eSetDeliver(eDeliver);
                }
                refreshMdmRepositoryViewTree();
                service.removeDeployPhaseCommandOf(ERepositoryObjectType.PROCESS, item);
            }
        } catch (PersistenceException e) {
            log.error(e.getMessage(), e);
        }
    }
}
Also used : SpagoBiServer(org.talend.core.model.properties.SpagoBiServer) Item(org.talend.core.model.properties.Item) Shell(org.eclipse.swt.widgets.Shell) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) IRemoveCommandService(com.amalto.workbench.service.bridge.IRemoveCommandService) WizardDialog(org.eclipse.jface.wizard.WizardDialog) Property(org.talend.core.model.properties.Property) DeployOnMDMExportWizard(org.talend.mdm.engines.client.ui.wizards.DeployOnMDMExportWizard) MDMServerDef(org.talend.mdm.repository.model.mdmmetadata.MDMServerDef) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory)

Aggregations

IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)251 PersistenceException (org.talend.commons.exception.PersistenceException)154 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)96 Item (org.talend.core.model.properties.Item)67 Property (org.talend.core.model.properties.Property)58 ArrayList (java.util.ArrayList)42 ConnectionItem (org.talend.core.model.properties.ConnectionItem)34 RepositoryNode (org.talend.repository.model.RepositoryNode)32 ProcessItem (org.talend.core.model.properties.ProcessItem)29 ERepositoryObjectType (org.talend.core.model.repository.ERepositoryObjectType)28 CoreException (org.eclipse.core.runtime.CoreException)23 LoginException (org.talend.commons.exception.LoginException)22 IRepositoryService (org.talend.repository.model.IRepositoryService)22 ERepositoryStatus (org.talend.commons.runtime.model.repository.ERepositoryStatus)21 DatabaseConnection (org.talend.core.model.metadata.builder.connection.DatabaseConnection)21 IElementParameter (org.talend.core.model.process.IElementParameter)21 Connection (org.talend.core.model.metadata.builder.connection.Connection)20 List (java.util.List)18 IFile (org.eclipse.core.resources.IFile)18 Project (org.talend.core.model.general.Project)18