Search in sources :

Example 1 with CDOTransaction

use of org.eclipse.emf.cdo.transaction.CDOTransaction in project InformationSystem by ObeoNetwork.

the class CollaborativeBusinessProjectImporter method getTargetRemoteResource.

private CDOResource getTargetRemoteResource(String targetResourcePath) {
    CDOResource targetResource = null;
    CDOTransaction transaction = getTransactionOnSession(getTargetSession());
    if (transaction != null && transaction.hasResource(targetResourcePath)) {
        try {
            targetResource = transaction.getResource(targetResourcePath);
        } catch (Exception e) {
        // unable to get resource, it probably doesn't exist
        }
    }
    return targetResource;
}
Also used : CDOTransaction(org.eclipse.emf.cdo.transaction.CDOTransaction) CDOResource(org.eclipse.emf.cdo.eresource.CDOResource) RepositoryConnectionException(fr.obeo.dsl.viewpoint.collab.api.RepositoryConnectionException)

Example 2 with CDOTransaction

use of org.eclipse.emf.cdo.transaction.CDOTransaction in project InformationSystem by ObeoNetwork.

the class EmbeddedCDOServer method getRemoteProjectsURIs.

/**
 * Retrieve remote projects from CDO server
 * @param parentMonitor
 * @return
 */
public Collection<URI> getRemoteProjectsURIs(IProgressMonitor parentMonitor) {
    SubMonitor monitor = SubMonitor.convert(parentMonitor, 1);
    monitor.setTaskName("Retrieving remote projects list");
    String productGroup = "org.eclipse.emf.cdo.sessions";
    CDOSession session = (CDOSession) IPluginContainer.INSTANCE.getElement(productGroup, "cdo", getTcpUrl());
    CDOTransaction transaction = session.openTransaction();
    Collection<URI> remoteProjectsURIs = getRemoteProjectsURIs(transaction);
    transaction.close();
    session.close();
    monitor.worked(1);
    monitor.done();
    return remoteProjectsURIs;
}
Also used : CDOSession(org.eclipse.emf.cdo.session.CDOSession) CDOTransaction(org.eclipse.emf.cdo.transaction.CDOTransaction) SubMonitor(org.eclipse.core.runtime.SubMonitor) URI(org.eclipse.emf.common.util.URI)

Example 3 with CDOTransaction

use of org.eclipse.emf.cdo.transaction.CDOTransaction in project InformationSystem by ObeoNetwork.

the class ScaffoldingOperation method createScaffoldResourceForSharedProject.

private Resource createScaffoldResourceForSharedProject(CDOView cdoView) {
    CDOTransaction transaction = (CDOTransaction) cdoView;
    String name = getScaffoldModelName();
    int count = 0;
    while (count < 10) {
        String path = SCAFFOLD_FOLDER + "/" + getFilenameForScaffoldModel(name, count);
        // Create resource
        CDOResource resource = transaction.getOrCreateResource(path);
        // Check if it is empty
        if (resource.getContents().isEmpty()) {
            resource.getContents().add(scaffoldInfo);
            return resource;
        } else {
            // try with another name
            count++;
        }
    }
    return null;
}
Also used : CDOTransaction(org.eclipse.emf.cdo.transaction.CDOTransaction) CDOResource(org.eclipse.emf.cdo.eresource.CDOResource)

Example 4 with CDOTransaction

use of org.eclipse.emf.cdo.transaction.CDOTransaction in project InformationSystem by ObeoNetwork.

the class CollaborativeBusinessProjectImporter method addToRemoteSemanticResource.

private void addToRemoteSemanticResource(final EObject copyObject, final String targetPath) {
    CDOTransaction transaction = getTransactionOnSession(getTargetSession());
    if (transaction != null) {
        CDOResource targetResource = transaction.getOrCreateResource(targetPath);
        targetResource.getContents().add(copyObject);
        if (!existsTargetSemanticResource(targetResource.getURI())) {
            addToSemanticResources(getTargetSession(), targetResource.getURI(), new NullProgressMonitor());
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CDOTransaction(org.eclipse.emf.cdo.transaction.CDOTransaction) CDOResource(org.eclipse.emf.cdo.eresource.CDOResource)

Aggregations

CDOTransaction (org.eclipse.emf.cdo.transaction.CDOTransaction)4 CDOResource (org.eclipse.emf.cdo.eresource.CDOResource)3 RepositoryConnectionException (fr.obeo.dsl.viewpoint.collab.api.RepositoryConnectionException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1 CDOSession (org.eclipse.emf.cdo.session.CDOSession)1 URI (org.eclipse.emf.common.util.URI)1