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();
}
}
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();
}
}
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;
}
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();
}
}
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;
}
Aggregations