Search in sources :

Example 11 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class SoapBimServerClientFactory method create.

@Override
public BimServerClient create(AuthenticationInfo authenticationInfo) throws ServiceException, ChannelConnectionException {
    SoapChannel soapChannel = new SoapChannel(getHttpClient(), address + "/soap11", true, getServicesMap().getInterfaceClasses());
    BimServerClient bimServerClient = new BimServerClient(this.getMetaDataManager(), address, getServicesMap(), soapChannel);
    soapChannel.connect(bimServerClient);
    bimServerClient.setAuthentication(authenticationInfo);
    bimServerClient.connect();
    return bimServerClient;
}
Also used : BimServerClient(org.bimserver.client.BimServerClient)

Example 12 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class Draw2DAABB method createImage.

private void createImage() {
    Graphics graphics = image.getGraphics();
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        try (BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"))) {
            List<SProjectSmall> allRelatedProjects = client.getServiceInterface().getAllRelatedProjects(13500417L);
            Bounds totalBounds = new Bounds();
            Bounds screenBounds = new Bounds(0, 0, 0, width, height, 1000);
            for (SProjectSmall projectSmall : allRelatedProjects) {
                if (projectSmall.getLastRevisionId() != -1 && projectSmall.getNrSubProjects() == 0) {
                    SProject project = client.getServiceInterface().getProjectByPoid(projectSmall.getOid());
                    SBounds bounds = client.getServiceInterface().getModelBounds(project.getLastRevisionId());
                    if (bounds != null) {
                        totalBounds.integrate(new Bounds(bounds));
                    }
                }
            }
            System.out.println("Model bounds: " + totalBounds);
            System.out.println("Screen bounds: " + screenBounds);
            for (SProjectSmall projectSmall : allRelatedProjects) {
                if (projectSmall.getLastRevisionId() != -1 && projectSmall.getNrSubProjects() == 0) {
                    SProject project = client.getServiceInterface().getProjectByPoid(projectSmall.getOid());
                    SBounds bounds = client.getServiceInterface().getModelBounds(project.getLastRevisionId());
                    if (bounds != null) {
                        Bounds subModelBounds = new Bounds(bounds);
                        Bounds subModelScreenBounds = subModelBounds.scale(totalBounds, screenBounds);
                    }
                }
            }
        }
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Graphics(java.awt.Graphics) SBounds(org.bimserver.interfaces.objects.SBounds) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) Bounds(org.bimserver.database.queries.Bounds) SBounds(org.bimserver.interfaces.objects.SBounds) SProjectSmall(org.bimserver.interfaces.objects.SProjectSmall) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClient(org.bimserver.client.BimServerClient) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException)

Example 13 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class TriggerImportDataRemote method main.

public static void main(String[] args) {
    /*
		 * Args:
		 * 	0: Address of new server
		 *  1: Username
		 *  2: Password
		 *  3: Address of old server
		 *  4: Local path to incoming folder of old server, this local path has to be available on the new server, so you have to copy it from the old server
		 */
    try {
        Path home = Paths.get("home");
        Path tmp = home.resolve("tmp");
        PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
        MetaDataManager metaDataManager = new MetaDataManager(tmp);
        pluginManager.setMetaDataManager(metaDataManager);
        try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory(metaDataManager, args[0])) {
            BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo(args[1], args[2]));
            client.getServiceInterface().importData(args[3], args[1], args[2], args[4]);
        } catch (Exception e) {
            e.printStackTrace();
        }
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) PluginException(org.bimserver.shared.exceptions.PluginException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException) MetaDataManager(org.bimserver.emf.MetaDataManager) BimServerClient(org.bimserver.client.BimServerClient) PluginException(org.bimserver.shared.exceptions.PluginException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)

Example 14 with BimServerClient

use of org.bimserver.client.BimServerClient in project BIMserver by opensourceBIM.

the class TestNewQueryViaClient method start.

private void start() {
    try (JsonBimServerClientFactory factory = new JsonBimServerClientFactory("http://localhost:8080")) {
        BimServerClient client = factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        String projectName = "Test " + new Random().nextInt();
        SProject project = client.getServiceInterface().addProject(projectName, "ifc2x3tc1");
        SDeserializerPluginConfiguration deserializer = client.getServiceInterface().getSuggestedDeserializerForExtension("ifc", project.getOid());
        client.checkinSync(project.getOid(), "Test Model", deserializer.getOid(), false, Paths.get("C:/Git/TestFiles/TestData/data/AC11-FZK-Haus-IFC.ifc"));
        project = client.getServiceInterface().getProjectByPoid(project.getOid());
        System.out.println(project.getName());
        ClientIfcModel model = client.getModel(project, project.getLastRevisionId(), false, false);
        Query query = new Query(model.getPackageMetaData());
        QueryPart queryPart = query.createQueryPart();
        queryPart.addType(Ifc2x3tc1Package.eINSTANCE.getIfcWall(), true);
        for (IfcWall ifcWall : model.getAllWithSubTypes(IfcWall.class)) {
            System.out.println(ifcWall.getGlobalId());
        }
    } catch (ServiceException e) {
        e.printStackTrace();
    } catch (ChannelConnectionException e) {
        e.printStackTrace();
    } catch (PublicInterfaceNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (BimServerClientException e) {
        e.printStackTrace();
    } catch (Exception e1) {
        e1.printStackTrace();
    }
}
Also used : IfcWall(org.bimserver.models.ifc2x3tc1.IfcWall) ClientIfcModel(org.bimserver.client.ClientIfcModel) SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) Query(org.bimserver.database.queries.om.Query) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) QueryPart(org.bimserver.database.queries.om.QueryPart) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) IOException(java.io.IOException) SProject(org.bimserver.interfaces.objects.SProject) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) BimServerClient(org.bimserver.client.BimServerClient) 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) Random(java.util.Random) ServiceException(org.bimserver.shared.exceptions.ServiceException) PublicInterfaceNotFoundException(org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)

Example 15 with BimServerClient

use of org.bimserver.client.BimServerClient 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().checkinFromUrlSync(project.getOid(), fileName, deserializer.getOid(), fileName, downloadUrl, false);
            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)

Aggregations

BimServerClient (org.bimserver.client.BimServerClient)27 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)23 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)23 SProject (org.bimserver.interfaces.objects.SProject)20 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)15 Test (org.junit.Test)15 Path (java.nio.file.Path)14 ClientIfcModel (org.bimserver.client.ClientIfcModel)11 SLongCheckinActionState (org.bimserver.interfaces.objects.SLongCheckinActionState)9 BimServerClientException (org.bimserver.shared.exceptions.BimServerClientException)6 CheckinProgressHandler (org.bimserver.plugins.services.CheckinProgressHandler)5 GeometryInfo (org.bimserver.models.geometry.GeometryInfo)3 IfcWall (org.bimserver.models.ifc2x3tc1.IfcWall)3 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)3 DateFormat (java.text.DateFormat)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Query (org.bimserver.database.queries.om.Query)2 QueryPart (org.bimserver.database.queries.om.QueryPart)2 PackageMetaData (org.bimserver.emf.PackageMetaData)2