use of org.bimserver.webservices.LongTransaction in project BIMserver by opensourceBIM.
the class LowLevelServiceImpl method getAttributeAtIndex.
private Object getAttributeAtIndex(Long tid, Long oid, String attributeName, int index) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
LongTransaction transaction = getBimServer().getLongTransactionManager().get(tid);
EClass eClass = session.getEClassForOid(oid);
IdEObject object = session.get(eClass, oid, new OldQuery(transaction.getPackageMetaData(), transaction.getPid(), transaction.getRid(), transaction.getRoid(), null, Deep.NO));
if (object == null) {
throw new UserException("No object of type " + eClass.getName() + " with oid " + oid + " found");
}
Object eGet = object.eGet(object.eClass().getEStructuralFeature(attributeName));
if (eGet instanceof List) {
List<?> list = (List<?>) eGet;
return list.get(index);
}
return eGet;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.webservices.LongTransaction in project BIMserver by opensourceBIM.
the class LowLevelServiceImpl method getAttribute.
private Object getAttribute(Long tid, Long oid, String attributeName) throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
LongTransaction transaction = getBimServer().getLongTransactionManager().get(tid);
EClass eClass = session.getEClassForOid(oid);
IdEObject object = session.get(eClass, oid, new OldQuery(transaction.getPackageMetaData(), transaction.getPid(), transaction.getRid(), transaction.getRoid(), null, Deep.NO));
if (object == null) {
throw new UserException("No object of type " + eClass.getName() + " with oid " + oid + " found");
}
Object eGet = object.eGet(object.eClass().getEStructuralFeature(attributeName));
if (eGet instanceof IdEObject) {
IdEObject refObject = (IdEObject) eGet;
return refObject.eGet(refObject.eClass().getEStructuralFeature("wrappedValue"));
}
return eGet;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations