Search in sources :

Example 1 with Checkout

use of org.bimserver.models.store.Checkout in project BIMserver by opensourceBIM.

the class GetAllCheckoutsOfProjectDatabaseAction method execute.

@Override
public List<Checkout> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
    Project project = getProjectByPoid(poid);
    Set<Project> projects = new HashSet<Project>();
    if (checkSubProjects) {
        getSubProjects(project, projects);
    } else {
        projects.add(project);
    }
    Condition condition = new HasReferenceToInCondition(StorePackage.eINSTANCE.getCheckout_Project(), projects);
    Map<Long, Checkout> query = getDatabaseSession().query(condition, Checkout.class, OldQuery.getDefault());
    return CollectionUtils.mapToList(query);
}
Also used : Condition(org.bimserver.database.query.conditions.Condition) HasReferenceToInCondition(org.bimserver.database.query.conditions.HasReferenceToInCondition) Project(org.bimserver.models.store.Project) Checkout(org.bimserver.models.store.Checkout) HasReferenceToInCondition(org.bimserver.database.query.conditions.HasReferenceToInCondition) HashSet(java.util.HashSet)

Example 2 with Checkout

use of org.bimserver.models.store.Checkout in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllCheckoutsOfProjectAndSubProjects.

@Override
public List<SCheckout> getAllCheckoutsOfProjectAndSubProjects(Long poid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<List<Checkout>> action = new GetAllCheckoutsOfProjectDatabaseAction(session, getInternalAccessMethod(), poid, true);
        List<Checkout> list = session.executeAndCommitAction(action);
        Collections.sort(list, new CheckoutComparator());
        return getBimServer().getSConverter().convertToSListCheckout(list);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SCheckout(org.bimserver.interfaces.objects.SCheckout) Checkout(org.bimserver.models.store.Checkout) GetAllCheckoutsOfProjectDatabaseAction(org.bimserver.database.actions.GetAllCheckoutsOfProjectDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) CheckoutComparator(org.bimserver.webservices.CheckoutComparator) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 3 with Checkout

use of org.bimserver.models.store.Checkout in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllCheckoutsOfRevision.

@Override
public List<SCheckout> getAllCheckoutsOfRevision(Long roid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<List<Checkout>> action = new GetAllCheckoutsOfRevisionDatabaseAction(session, getInternalAccessMethod(), roid);
        List<Checkout> list = session.executeAndCommitAction(action);
        Collections.sort(list, new CheckoutComparator());
        return getBimServer().getSConverter().convertToSListCheckout(list);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SCheckout(org.bimserver.interfaces.objects.SCheckout) Checkout(org.bimserver.models.store.Checkout) DatabaseSession(org.bimserver.database.DatabaseSession) CheckoutComparator(org.bimserver.webservices.CheckoutComparator) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) GetAllCheckoutsOfRevisionDatabaseAction(org.bimserver.database.actions.GetAllCheckoutsOfRevisionDatabaseAction) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 4 with Checkout

use of org.bimserver.models.store.Checkout in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllCheckoutsByUser.

@Override
public List<SCheckout> getAllCheckoutsByUser(Long uoid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<List<Checkout>> action = new GetAllCheckoutsByUserDatabaseAction(session, getInternalAccessMethod(), uoid);
        List<Checkout> list = session.executeAndCommitAction(action);
        Collections.sort(list, new CheckoutComparator());
        return getBimServer().getSConverter().convertToSListCheckout(list);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SCheckout(org.bimserver.interfaces.objects.SCheckout) Checkout(org.bimserver.models.store.Checkout) DatabaseSession(org.bimserver.database.DatabaseSession) CheckoutComparator(org.bimserver.webservices.CheckoutComparator) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) GetAllCheckoutsByUserDatabaseAction(org.bimserver.database.actions.GetAllCheckoutsByUserDatabaseAction) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 5 with Checkout

use of org.bimserver.models.store.Checkout in project BIMserver by opensourceBIM.

the class GetCheckinWarningsDatabaseAction method checkInterleavingCommits.

private void checkInterleavingCommits(Project project, User user, Set<String> warnings) {
    Checkout lastOwnActiveCheckout = null;
    for (Checkout checkout : project.getCheckouts()) {
        if (checkout.getUser() == user && checkout.getActive()) {
            lastOwnActiveCheckout = checkout;
        }
    }
    if (lastOwnActiveCheckout != null) {
        Project mainProject = project;
        while (mainProject.getParent() != null) {
            mainProject = mainProject.getParent();
        }
        int newRevisionsAfterCheckout = 0;
        for (Revision virtualRevision : mainProject.getRevisions()) {
            if (lastOwnActiveCheckout.getDate().before(virtualRevision.getDate()) && lastOwnActiveCheckout.getRevision() != virtualRevision) {
                newRevisionsAfterCheckout++;
            }
        }
        if (newRevisionsAfterCheckout == 1) {
            warnings.add("Warning, after your last checkout of this project (revision " + lastOwnActiveCheckout.getRevision().getId() + "), a new revision has been checked-in");
        } else if (newRevisionsAfterCheckout > 1) {
            warnings.add("Warning, after your last checkout of this project (revision " + lastOwnActiveCheckout.getRevision().getId() + "), " + newRevisionsAfterCheckout + " new revisions have been checked-in");
        }
    }
}
Also used : Project(org.bimserver.models.store.Project) Checkout(org.bimserver.models.store.Checkout) Revision(org.bimserver.models.store.Revision)

Aggregations

Checkout (org.bimserver.models.store.Checkout)10 UserException (org.bimserver.shared.exceptions.UserException)5 IOException (java.io.IOException)4 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 MalformedURLException (java.net.MalformedURLException)4 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 MessagingException (javax.mail.MessagingException)4 AddressException (javax.mail.internet.AddressException)4 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)4 DatabaseSession (org.bimserver.database.DatabaseSession)4 SCheckout (org.bimserver.interfaces.objects.SCheckout)4 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)4 Project (org.bimserver.models.store.Project)4 Revision (org.bimserver.models.store.Revision)4 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)4 SerializerException (org.bimserver.plugins.serializers.SerializerException)4 PluginException (org.bimserver.shared.exceptions.PluginException)4 ServerException (org.bimserver.shared.exceptions.ServerException)4