Search in sources :

Example 61 with BimServerClientInterface

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

Example 62 with BimServerClientInterface

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

the class TestNotification method main.

@SuppressWarnings("unused")
public static void main(String[] args) {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        // SProject newProject = client.getServiceInterface().addProject("test" + Math.random());
        // SDeserializerPluginConfiguration deserializerByName = client.getServiceInterface().getDeserializerByName("IfcStepDeserializer");
        // client.checkin(newProject.getOid(), "test", deserializerByName.getOid(), false, true, new File("../TestData/data/AC11-Institute-Var-2-IFC.ifc"));
        // newProject = client.getServiceInterface().getProjectByPoid(newProject.getOid());
        SProject project = client.getServiceInterface().getProjectByPoid(458753L);
        SSerializerPluginConfiguration geometrySerializer = client.getServiceInterface().getSerializerByName("JsonGeometrySerializer");
        for (int i = 0; i < 100; i++) {
        // final CountDownLatch countDownLatch = new CountDownLatch(1);
        // final Long downloadByTypes = client.getServiceInterface().downloadByTypes(Collections.singleton(project.getLastRevisionId()), "ifc2x3tc1", Collections.singleton("IfcWindow"), geometrySerializer.getOid(), true, false, false, false);
        // final ProgressHandler progressHandler = new ProgressHandler() {
        // @Override
        // public void progress(SLongActionState state) {
        // if (state.getProgress() == 100) {
        // countDownLatch.countDown();
        // }
        // }
        // };
        // client.getNotificationsManager().registerProgressHandler(downloadByTypes, progressHandler);
        // try {
        // countDownLatch.await(20, TimeUnit.SECONDS);
        // client.getNotificationsManager().unregisterProgressHandler(downloadByTypes, progressHandler);
        // } catch (InterruptedException e) {
        // e.printStackTrace();
        // }
        }
        client.disconnect();
        System.out.println("Done");
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException 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 63 with BimServerClientInterface

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

the class FileLoader method load.

private void load(Path dir) {
    // JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://sandbox.bimserver.org");
    try {
        final BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        ExecutorService executorService = new ThreadPoolExecutor(1, 1, 1, TimeUnit.HOURS, new ArrayBlockingQueue<Runnable>(200));
        for (final Path file : PathUtils.list(dir)) {
            executorService.submit(new Runnable() {

                @Override
                public void run() {
                    System.out.println(file.getFileName());
                    SProject project;
                    try {
                        project = client.getServiceInterface().addProject(file.getFileName().toString(), "ifc2x3tc1");
                        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
                        client.checkin(project.getOid(), file.getFileName().toString(), deserializer.getOid(), false, Flow.SYNC, file);
                    } catch (ServerException e) {
                        e.printStackTrace();
                    } catch (UserException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } catch (PublicInterfaceNotFoundException e) {
                        e.printStackTrace();
                    }
                }
            });
        }
        executorService.awaitTermination(1, TimeUnit.HOURS);
        System.out.println("Done");
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ServerException(org.bimserver.shared.exceptions.ServerException) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) ExecutorService(java.util.concurrent.ExecutorService) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) ThreadPoolExecutor(java.util.concurrent.ThreadPoolExecutor) UserException(org.bimserver.shared.exceptions.UserException)

Example 64 with BimServerClientInterface

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

the class RegenerateGeometry method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        List<SProject> allProjects = client.getServiceInterface().getAllProjects(false, true);
        Set<Long> croids = new HashSet<Long>();
        for (SProject project : allProjects) {
            for (Long roid : project.getRevisions()) {
                SRevision revision = client.getServiceInterface().getRevision(roid);
                for (long croid : revision.getConcreteRevisions()) {
                    croids.add(croid);
                }
            }
        }
        for (long croid : croids) {
            client.getAdminInterface().regenerateGeometry(croid);
        }
        System.out.println("Done");
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : SRevision(org.bimserver.interfaces.objects.SRevision) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SProject(org.bimserver.interfaces.objects.SProject) HashSet(java.util.HashSet)

Example 65 with BimServerClientInterface

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

the class TestUploadSameModelALot method start.

private void start() {
    try {
        BimServerClientInterface client = LocalDevSetup.setupJson("http://localhost:8080");
        client.getSettingsInterface().setGenerateGeometryOnCheckin(false);
        for (int i = 0; i < 20; i++) {
            SProject project = client.getServiceInterface().addProject("P" + i, "ifc2x3tc1");
            SDeserializerPluginConfiguration deserializerForExtension = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
            System.out.println(i);
            client.checkin(project.getOid(), "C" + i, deserializerForExtension.getOid(), false, Flow.SYNC, Paths.get("../TestData/data/AC11-FZK-Haus-IFC.ifc"));
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject)

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