Search in sources :

Example 1 with PluginConfiguration

use of org.bimserver.plugins.PluginConfiguration in project BIMserver by opensourceBIM.

the class MergerFactory method createMerger.

public org.bimserver.plugins.modelmerger.ModelMerger createMerger(DatabaseSession databaseSession, Long currentUoid) throws MergeException, BimserverDatabaseException {
    DatabaseSession session = bimServer.getDatabase().createSession();
    try {
        User user = databaseSession.get(StorePackage.eINSTANCE.getUser(), currentUoid, OldQuery.getDefault());
        UserSettings userSettings = user.getUserSettings();
        ModelMergerPluginConfiguration modelMergerObject = userSettings.getDefaultModelMerger();
        if (modelMergerObject != null) {
            ModelMergerPlugin modelMergerPlugin = bimServer.getPluginManager().getModelMergerPlugin(modelMergerObject.getPluginDescriptor().getPluginClassName(), true);
            if (modelMergerPlugin != null) {
                org.bimserver.plugins.modelmerger.ModelMerger modelMerger = modelMergerPlugin.createModelMerger(new PluginConfiguration(modelMergerObject.getSettings()));
                return modelMerger;
            } else {
                throw new MergeException("No Model Merger found " + modelMergerObject.getPluginDescriptor().getPluginClassName());
            }
        } else {
            throw new MergeException("No configured Model Merger found");
        }
    } finally {
        session.close();
    }
}
Also used : ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) ModelMergerPlugin(org.bimserver.plugins.modelmerger.ModelMergerPlugin) MergeException(org.bimserver.plugins.modelmerger.MergeException) UserSettings(org.bimserver.models.store.UserSettings) ModelMergerPluginConfiguration(org.bimserver.models.store.ModelMergerPluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration)

Example 2 with PluginConfiguration

use of org.bimserver.plugins.PluginConfiguration in project BIMserver by opensourceBIM.

the class Visualise method main.

public static void main(String[] args) {
    PluginManager pluginManager;
    try {
        pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
        DeserializerPlugin deserializerPlugin = pluginManager.requireDeserializer("application/ifc");
        Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        IfcModelInterface model1 = DeserializerUtils.readFromFile(deserializer, TestFile.EXPORT3.getFile());
        IfcModelInterface model1b = DeserializerUtils.readFromFile(deserializer, TestFile.EXPORT3.getFile());
        IfcModelInterface model2 = DeserializerUtils.readFromFile(deserializer, TestFile.EXPORT3.getFile());
        IfcModelInterface model2b = DeserializerUtils.readFromFile(deserializer, TestFile.EXPORT3.getFile());
        model1.setObjectOids();
        model1b.setObjectOids();
        model2.setObjectOids();
        model2b.setObjectOids();
        model1.indexGuids();
        model2.indexGuids();
        model2.fixOids(new IncrementingOidProvider(model1.getHighestOid() + 1));
        IfcModel merged = new RevisionMerger(model1, model2).merge();
        SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
        Serializer serializer = serializerPlugin.createSerializer(new PluginConfiguration());
        serializer.init(merged, null, false);
        SerializerUtils.writeToFile(serializer, Paths.get("merged.ifc"));
        new Visualise().start(model1b, "Model 1");
        new Visualise().start(model2b, "Model 2");
        new Visualise().start(merged, "Merged");
    } catch (PluginException e1) {
        e1.printStackTrace();
    } catch (SerializerException e) {
        e.printStackTrace();
    } catch (DeserializeException e) {
        e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : RevisionMerger(org.bimserver.merging.RevisionMerger) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) FileNotFoundException(java.io.FileNotFoundException) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) IOException(java.io.IOException) SerializerException(org.bimserver.plugins.serializers.SerializerException) PluginManager(org.bimserver.plugins.PluginManager) IfcModel(org.bimserver.ifc.IfcModel) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) Deserializer(org.bimserver.plugins.deserializers.Deserializer) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) IncrementingOidProvider(org.bimserver.shared.IncrementingOidProvider) Serializer(org.bimserver.plugins.serializers.Serializer)

Example 3 with PluginConfiguration

use of org.bimserver.plugins.PluginConfiguration in project BIMserver by opensourceBIM.

the class GuidHighlighterTester method readModel.

public IfcModelInterface readModel(Path file) {
    PluginManager pluginManager;
    try {
        pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        try {
            IfcModelInterface model = DeserializerUtils.readFromFile(deserializer, file);
            return model;
        } catch (Exception e) {
            e.printStackTrace();
        }
    } catch (PluginException e1) {
        e1.printStackTrace();
    }
    return null;
}
Also used : PluginManager(org.bimserver.plugins.PluginManager) Deserializer(org.bimserver.plugins.deserializers.Deserializer) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) PluginException(org.bimserver.shared.exceptions.PluginException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Example 4 with PluginConfiguration

use of org.bimserver.plugins.PluginConfiguration in project BIMserver by opensourceBIM.

the class IfcRioleringTest method start.

private void start() {
    Path src = TestFile.RIOLERING_TEST.getFile();
    PluginManager pluginManager;
    try {
        pluginManager = LocalDevPluginLoader.createPluginManager(Paths.get("home"));
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(new PluginConfiguration());
        deserializer.init(pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1"));
        try {
            model = DeserializerUtils.readFromFile(deserializer, src);
        } catch (Exception e) {
            e.printStackTrace();
        }
        step1();
    } catch (PluginException e1) {
        e1.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) Deserializer(org.bimserver.plugins.deserializers.Deserializer) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) PluginException(org.bimserver.shared.exceptions.PluginException)

Example 5 with PluginConfiguration

use of org.bimserver.plugins.PluginConfiguration in project BIMserver by opensourceBIM.

the class SerializerFactory method createMessagingSerializer.

public MessagingSerializer createMessagingSerializer(String username, IfcModelInterface model, DownloadParameters downloadParameters) throws SerializerException {
    DatabaseSession session = bimDatabase.createSession();
    try {
        MessagingSerializerPluginConfiguration serializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getMessagingSerializerPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
        if (serializerPluginConfiguration != null) {
            MessagingSerializerPlugin serializerPlugin = (MessagingSerializerPlugin) pluginManager.getPlugin(serializerPluginConfiguration.getPluginDescriptor().getPluginClassName(), true);
            if (serializerPlugin != null) {
                ObjectType settings = serializerPluginConfiguration.getSettings();
                MessagingSerializer serializer = serializerPlugin.createSerializer(new PluginConfiguration(settings));
                if (serializer != null) {
                    try {
                        serializer.init(model, null, pluginManager, model.getPackageMetaData(), true);
                        return serializer;
                    } catch (NullPointerException e) {
                        LOGGER.error("", e);
                    }
                }
            }
        }
    } catch (BimserverDatabaseException e) {
        LOGGER.error("", e);
    } finally {
        session.close();
    }
    return null;
}
Also used : MessagingSerializerPlugin(org.bimserver.plugins.serializers.MessagingSerializerPlugin) MessagingSerializer(org.bimserver.plugins.serializers.MessagingSerializer) ObjectType(org.bimserver.models.store.ObjectType) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) MessagingSerializerPluginConfiguration(org.bimserver.models.store.MessagingSerializerPluginConfiguration)

Aggregations

PluginConfiguration (org.bimserver.plugins.PluginConfiguration)18 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)9 IfcModelInterface (org.bimserver.emf.IfcModelInterface)7 UserException (org.bimserver.shared.exceptions.UserException)7 IOException (java.io.IOException)6 DatabaseSession (org.bimserver.database.DatabaseSession)6 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)6 PackageMetaData (org.bimserver.emf.PackageMetaData)5 Revision (org.bimserver.models.store.Revision)5 User (org.bimserver.models.store.User)5 UserSettings (org.bimserver.models.store.UserSettings)5 PluginException (org.bimserver.shared.exceptions.PluginException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Deserializer (org.bimserver.plugins.deserializers.Deserializer)4 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)4 FileNotFoundException (java.io.FileNotFoundException)3 OldQuery (org.bimserver.database.OldQuery)3 BasicIfcModel (org.bimserver.ifc.BasicIfcModel)3 PluginManager (org.bimserver.plugins.PluginManager)3 ServerException (org.bimserver.shared.exceptions.ServerException)3