use of org.bimserver.models.store.ExtendedData in project BIMserver by opensourceBIM.
the class ServiceImpl method addExtendedDataToProject.
@Override
public void addExtendedDataToProject(Long poid, SExtendedData extendedData) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
ExtendedData convert = getBimServer().getSConverter().convertFromSObject(extendedData, session);
session.executeAndCommitAction(new AddExtendedDataToProjectDatabaseAction(getBimServer(), session, getInternalAccessMethod(), poid, convert, getAuthorization()));
} catch (Exception e) {
handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.ExtendedData in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllExtendedDataOfRevisionAndSchema.
@Override
public List<SExtendedData> getAllExtendedDataOfRevisionAndSchema(Long roid, Long schemaId) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
Revision revision = (Revision) session.get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
if (revision == null) {
throw new UserException("No revision found with roid " + roid);
}
EList<ExtendedData> list = revision.getExtendedData();
List<SExtendedData> result = new ArrayList<>();
for (ExtendedData extendedData : list) {
if (extendedData.getSchema().getOid() == schemaId) {
result.add(getBimServer().getSConverter().convertToSObject(extendedData));
}
}
return result;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.models.store.ExtendedData in project BIMserver by opensourceBIM.
the class ServiceImpl method getLastExtendedDataOfRevisionAndSchema.
@Override
public SExtendedData getLastExtendedDataOfRevisionAndSchema(Long roid, Long schemaId) throws ServerException, UserException {
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
Revision revision = (Revision) session.get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
if (revision == null) {
throw new UserException("No revision found with roid " + roid);
}
EList<ExtendedData> list = revision.getExtendedData();
ExtendedData last = null;
for (ExtendedData extendedData : list) {
if (extendedData.getSchema().getOid() == schemaId) {
if (last == null || last.getAdded().before(extendedData.getAdded())) {
last = extendedData;
}
}
}
if (last != null) {
return getBimServer().getSConverter().convertToSObject(last);
}
return null;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations