use of org.bimserver.interfaces.objects.SExtendedDataSchema in project BIMserver by opensourceBIM.
the class ServiceImpl method getAllExtendedDataSchemas.
@Override
public List<SExtendedDataSchema> getAllExtendedDataSchemas() throws ServerException, UserException {
requireAuthenticationAndRunningServer();
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
List<SExtendedDataSchema> schemas = getBimServer().getSConverter().convertToSListExtendedDataSchema(session.executeAndCommitAction(new GetAllExtendedDataSchemasDatabaseAction(session, getInternalAccessMethod())));
Collections.sort(schemas, new Comparator<SExtendedDataSchema>() {
@Override
public int compare(SExtendedDataSchema o1, SExtendedDataSchema o2) {
return o1.getName().compareTo(o2.getName());
}
});
return schemas;
} catch (Exception e) {
return handleException(e);
} finally {
session.close();
}
}
use of org.bimserver.interfaces.objects.SExtendedDataSchema in project BIMserver by opensourceBIM.
the class ServiceImpl method getExtendedDataSchemaFromRepository.
@Override
public SExtendedDataSchema getExtendedDataSchemaFromRepository(String namespace) throws UserException, ServerException {
requireRealUserAuthentication();
try {
String content = NetUtils.getContent(new URL(getServiceMap().get(SettingsInterface.class).getServiceRepositoryUrl() + "/extendeddataschemas?namespace=" + namespace), 5000);
JSONObject root = new JSONObject(new JSONTokener(content));
SExtendedDataSchema sExtendedDataSchema = new SExtendedDataSchema();
sExtendedDataSchema.setName(root.getString("name"));
sExtendedDataSchema.setContentType(root.getString("contentType"));
sExtendedDataSchema.setUrl(root.getString("url"));
return sExtendedDataSchema;
} catch (Exception e) {
return handleException(e);
}
}
use of org.bimserver.interfaces.objects.SExtendedDataSchema in project BIMserver by opensourceBIM.
the class TestAddExtendedData method start.
private void start() {
try {
BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
SFile file = new SFile();
file.setData("test".getBytes(Charsets.UTF_8));
file.setMime("text");
file.setFilename("test.txt");
long fileId = client.getServiceInterface().uploadFile(file);
System.out.println(client.getServiceInterface().getFile(fileId));
SProject project = client.getServiceInterface().addProject("test23", "ifc2x3tc1");
SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
client.checkin(project.getOid(), "initial", deserializerForExtension.getOid(), false, Flow.SYNC, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"));
project = client.getServiceInterface().getProjectByPoid(project.getOid());
SExtendedDataSchema extendedDataSchemaByNamespace = client.getServiceInterface().getExtendedDataSchemaByName("http://extend.bimserver.org/validationreport");
SExtendedData extendedData = new SExtendedData();
extendedData.setFileId(fileId);
extendedData.setTitle("test3");
extendedData.setSchemaId(extendedDataSchemaByNamespace.getOid());
client.getServiceInterface().addExtendedDataToRevision(project.getLastRevisionId(), extendedData);
} catch (ServiceException e) {
e.printStackTrace();
} catch (PublicInterfaceNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Aggregations