use of org.bimserver.interfaces.objects.SModelCheckerInstance in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllRepositoryModelCheckers.
@Override
public List<SModelCheckerInstance> getAllRepositoryModelCheckers() throws ServerException, UserException {
requireRealUserAuthentication();
try {
List<SModelCheckerInstance> modelCheckers = new ArrayList<SModelCheckerInstance>();
String content = NetUtils.getContent(new URL(getServiceMap().get(SettingsInterface.class).getServiceRepositoryUrl() + "/modelcheckers"), 5000);
JSONObject root = new JSONObject(new JSONTokener(content));
JSONArray modelCheckersJson = root.getJSONArray("modelcheckers");
for (int i = 0; i < modelCheckersJson.length(); i++) {
JSONObject modelCheckerJson = modelCheckersJson.getJSONObject(i);
SModelCheckerInstance sModelChecker = new SModelCheckerInstance();
sModelChecker.setName(modelCheckerJson.getString("name"));
sModelChecker.setCode(modelCheckerJson.getString("code"));
sModelChecker.setDescription(modelCheckerJson.getString("description"));
sModelChecker.setModelCheckerPluginClassName(modelCheckerJson.getString("modelCheckerPluginClassName"));
modelCheckers.add(sModelChecker);
}
return modelCheckers;
} catch (Exception e) {
return handleException(e);
}
}
use of org.bimserver.interfaces.objects.SModelCheckerInstance in project BIMserver by opensourceBIM.
the class ServiceImpl method addModelChecker.
@Override
public Long addModelChecker(SModelCheckerInstance modelCheckerInstance) throws UserException, ServerException {
requireAdminAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
ModelCheckerInstance convert = getBimServer().getSConverter().convertFromSObject(modelCheckerInstance, session);
return session.executeAndCommitAction(new AddModelCheckerDatabaseAction(session, getInternalAccessMethod(), convert));
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
Aggregations