Search in sources :

Example 6 with SExtendedDataSchema

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();
    }
}
Also used : GetAllExtendedDataSchemasDatabaseAction(org.bimserver.database.actions.GetAllExtendedDataSchemasDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) SExtendedDataSchema(org.bimserver.interfaces.objects.SExtendedDataSchema) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Example 7 with SExtendedDataSchema

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);
    }
}
Also used : JSONTokener(org.codehaus.jettison.json.JSONTokener) SettingsInterface(org.bimserver.shared.interfaces.SettingsInterface) JSONObject(org.codehaus.jettison.json.JSONObject) SExtendedDataSchema(org.bimserver.interfaces.objects.SExtendedDataSchema) URL(java.net.URL) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Example 8 with SExtendedDataSchema

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();
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) SExtendedData(org.bimserver.interfaces.objects.SExtendedData) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) IOException(java.io.IOException) SFile(org.bimserver.interfaces.objects.SFile) SProject(org.bimserver.interfaces.objects.SProject) SExtendedDataSchema(org.bimserver.interfaces.objects.SExtendedDataSchema)

Aggregations

SExtendedDataSchema (org.bimserver.interfaces.objects.SExtendedDataSchema)8 IOException (java.io.IOException)5 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)5 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)5 ServerException (org.bimserver.shared.exceptions.ServerException)5 UserException (org.bimserver.shared.exceptions.UserException)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 MalformedURLException (java.net.MalformedURLException)4 MessagingException (javax.mail.MessagingException)4 AddressException (javax.mail.internet.AddressException)4 SExtendedData (org.bimserver.interfaces.objects.SExtendedData)4 SFile (org.bimserver.interfaces.objects.SFile)4 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)4 SerializerException (org.bimserver.plugins.serializers.SerializerException)4 BcfException (org.opensourcebim.bcf.BcfException)4 DatabaseSession (org.bimserver.database.DatabaseSession)3 SProject (org.bimserver.interfaces.objects.SProject)3 URL (java.net.URL)2 BimBotsException (org.bimserver.bimbots.BimBotsException)2 BimBotsOutput (org.bimserver.bimbots.BimBotsOutput)2