Search in sources :

Example 61 with SProject

use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.

the class ServiceImpl method getProjectByPoid.

@Override
public SProject getProjectByPoid(Long poid) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        GetProjectByPoidDatabaseAction action = new GetProjectByPoidDatabaseAction(session, getInternalAccessMethod(), poid, getAuthorization());
        SProject result = getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
        return result;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : GetProjectByPoidDatabaseAction(org.bimserver.database.actions.GetProjectByPoidDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) SProject(org.bimserver.interfaces.objects.SProject) 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 62 with SProject

use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.

the class ServiceImpl method getSubProjects.

@Override
public List<SProject> getSubProjects(Long poid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Set<Project>> action = new GetSubProjectsDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), poid);
        List<SProject> convertToSListProject = getBimServer().getSConverter().convertToSListProject(session.executeAndCommitAction(action));
        Collections.sort(convertToSListProject, new SProjectComparator());
        return convertToSListProject;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : GetSubProjectsDatabaseAction(org.bimserver.database.actions.GetSubProjectsDatabaseAction) SProjectComparator(org.bimserver.webservices.SProjectComparator) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) DatabaseSession(org.bimserver.database.DatabaseSession) SProject(org.bimserver.interfaces.objects.SProject) 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 63 with SProject

use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.

the class ServiceImpl method addProject.

@Override
public SProject addProject(String projectName, String schema) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Project> action = new AddProjectDatabaseAction(getBimServer(), session, getInternalAccessMethod(), projectName, schema, getAuthorization());
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : Project(org.bimserver.models.store.Project) SProject(org.bimserver.interfaces.objects.SProject) DatabaseSession(org.bimserver.database.DatabaseSession) AddProjectDatabaseAction(org.bimserver.database.actions.AddProjectDatabaseAction) 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 64 with SProject

use of org.bimserver.interfaces.objects.SProject in project BIMserver by opensourceBIM.

the class LoadFullDirectory method loadDirectoryRecursive.

private void loadDirectoryRecursive(Path path, SProject parent) {
    try {
        for (Path p : PathUtils.list(path)) {
            if (Files.isDirectory(p)) {
                String projectName = p.getFileName().toString();
                SProject project = createProjectIfNotExists(parent, projectName);
                if (project != null) {
                    loadDirectoryRecursive(p, project);
                }
            } else {
                String projectName = p.getFileName().toString();
                SProject project = createProjectIfNotExists(parent, projectName);
                loadFile(p, project);
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject)

Example 65 with SProject

use of org.bimserver.interfaces.objects.SProject 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

SProject (org.bimserver.interfaces.objects.SProject)79 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)57 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)45 Test (org.junit.Test)39 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)37 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)24 UserException (org.bimserver.shared.exceptions.UserException)24 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)22 IOException (java.io.IOException)21 IfcModelInterface (org.bimserver.emf.IfcModelInterface)21 ServerException (org.bimserver.shared.exceptions.ServerException)20 URL (java.net.URL)19 LowLevelInterface (org.bimserver.shared.interfaces.LowLevelInterface)18 ServiceException (org.bimserver.shared.exceptions.ServiceException)16 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)12 Path (java.nio.file.Path)10 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)9 DatabaseSession (org.bimserver.database.DatabaseSession)8 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)7 SerializerException (org.bimserver.plugins.serializers.SerializerException)7