Search in sources :

Example 56 with BimServerClientInterface

use of org.bimserver.plugins.services.BimServerClientInterface 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 57 with BimServerClientInterface

use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.

the class TestChangeDescription method start.

private void start() {
    BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
    try {
        SProject project = client.getServiceInterface().getProjectsByName("dfgfgdf").get(0);
        IfcModelInterface model = client.getModel(project, project.getLastRevisionId(), false, true);
        for (IfcWall wall : model.getAllWithSubTypes(IfcWall.class)) {
            wall.setDescription(wall.getDescription() + " Changed");
        }
        model.commit("test");
    } catch (UserException e) {
        e.printStackTrace();
    } catch (ServerException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    }
}
Also used : IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) ServerException(org.bimserver.shared.exceptions.ServerException) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) UserException(org.bimserver.shared.exceptions.UserException) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Example 58 with BimServerClientInterface

use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.

the class TestChangeWrappedValue method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        long poid = 2686977;
        long roid = 720899;
        SProject project = client.getServiceInterface().getProjectByPoid(poid);
        IfcModelInterface model = client.getModel(project, roid, true, false);
        for (IfcPropertySingleValue prop : model.getAll(IfcPropertySingleValue.class)) {
            // IfcValue value = ((IfcPropertySingleValue) prop).getNominalValue();
            // if(value instanceof IfcLabel){
            // System.out.println(prop.getOid() + " is " + ((IfcLabel) value).getWrappedValue() );
            // ((IfcLabel) value).setWrappedValue(((IfcLabel) value).getWrappedValue() + " changed");
            // }
            IfcLabel label = model.create(IfcLabel.class);
            label.setWrappedValue("blabla");
            prop.setNominalValue(label);
        }
        model.commit("blaat");
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
        e.printStackTrace();
    }
}
Also used : IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) IfcPropertySingleValue(org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue) IfcLabel(org.bimserver.models.ifc2x3tc1.IfcLabel) ServiceException(org.bimserver.shared.exceptions.ServiceException) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Example 59 with BimServerClientInterface

use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.

the class TestDownloadBinaryGeometrySimultanous method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        final SSerializerPluginConfiguration serializer = client.getServiceInterface().getSerializerByName("BinaryGeometrySerializer");
        SProject project = client.getServiceInterface().getProjectByPoid(131073L);
        for (int i = 0; i < 10; i++) {
            Thread.sleep(200);
            new Runner(client, serializer, project, i).start();
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject)

Example 60 with BimServerClientInterface

use of org.bimserver.plugins.services.BimServerClientInterface in project BIMserver by opensourceBIM.

the class TestManyUsersAndLogin method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        int nrUsers = 10000;
        long totalTimeAdding = 0;
        List<Long> userIds = new ArrayList<>();
        for (int i = 0; i < nrUsers; i++) {
            long s = System.nanoTime();
            try {
                SUser user = client.getServiceInterface().addUserWithPassword("test" + i + "@bimserver.org", "password", "Test " + i, SUserType.USER, true, "");
                userIds.add(user.getOid());
            } catch (Exception e) {
            }
            long e = System.nanoTime();
            totalTimeAdding += (e - s);
            if (i % 100 == 0) {
                System.out.println((totalTimeAdding / 1000000) + " ms for 100 users");
                totalTimeAdding = 0;
            }
        }
        long totalLoginTime = 0;
        int nrProjects = 10000;
        totalTimeAdding = 0;
        List<Long> projectIds = new ArrayList<>();
        for (int i = 0; i < nrProjects; i++) {
            long s = System.nanoTime();
            try {
                SProject project = client.getServiceInterface().addProject("test" + i, "ifc2x3tc1");
                projectIds.add(project.getOid());
            } catch (Exception e) {
            }
            long e = System.nanoTime();
            totalTimeAdding += (e - s);
            if (i % 100 == 0) {
                System.out.println((totalTimeAdding / 1000000) + " ms for 100 projects");
                totalTimeAdding = 0;
            }
        }
        int nrProjectUserLinks = 100000;
        Random random = new Random();
        totalTimeAdding = 0;
        for (int i = 0; i < nrProjectUserLinks; i++) {
            long s = System.nanoTime();
            client.getServiceInterface().addUserToProject(userIds.get(random.nextInt(userIds.size())), projectIds.get(random.nextInt(projectIds.size())));
            long e = System.nanoTime();
            totalTimeAdding += (e - s);
            if (i % 100 == 0) {
                System.out.println((totalTimeAdding / 1000000) + " ms for 100 projects/user links");
                totalTimeAdding = 0;
            }
        }
        int loginAttempts = 100;
        for (int i = 0; i < loginAttempts; i++) {
            long s = System.nanoTime();
            client.getAuthInterface().login("test" + new Random().nextInt(nrUsers) + "@bimserver.org", "password");
            long e = System.nanoTime();
            totalLoginTime += (e - s);
        }
        System.out.println("Average login time with " + nrUsers + " users in system: " + ((((totalLoginTime / loginAttempts) / 1000000) + " ms")));
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : Random(java.util.Random) ServiceException(org.bimserver.shared.exceptions.ServiceException) SUser(org.bimserver.interfaces.objects.SUser) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) ArrayList(java.util.ArrayList) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) ServiceException(org.bimserver.shared.exceptions.ServiceException)

Aggregations

BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)66 SProject (org.bimserver.interfaces.objects.SProject)57 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)46 Test (org.junit.Test)40 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)31 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)23 IfcModelInterface (org.bimserver.emf.IfcModelInterface)20 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)20 URL (java.net.URL)19 LowLevelInterface (org.bimserver.shared.interfaces.LowLevelInterface)19 IOException (java.io.IOException)16 ServiceException (org.bimserver.shared.exceptions.ServiceException)15 UserException (org.bimserver.shared.exceptions.UserException)13 ServerException (org.bimserver.shared.exceptions.ServerException)11 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)10 Path (java.nio.file.Path)8 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)7 BimServerClientFactory (org.bimserver.shared.BimServerClientFactory)7 IfcPropertySingleValue (org.bimserver.models.ifc2x3tc1.IfcPropertySingleValue)6 File (java.io.File)4