Search in sources :

Example 1 with SModelComparePluginConfiguration

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

the class TestCompare method testIfc2x3tc1Name.

@Test
public void testIfc2x3tc1Name() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject1 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        SProject newProject2 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc2x3tc1");
        // Get the appropriate deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject1.getOid());
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc2x3tc1");
        // Checkin the file
        bimServerClient.checkin(newProject1.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/compare_by_guid_rev_1.ifc"));
        bimServerClient.checkin(newProject2.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/compare_by_guid_rev_2.ifc"));
        newProject1 = bimServerClient.getServiceInterface().getProjectByPoid(newProject1.getOid());
        newProject2 = bimServerClient.getServiceInterface().getProjectByPoid(newProject2.getOid());
        SModelComparePluginConfiguration defaultModelCompare = bimServerClient.getPluginInterface().getModelCompareByName("Name based");
        bimServerClient.getServiceInterface().compare(newProject1.getLastRevisionId(), newProject2.getLastRevisionId(), SCompareType.ALL, defaultModelCompare.getOid());
        Long topicId = bimServerClient.getServiceInterface().downloadCompareResults(serializer.getOid(), newProject1.getLastRevisionId(), newProject2.getLastRevisionId(), defaultModelCompare.getOid(), SCompareType.ALL, true);
        bimServerClient.saveDownloadData(topicId, Paths.get("tmptestdata/ifc2x3tc1namecompare.ifc"));
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) URL(java.net.URL) Test(org.junit.Test)

Example 2 with SModelComparePluginConfiguration

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

the class PluginServiceImpl method updateModelCompare.

@Override
public void updateModelCompare(SModelComparePluginConfiguration modelCompare) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        ModelComparePluginConfiguration convert = session.get(modelCompare.getOid(), OldQuery.getDefault());
        getBimServer().getSConverter().convertFromSObject(modelCompare, convert, session);
        session.executeAndCommitAction(new UpdateModelCompareDatabaseAction(session, getInternalAccessMethod(), convert));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : UpdateModelCompareDatabaseAction(org.bimserver.database.actions.UpdateModelCompareDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) ModelComparePluginConfiguration(org.bimserver.models.store.ModelComparePluginConfiguration) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 3 with SModelComparePluginConfiguration

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

the class PluginServiceImpl method getAllModelCompares.

@Override
public List<SModelComparePluginConfiguration> getAllModelCompares(Boolean onlyEnabled) throws ServerException, UserException {
    requireAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        UserSettings userSettings = getUserSettings(session);
        List<SModelComparePluginConfiguration> modelCompares = getBimServer().getSConverter().convertToSListModelComparePluginConfiguration(userSettings.getModelCompares());
        Collections.sort(modelCompares, new SPluginConfigurationComparator());
        return modelCompares;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SPluginConfigurationComparator(org.bimserver.webservices.SPluginConfigurationComparator) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 4 with SModelComparePluginConfiguration

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

the class PluginServiceImpl method addModelCompare.

@Override
public Long addModelCompare(SModelComparePluginConfiguration modelCompare) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        ModelComparePluginConfiguration convert = getBimServer().getSConverter().convertFromSObject(modelCompare, session);
        return session.executeAndCommitAction(new AddModelCompareDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), convert));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) AddModelCompareDatabaseAction(org.bimserver.database.actions.AddModelCompareDatabaseAction) ModelComparePluginConfiguration(org.bimserver.models.store.ModelComparePluginConfiguration) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 5 with SModelComparePluginConfiguration

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

the class TestCompare method testIfc4Guid.

@Test
public void testIfc4Guid() {
    try {
        // Create a new BimServerClient with authentication
        BimServerClientInterface bimServerClient = getFactory().create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
        // Create a new project
        SProject newProject1 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc4");
        SProject newProject2 = bimServerClient.getServiceInterface().addProject("test" + Math.random(), "ifc4");
        // Get the appropriate deserializer
        SDeserializerPluginConfiguration deserializer = bimServerClient.getServiceInterface().getSuggestedDeserializerForExtension("ifc", newProject1.getOid());
        SSerializerPluginConfiguration serializer = bimServerClient.getServiceInterface().getSerializerByName("Ifc4");
        // Checkin the file
        bimServerClient.checkin(newProject1.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/compare_by_name_rev_1.ifc"));
        bimServerClient.checkin(newProject2.getOid(), "test", deserializer.getOid(), false, Flow.SYNC, new URL("https://github.com/opensourceBIM/TestFiles/raw/master/TestData/data/compare_by_name_rev_2.ifc"));
        newProject1 = bimServerClient.getServiceInterface().getProjectByPoid(newProject1.getOid());
        newProject2 = bimServerClient.getServiceInterface().getProjectByPoid(newProject2.getOid());
        SModelComparePluginConfiguration defaultModelCompare = bimServerClient.getPluginInterface().getModelCompareByName("GUID based");
        bimServerClient.getServiceInterface().compare(newProject1.getLastRevisionId(), newProject2.getLastRevisionId(), SCompareType.ALL, defaultModelCompare.getOid());
        long topicId = bimServerClient.getServiceInterface().downloadCompareResults(serializer.getOid(), newProject1.getLastRevisionId(), newProject2.getLastRevisionId(), defaultModelCompare.getOid(), SCompareType.ALL, true);
        bimServerClient.saveDownloadData(topicId, Paths.get("tmptestdata/ifc4guidcompare.ifc"));
    } catch (Throwable e) {
        e.printStackTrace();
        if (e instanceof AssertionError) {
            throw (AssertionError) e;
        }
        fail(e.getMessage());
    }
}
Also used : SDeserializerPluginConfiguration(org.bimserver.interfaces.objects.SDeserializerPluginConfiguration) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) SModelComparePluginConfiguration(org.bimserver.interfaces.objects.SModelComparePluginConfiguration) BimServerClientInterface(org.bimserver.plugins.services.BimServerClientInterface) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) SProject(org.bimserver.interfaces.objects.SProject) URL(java.net.URL) Test(org.junit.Test)

Aggregations

SModelComparePluginConfiguration (org.bimserver.interfaces.objects.SModelComparePluginConfiguration)7 URL (java.net.URL)4 SDeserializerPluginConfiguration (org.bimserver.interfaces.objects.SDeserializerPluginConfiguration)4 SProject (org.bimserver.interfaces.objects.SProject)4 SSerializerPluginConfiguration (org.bimserver.interfaces.objects.SSerializerPluginConfiguration)4 BimServerClientInterface (org.bimserver.plugins.services.BimServerClientInterface)4 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)3 DatabaseSession (org.bimserver.database.DatabaseSession)3 ServerException (org.bimserver.shared.exceptions.ServerException)3 UserException (org.bimserver.shared.exceptions.UserException)3 ModelComparePluginConfiguration (org.bimserver.models.store.ModelComparePluginConfiguration)2 AddModelCompareDatabaseAction (org.bimserver.database.actions.AddModelCompareDatabaseAction)1 UpdateModelCompareDatabaseAction (org.bimserver.database.actions.UpdateModelCompareDatabaseAction)1 UserSettings (org.bimserver.models.store.UserSettings)1 SPluginConfigurationComparator (org.bimserver.webservices.SPluginConfigurationComparator)1