Search in sources :

Example 36 with SDeserializerPluginConfiguration

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

the class TestContainedInStructure method test.

@Test
public void test() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Get the service interface
        bimServerClient.getSettingsInterface().setGenerateGeometryOnCheckin(false);
        // Create a new project
        SProject newProject = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Get the appropriate deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject.getOid());
        // Checkin the file
        bimServerClient.checkin(newProject.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // Refresh project info
        newProject = bimServerClient.getServiceInterface().getProjectByPoid(newProject.getOid());
        IfcModelInterface model = bimServerClient.getModel(newProject, newProject.getLastRevisionId(), true, false);
        for (IfcFurnishingElement ifcFurnishingElement : model.getAllWithSubTypes(IfcFurnishingElement.class)) {
            System.out.println(ifcFurnishingElement);
            for (IfcRelContainedInSpatialStructure ifcRelContainedInSpatialStructure : ifcFurnishingElement.getContainedInStructure()) {
                System.out.println(ifcRelContainedInSpatialStructure.getRelatingStructure());
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) IfcModelInterface(org.bimserver.emf.IfcModelInterface) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) IfcRelContainedInSpatialStructure(org.bimserver.models.ifc2x3tc1.IfcRelContainedInSpatialStructure) SProject(org.bimserver.interfaces.objects.SProject) URL(java.net.URL) Test(org.junit.Test)

Example 37 with SDeserializerPluginConfiguration

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

the class ServiceImpl method triggerRevisionService.

@Override
public void triggerRevisionService(Long roid, Long soid) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        Revision revision = (Revision) session.get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
        if (revision == null) {
            throw new UserException("No revision found for roid " + roid);
        }
        NewService newService = session.get(StorePackage.eINSTANCE.getNewService(), soid, OldQuery.getDefault());
        if (revision.getServicesLinked().contains(newService)) {
            // We don't want no loops
            return;
        }
        String url = newService.getResourceUrl();
        SerializerPluginConfiguration serializer = newService.getSerializer();
        PackageMetaData pmd = getBimServer().getMetaDataManager().getPackageMetaData(revision.getProject().getSchema());
        Query query = DefaultQueries.all(pmd);
        Long topicId = download(Collections.singleton(roid), new JsonQueryObjectModelConverter(pmd).toJson(query).toString(), serializer.getOid(), false);
        CloseableHttpClient httpclient = HttpClients.createDefault();
        HttpPost httpPost = new HttpPost(url);
        LongAction<?> longAction = getBimServer().getLongActionManager().getLongAction(topicId);
        if (longAction == null) {
            throw new UserException("No data found for topicId " + topicId);
        }
        SCheckoutResult result;
        if (longAction instanceof LongStreamingDownloadAction) {
            LongStreamingDownloadAction longStreamingDownloadAction = (LongStreamingDownloadAction) longAction;
            if (longStreamingDownloadAction.getErrors().isEmpty()) {
                try {
                    result = longStreamingDownloadAction.getCheckoutResult();
                } catch (SerializerException e) {
                    throw new UserException(e);
                }
            } else {
                LOGGER.error(longStreamingDownloadAction.getErrors().get(0));
                throw new ServerException(longStreamingDownloadAction.getErrors().get(0));
            }
        } else {
            LongDownloadOrCheckoutAction longDownloadAction = (LongDownloadOrCheckoutAction) longAction;
            try {
                longDownloadAction.waitForCompletion();
                if (longDownloadAction.getErrors().isEmpty()) {
                    result = longDownloadAction.getCheckoutResult();
                } else {
                    LOGGER.error(longDownloadAction.getErrors().get(0));
                    throw new ServerException(longDownloadAction.getErrors().get(0));
                }
            } catch (Exception e) {
                LOGGER.error("", e);
                throw new ServerException(e);
            }
        }
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        LOGGER.info("Starting serialization");
        DataSource datasource = result.getFile().getDataSource();
        if (datasource instanceof ExtendedDataSource) {
            ((ExtendedDataSource) datasource).writeToOutputStream(baos, null);
        }
        LOGGER.info("Serialization done");
        if (newService.getAccessToken() != null) {
            httpPost.setHeader("Authorization", "Bearer " + newService.getAccessToken());
        }
        httpPost.setHeader("Input-Type", newService.getInput());
        httpPost.setHeader("Output-Type", newService.getOutput());
        httpPost.setEntity(new ByteArrayEntity(baos.toByteArray()));
        CloseableHttpResponse response = httpclient.execute(httpPost);
        LOGGER.info(response.getStatusLine().toString());
        if (response.getStatusLine().getStatusCode() == 401) {
            throw new UserException("Remote service responded with a 401 Unauthorized");
        } else if (response.getStatusLine().getStatusCode() == 200) {
            Header[] headers = response.getHeaders("Content-Disposition");
            String filename = "unknown";
            if (headers.length > 0) {
                String contentDisposition = headers[0].getValue();
                if (contentDisposition.contains("filename=")) {
                    int indexOf = contentDisposition.indexOf("filename=") + 10;
                    filename = contentDisposition.substring(indexOf, contentDisposition.indexOf("\"", indexOf + 1));
                } else {
                    filename = contentDisposition;
                }
            }
            Header dataTitleHeader = response.getFirstHeader("Data-Title");
            String dataTitle = newService.getName() + " Results";
            if (dataTitleHeader != null) {
                dataTitle = dataTitleHeader.getValue();
            }
            byte[] responseBytes = ByteStreams.toByteArray(response.getEntity().getContent());
            Action action = newService.getAction();
            if (action instanceof StoreExtendedData) {
                SFile file = new SFile();
                file.setData(responseBytes);
                file.setFilename(filename);
                file.setSize(responseBytes.length);
                file.setMime(response.getHeaders("Content-Type")[0].getValue());
                Long fileId = uploadFile(file);
                SExtendedData extendedData = new SExtendedData();
                extendedData.setAdded(new Date());
                extendedData.setRevisionId(roid);
                extendedData.setTitle(dataTitle);
                extendedData.setSize(responseBytes.length);
                extendedData.setFileId(fileId);
                extendedData.setSchemaId(getExtendedDataSchemaByName(newService.getOutput()).getOid());
                addExtendedDataToRevision(roid, extendedData);
            } else if (action instanceof CheckinRevision) {
                CheckinRevision checkinRevision = (CheckinRevision) action;
                Project targetProject = checkinRevision.getProject();
                String extension = filename.substring(filename.lastIndexOf(".") + 1);
                SDeserializerPluginConfiguration deserializer = getSuggestedDeserializerForExtension(extension, targetProject.getOid());
                Long checkingTopicId = initiateCheckin(targetProject.getOid(), deserializer.getOid());
                checkinInitiatedInternal(checkingTopicId, targetProject.getOid(), dataTitle, deserializer.getOid(), (long) responseBytes.length, filename, new DataHandler(new ByteArrayDataSource(responseBytes, "ifc")), false, true, newService.getOid());
            }
        } else {
            throw new UserException("Remote service responded with a " + response.getStatusLine());
        }
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) CheckinDatabaseAction(org.bimserver.database.actions.CheckinDatabaseAction) GetDeserializerByIdDatabaseAction(org.bimserver.database.actions.GetDeserializerByIdDatabaseAction) GetAllReadableProjectsDatabaseAction(org.bimserver.database.actions.GetAllReadableProjectsDatabaseAction) AddModelCheckerToProjectDatabaseAction(org.bimserver.database.actions.AddModelCheckerToProjectDatabaseAction) GetProjectsByNameDatabaseAction(org.bimserver.database.actions.GetProjectsByNameDatabaseAction) AddProjectDatabaseAction(org.bimserver.database.actions.AddProjectDatabaseAction) LongCheckinAction(org.bimserver.longaction.LongCheckinAction) GetUserByUoidDatabaseAction(org.bimserver.database.actions.GetUserByUoidDatabaseAction) UpdateProjectDatabaseAction(org.bimserver.database.actions.UpdateProjectDatabaseAction) BimDatabaseAction(org.bimserver.database.actions.BimDatabaseAction) GetAllExtendedDataSchemasDatabaseAction(org.bimserver.database.actions.GetAllExtendedDataSchemasDatabaseAction) UserHasRightsDatabaseAction(org.bimserver.database.actions.UserHasRightsDatabaseAction) GetAllNewServicesOfProjectDatabaseAction(org.bimserver.database.actions.GetAllNewServicesOfProjectDatabaseAction) LongBranchAction(org.bimserver.longaction.LongBranchAction) AddExtendedDataToProjectDatabaseAction(org.bimserver.database.actions.AddExtendedDataToProjectDatabaseAction) GetSerializerByContentTypeDatabaseAction(org.bimserver.database.actions.GetSerializerByContentTypeDatabaseAction) GetSubProjectsDatabaseAction(org.bimserver.database.actions.GetSubProjectsDatabaseAction) SAction(org.bimserver.interfaces.objects.SAction) LongStreamingDownloadAction(org.bimserver.longaction.LongStreamingDownloadAction) GetModelCheckerOidDatabaseAction(org.bimserver.database.actions.GetModelCheckerOidDatabaseAction) BranchToExistingProjectDatabaseAction(org.bimserver.database.actions.BranchToExistingProjectDatabaseAction) RegenerateGeometryDatabaseAction(org.bimserver.database.actions.RegenerateGeometryDatabaseAction) GetAllAuthorizedUsersOfProjectDatabaseAction(org.bimserver.database.actions.GetAllAuthorizedUsersOfProjectDatabaseAction) GetAllCheckoutsOfRevisionDatabaseAction(org.bimserver.database.actions.GetAllCheckoutsOfRevisionDatabaseAction) ChangeUserTypeDatabaseAction(org.bimserver.database.actions.ChangeUserTypeDatabaseAction) GetAvailableClassesDatabaseAction(org.bimserver.database.actions.GetAvailableClassesDatabaseAction) GetProjectByPoidDatabaseAction(org.bimserver.database.actions.GetProjectByPoidDatabaseAction) RemoveServiceFromProjectDatabaseAction(org.bimserver.database.actions.RemoveServiceFromProjectDatabaseAction) StreamingCheckinDatabaseAction(org.bimserver.database.actions.StreamingCheckinDatabaseAction) UploadFileDatabaseAction(org.bimserver.database.actions.UploadFileDatabaseAction) DeleteUserDatabaseAction(org.bimserver.database.actions.DeleteUserDatabaseAction) LongGenericAction(org.bimserver.longaction.LongGenericAction) AddUserDatabaseAction(org.bimserver.database.actions.AddUserDatabaseAction) GetQueryEngineByNameDatabaseAction(org.bimserver.database.actions.GetQueryEngineByNameDatabaseAction) RemoveNewServiceFromProjectDatabaseAction(org.bimserver.database.actions.RemoveNewServiceFromProjectDatabaseAction) GetAllProjectsSmallDatabaseAction(org.bimserver.database.actions.GetAllProjectsSmallDatabaseAction) RemoveModelCheckerFromProjectDatabaseAction(org.bimserver.database.actions.RemoveModelCheckerFromProjectDatabaseAction) LongAction(org.bimserver.longaction.LongAction) LongDownloadAction(org.bimserver.longaction.LongDownloadAction) GetAllUsersDatabaseAction(org.bimserver.database.actions.GetAllUsersDatabaseAction) GetAllProjectsDatabaseAction(org.bimserver.database.actions.GetAllProjectsDatabaseAction) LongDownloadOrCheckoutAction(org.bimserver.longaction.LongDownloadOrCheckoutAction) GetRevisionSummaryDatabaseAction(org.bimserver.database.actions.GetRevisionSummaryDatabaseAction) UndeleteUserDatabaseAction(org.bimserver.database.actions.UndeleteUserDatabaseAction) GetSerializerByIdDatabaseAction(org.bimserver.database.actions.GetSerializerByIdDatabaseAction) GetAllWritableProjectsDatabaseAction(org.bimserver.database.actions.GetAllWritableProjectsDatabaseAction) SetRevisionTagDatabaseAction(org.bimserver.database.actions.SetRevisionTagDatabaseAction) GetExtendedDataSchemaByIdDatabaseAction(org.bimserver.database.actions.GetExtendedDataSchemaByIdDatabaseAction) GetOidByGuidDatabaseAction(org.bimserver.database.actions.GetOidByGuidDatabaseAction) AddExtendedDataSchemaDatabaseAction(org.bimserver.database.actions.AddExtendedDataSchemaDatabaseAction) RemoveUserFromExtendedDataSchemaDatabaseAction(org.bimserver.database.actions.RemoveUserFromExtendedDataSchemaDatabaseAction) GetUserByUserNameDatabaseAction(org.bimserver.database.actions.GetUserByUserNameDatabaseAction) GetAllRevisionsByUserDatabaseAction(org.bimserver.database.actions.GetAllRevisionsByUserDatabaseAction) GetSerializerByNameDatabaseAction(org.bimserver.database.actions.GetSerializerByNameDatabaseAction) GetIfcHeaderDatabaseAction(org.bimserver.database.actions.GetIfcHeaderDatabaseAction) GetCheckoutWarningsDatabaseAction(org.bimserver.database.actions.GetCheckoutWarningsDatabaseAction) GetQueryEngineByIdDatabaseAction(org.bimserver.database.actions.GetQueryEngineByIdDatabaseAction) UpdateRevisionDatabaseAction(org.bimserver.database.actions.UpdateRevisionDatabaseAction) BranchToNewProjectDatabaseAction(org.bimserver.database.actions.BranchToNewProjectDatabaseAction) AddServiceToProjectDatabaseAction(org.bimserver.database.actions.AddServiceToProjectDatabaseAction) GetTopLevelProjectByNameDatabaseAction(org.bimserver.database.actions.GetTopLevelProjectByNameDatabaseAction) GetAllRelatedProjectsDatabaseAction(org.bimserver.database.actions.GetAllRelatedProjectsDatabaseAction) DeleteServiceDatabaseAction(org.bimserver.database.actions.DeleteServiceDatabaseAction) GetDeserializerByNameDatabaseAction(org.bimserver.database.actions.GetDeserializerByNameDatabaseAction) AddLocalServiceToProjectDatabaseAction(org.bimserver.database.actions.AddLocalServiceToProjectDatabaseAction) GetAllCheckoutsOfProjectDatabaseAction(org.bimserver.database.actions.GetAllCheckoutsOfProjectDatabaseAction) LogAction(org.bimserver.models.log.LogAction) GetAllCheckoutsByUserDatabaseAction(org.bimserver.database.actions.GetAllCheckoutsByUserDatabaseAction) GetVolumeDatabaseAction(org.bimserver.database.actions.GetVolumeDatabaseAction) LongCheckoutAction(org.bimserver.longaction.LongCheckoutAction) UpdateModelCheckerDatabaseAction(org.bimserver.database.actions.UpdateModelCheckerDatabaseAction) UpdateGeoTagDatabaseAction(org.bimserver.database.actions.UpdateGeoTagDatabaseAction) Action(org.bimserver.models.store.Action) AddExtendedDataToRevisionDatabaseAction(org.bimserver.database.actions.AddExtendedDataToRevisionDatabaseAction) DeleteProjectDatabaseAction(org.bimserver.database.actions.DeleteProjectDatabaseAction) GetExtendedDataSchemaByNameDatabaseAction(org.bimserver.database.actions.GetExtendedDataSchemaByNameDatabaseAction) RemoveUserFromProjectDatabaseAction(org.bimserver.database.actions.RemoveUserFromProjectDatabaseAction) GetExtendedDataByIdDatabaseAction(org.bimserver.database.actions.GetExtendedDataByIdDatabaseAction) GetAllRevisionsOfProjectDatabaseAction(org.bimserver.database.actions.GetAllRevisionsOfProjectDatabaseAction) GetProjectsOfUserDatabaseAction(org.bimserver.database.actions.GetProjectsOfUserDatabaseAction) SLogAction(org.bimserver.interfaces.objects.SLogAction) AddUserToExtendedDataSchemaDatabaseAction(org.bimserver.database.actions.AddUserToExtendedDataSchemaDatabaseAction) GetSubProjectByNameDatabaseAction(org.bimserver.database.actions.GetSubProjectByNameDatabaseAction) GetNrPrimitivesDatabaseAction(org.bimserver.database.actions.GetNrPrimitivesDatabaseAction) GetRevisionDatabaseAction(org.bimserver.database.actions.GetRevisionDatabaseAction) ValidateModelCheckerDatabaseAction(org.bimserver.database.actions.ValidateModelCheckerDatabaseAction) AddNewServiceToProjectDatabaseAction(org.bimserver.database.actions.AddNewServiceToProjectDatabaseAction) LongStreamingCheckinAction(org.bimserver.longaction.LongStreamingCheckinAction) UndeleteProjectDatabaseAction(org.bimserver.database.actions.UndeleteProjectDatabaseAction) CompareDatabaseAction(org.bimserver.database.actions.CompareDatabaseAction) GetAllNonAuthorizedProjectsOfUserDatabaseAction(org.bimserver.database.actions.GetAllNonAuthorizedProjectsOfUserDatabaseAction) GetAllServicesOfProjectDatabaseAction(org.bimserver.database.actions.GetAllServicesOfProjectDatabaseAction) GetGeometryInfoDatabaseAction(org.bimserver.database.actions.GetGeometryInfoDatabaseAction) GetAvailableClassesInRevisionDatabaseAction(org.bimserver.database.actions.GetAvailableClassesInRevisionDatabaseAction) AddModelCheckerDatabaseAction(org.bimserver.database.actions.AddModelCheckerDatabaseAction) AddUserToProjectDatabaseAction(org.bimserver.database.actions.AddUserToProjectDatabaseAction) GetCheckinWarningsDatabaseAction(org.bimserver.database.actions.GetCheckinWarningsDatabaseAction) UserHasCheckinRightsDatabaseAction(org.bimserver.database.actions.UserHasCheckinRightsDatabaseAction) GetAreaDatabaseAction(org.bimserver.database.actions.GetAreaDatabaseAction) GetGeoTagDatabaseAction(org.bimserver.database.actions.GetGeoTagDatabaseAction) GetAllNonAuthorizedUsersOfProjectDatabaseAction(org.bimserver.database.actions.GetAllNonAuthorizedUsersOfProjectDatabaseAction) GetAllModelCheckersDatabaseAction(org.bimserver.database.actions.GetAllModelCheckersDatabaseAction) JsonQueryObjectModelConverter(org.bimserver.database.queries.om.JsonQueryObjectModelConverter) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) Query(org.bimserver.database.queries.om.Query) OldQuery(org.bimserver.database.OldQuery) DatabaseSession(org.bimserver.database.DatabaseSession) SCheckoutResult(org.bimserver.interfaces.objects.SCheckoutResult) LongStreamingDownloadAction(org.bimserver.longaction.LongStreamingDownloadAction) DataHandler(javax.activation.DataHandler) CheckinRevision(org.bimserver.models.store.CheckinRevision) LongDownloadOrCheckoutAction(org.bimserver.longaction.LongDownloadOrCheckoutAction) ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) UserException(org.bimserver.shared.exceptions.UserException) SFile(org.bimserver.interfaces.objects.SFile) NewService(org.bimserver.models.store.NewService) SNewService(org.bimserver.interfaces.objects.SNewService) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) ServerException(org.bimserver.shared.exceptions.ServerException) PackageMetaData(org.bimserver.emf.PackageMetaData) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SerializerException(org.bimserver.plugins.serializers.SerializerException) 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) Date(java.util.Date) ByteArrayDataSource(javax.mail.util.ByteArrayDataSource) ExtendedDataSource(org.bimserver.plugins.serializers.ExtendedDataSource) DataSource(javax.activation.DataSource) StoreExtendedData(org.bimserver.models.store.StoreExtendedData) Project(org.bimserver.models.store.Project) SProject(org.bimserver.interfaces.objects.SProject) ExtendedDataSource(org.bimserver.plugins.serializers.ExtendedDataSource) SRevision(org.bimserver.interfaces.objects.SRevision) Revision(org.bimserver.models.store.Revision) CheckinRevision(org.bimserver.models.store.CheckinRevision) SExtendedDataAddedToRevision(org.bimserver.interfaces.objects.SExtendedDataAddedToRevision) SIfcHeader(org.bimserver.interfaces.objects.SIfcHeader) Header(org.apache.http.Header) SExtendedData(org.bimserver.interfaces.objects.SExtendedData) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration)

Example 38 with SDeserializerPluginConfiguration

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

Example 39 with SDeserializerPluginConfiguration

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

the class TestBigFilesRemote method start.

private void start(String[] args) {
    String address = args[0];
    String username = args[1];
    String password = args[2];
    String basepath = args[3];
    System.out.println("Address: " + address);
    System.out.println("Username: " + username);
    System.out.println("Password: " + password);
    System.out.println("Basepath: " + basepath);
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory(null, address)) {
        BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo(args[1], args[2]));
        String[] fileNames = new String[] { "4NC Whole Model.ifc", "1006 General withIFC_exportLayerCombos.ifc", "12001_17 MOS_AC17SpecialBigVersion.ifc", "12510_MASTER_Drofus_Test.ifc", "BondBryan10-134 (06) Proposed Site-1.ifc", "HLM_39090_12259 University of Sheffield NEB  [PR-BIM-01-bhelberg].ifc" };
        DateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy hh:mm:ss");
        for (String fileName : fileNames) {
            String projectName = fileName.substring(0, fileName.lastIndexOf(".ifc"));
            List<SProject> projectsByName = client.getServiceInterface().getProjectsByName(projectName);
            SProject project = null;
            if (projectsByName.size() == 1) {
                project = projectsByName.get(0);
            } else {
                System.out.println("Creating project " + fileName);
                project = client.getServiceInterface().addProject(projectName, "ifc2x3tc1");
            }
            SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            System.out.println(dateFormat.format(new Date()));
            SDatabaseInformation databaseInformation = client.getAdminInterface().getDatabaseInformation();
            System.out.println("Database size: " + Formatters.bytesToString(databaseInformation.getDatabaseSizeInBytes()) + " (" + databaseInformation.getDatabaseSizeInBytes() + ")");
            SJavaInfo javaInfo = client.getAdminInterface().getJavaInfo();
            System.out.println("Used: " + Formatters.bytesToString(javaInfo.getHeapUsed()) + ", Free: " + Formatters.bytesToString(javaInfo.getHeapFree()) + ", Max: " + Formatters.bytesToString(javaInfo.getHeapMax()) + ", Total: " + Formatters.bytesToString(javaInfo.getHeapTotal()));
            String downloadUrl = basepath + UrlEscapers.urlPathSegmentEscaper().escape(fileName);
            System.out.println("Download URL: " + downloadUrl);
            client.getServiceInterface().checkinFromUrl(project.getOid(), fileName, deserializer.getOid(), fileName, downloadUrl, false, true);
            System.out.println("Done checking in " + fileName);
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (ChannelConnectionException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) SDatabaseInformation(org.bimserver.interfaces.objects.SDatabaseInformation) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClient(org.bimserver.client.BimServerClient) Date(java.util.Date) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) ServiceException(org.bimserver.shared.exceptions.ServiceException) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) SJavaInfo(org.bimserver.interfaces.objects.SJavaInfo) SimpleDateFormat(java.text.SimpleDateFormat)

Example 40 with SDeserializerPluginConfiguration

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

the class TestMultiple method main.

public static void main(String[] args) throws InterruptedException {
    try (BimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        BimServerClientInterface client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        ThreadPoolExecutor executor = new ThreadPoolExecutor(2, 2, 1, TimeUnit.DAYS, new ArrayBlockingQueue<>(2));
        for (int i = 0; i < 2; i++) {
            executor.submit(new Runnable() {

                @Override
                public void run() {
                    try {
                        SProject project = client.getServiceInterface().addProject("P" + new Random().nextInt(), "ifc2x3tc1");
                        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
                        client.checkin(project.getOid(), "Test", deserializer.getOid(), false, Flow.ASYNC, Paths.get("C:\\Git\\TestFiles\\TestData\\data\\HITOS_070308.ifc"));
                    } catch (ServerException e) {
                        e.printStackTrace();
                    } catch (UserException e) {
                        e.printStackTrace();
                    } catch (PublicInterfaceNotFoundException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        executor.shutdown();
        executor.awaitTermination(1, TimeUnit.HOURS);
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (ChannelConnectionException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ServerException(org.bimserver.shared.exceptions.ServerException) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException) UserException(org.bimserver.shared.exceptions.UserException) ServerException(org.bimserver.shared.exceptions.ServerException) Random(java.util.Random) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) UserException(org.bimserver.shared.exceptions.UserException)

Aggregations

SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)45 SProject (org.bimserver.interfaces.objects.SProject)39 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)31 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)27 Test (org.junit.Test)21 IOException (java.io.IOException)19 URL (java.net.URL)19 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)18 UserException (org.bimserver.shared.exceptions.UserException)16 IfcModelInterface (org.bimserver.emf.IfcModelInterface)15 ServerException (org.bimserver.shared.exceptions.ServerException)15 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)12 Path (java.nio.file.Path)9 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)9 DatabaseSession (org.bimserver.database.DatabaseSession)8 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)7 ServiceException (org.bimserver.shared.exceptions.ServiceException)7 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)5 IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)5 DeserializerPluginConfiguration (org.bimserver.models.store.DeserializerPluginConfiguration)5