use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class RemoveServiceFromProjectDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
Service service = getDatabaseSession().get(soid, OldQuery.getDefault());
Project project = getDatabaseSession().get(poid, OldQuery.getDefault());
project.getServices().remove(service);
getDatabaseSession().store(project);
return true;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class RemoveUserFromProjectDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
User user = getUserByUoid(uoid);
Project project = getProjectByPoid(poid);
User actingUser = getUserByUoid(authorization.getUoid());
if (authorization.hasRightsOnProject(actingUser, project)) {
if (user.getUserType() == UserType.ADMIN) {
int nrAdmins = 0;
for (User authUser : project.getHasAuthorizedUsers()) {
if (authUser.getUserType() == UserType.ADMIN) {
nrAdmins++;
}
}
if (nrAdmins == 1) {
throw new UserException("User cannot be removed from this project because it is the only admin user with authorization on this project");
}
}
project.getHasAuthorizedUsers().remove(user);
user.getHasRightsOn().remove(project);
final UserRemovedFromProject userRemovedFromProject = getDatabaseSession().create(UserRemovedFromProject.class);
userRemovedFromProject.setDate(new Date());
userRemovedFromProject.setExecutor(actingUser);
userRemovedFromProject.setAccessMethod(getAccessMethod());
userRemovedFromProject.setProject(project);
userRemovedFromProject.setUser(user);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(userRemovedFromProject));
}
});
getDatabaseSession().store(user);
getDatabaseSession().store(project);
return true;
} else {
throw new UserException("Insufficient rights to remove user from project");
}
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class UpdateGeoTagDatabaseAction method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User actingUser = getUserByUoid(authorization.getUoid());
GeoTag geoTag = (GeoTag) getDatabaseSession().get(StorePackage.eINSTANCE.getGeoTag(), sGeoTag.getOid(), OldQuery.getDefault());
boolean hasRights = false;
for (Project project : geoTag.getProjects()) {
if (authorization.hasRightsOnProject(actingUser, project)) {
hasRights = true;
continue;
}
}
if (hasRights) {
geoTag.setEnabled(sGeoTag.getEnabled());
geoTag.setX(sGeoTag.getX());
geoTag.setY(sGeoTag.getY());
geoTag.setZ(sGeoTag.getZ());
geoTag.setDirectionAngle(sGeoTag.getDirectionAngle());
geoTag.setEpsg(sGeoTag.getEpsg());
final GeoTagUpdated geoTagUpdated = getDatabaseSession().create(GeoTagUpdated.class);
geoTagUpdated.setGeoTag(geoTag);
geoTagUpdated.setAccessMethod(getAccessMethod());
geoTagUpdated.setDate(new Date());
geoTagUpdated.setExecutor(actingUser);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(geoTagUpdated));
}
});
getDatabaseSession().store(geoTag);
} else {
throw new UserException("User has no rights on any projects associated with this geotag");
}
return null;
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class NotificationRegistryServiceImpl method getProgressTopicsOnProject.
@Override
public List<Long> getProgressTopicsOnProject(Long poid) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
List<Long> list = new ArrayList<Long>();
Project project = session.get(StorePackage.eINSTANCE.getProject(), poid, OldQuery.getDefault());
List<Long> revisionOids = new ArrayList<Long>();
for (Revision revision : project.getRevisions()) {
revisionOids.add(revision.getOid());
}
Set<ProgressTopic> progressOnProjectTopics = getBimServer().getNotificationsManager().getProgressOnProjectTopics(poid, revisionOids);
if (progressOnProjectTopics != null) {
for (ProgressTopic topic : progressOnProjectTopics) {
list.add(topic.getKey().getId());
}
}
return list;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.Project in project BIMserver by opensourceBIM.
the class PluginServiceImpl method getAllDeserializersForProject.
@Override
public List<SDeserializerPluginConfiguration> getAllDeserializersForProject(Boolean onlyEnabled, Long poid) throws ServerException, UserException {
requireRealUserAuthentication();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
Project project = session.get(poid, OldQuery.getDefault());
UserSettings userSettings = getUserSettings(session);
EList<DeserializerPluginConfiguration> deserializers = userSettings.getDeserializers();
List<SDeserializerPluginConfiguration> sDeserializers = new ArrayList<SDeserializerPluginConfiguration>();
for (DeserializerPluginConfiguration deserializerPluginConfiguration : deserializers) {
DeserializerPlugin plugin = getBimServer().getPluginManager().getDeserializerPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
if (plugin == null) {
StreamingDeserializerPlugin streamingPlugin = getBimServer().getPluginManager().getStreamingDeserializerPlugin(deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
if (streamingPlugin != null) {
if (streamingPlugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
if (!onlyEnabled || (deserializerPluginConfiguration.getEnabled() && deserializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
sDeserializers.add(getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration));
}
}
}
} else {
if (plugin.getSupportedSchemas().contains(Schema.valueOf(project.getSchema().toUpperCase()))) {
if (!onlyEnabled || (deserializerPluginConfiguration.getEnabled() && deserializerPluginConfiguration.getPluginDescriptor().getEnabled())) {
sDeserializers.add(getBimServer().getSConverter().convertToSObject(deserializerPluginConfiguration));
}
}
}
}
Collections.sort(sDeserializers, new SPluginConfigurationComparator());
return sDeserializers;
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
return null;
}
Aggregations