Search in sources :

Example 6 with PluginManager

use of org.bimserver.plugins.PluginManager 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 7 with PluginManager

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

the class ExtractFurniture method main.

public static void main(String[] args) {
    try {
        Path home = Paths.get("home");
        PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
        DeserializerPlugin deserializerPlugin = pluginManager.getFirstDeserializer("ifc", Schema.IFC2X3TC1, true);
        Deserializer deserializer = deserializerPlugin.createDeserializer(null);
        MetaDataManager metaDataManager = new MetaDataManager(home.resolve("tmp"));
        PackageMetaData packageMetaData = metaDataManager.getPackageMetaData("ifc2x3tc1");
        deserializer.init(packageMetaData);
        IfcModelInterface model = DeserializerUtils.readFromFile(deserializer, Paths.get("../TestData/data/ADT-FZK-Haus-2005-2006.ifc"));
        model.fixOids(new IncrementingOidProvider());
        IfcFurnishingElement picknick = (IfcFurnishingElement) model.getByName(Ifc2x3tc1Package.eINSTANCE.getIfcFurnishingElement(), "Picknik Bank");
        IfcModelInterface newModel = new BasicIfcModel(packageMetaData, null);
        ModelHelper modelHelper = new ModelHelper(pluginManager.getMetaDataManager(), new HideAllInversesObjectIDM(CollectionUtils.singleSet(Ifc2x3tc1Package.eINSTANCE), pluginManager.getMetaDataManager().getPackageMetaData("ifc2x3tc1")), newModel);
        modelHelper.copy(picknick, false);
        SerializerPlugin serializerPlugin = pluginManager.getSerializerPlugin("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin", true);
        Serializer serializer = serializerPlugin.createSerializer(null);
        serializer.init(newModel, null, true);
        SerializerUtils.writeToFile(serializer, Paths.get("test.ifc"));
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (DeserializeException e) {
        e.printStackTrace();
    } catch (IfcModelInterfaceException e) {
        e.printStackTrace();
    } catch (SerializerException e) {
        e.printStackTrace();
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
Also used : Path(java.nio.file.Path) ModelHelper(org.bimserver.plugins.ModelHelper) IfcFurnishingElement(org.bimserver.models.ifc2x3tc1.IfcFurnishingElement) PackageMetaData(org.bimserver.emf.PackageMetaData) IfcModelInterface(org.bimserver.emf.IfcModelInterface) PluginException(org.bimserver.shared.exceptions.PluginException) DeserializerPlugin(org.bimserver.plugins.deserializers.DeserializerPlugin) FileNotFoundException(java.io.FileNotFoundException) MetaDataManager(org.bimserver.emf.MetaDataManager) SerializerPlugin(org.bimserver.plugins.serializers.SerializerPlugin) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) IOException(java.io.IOException) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) SerializerException(org.bimserver.plugins.serializers.SerializerException) PluginManager(org.bimserver.plugins.PluginManager) IfcModelInterfaceException(org.bimserver.emf.IfcModelInterfaceException) Deserializer(org.bimserver.plugins.deserializers.Deserializer) HideAllInversesObjectIDM(org.bimserver.plugins.objectidms.HideAllInversesObjectIDM) IncrementingOidProvider(org.bimserver.shared.IncrementingOidProvider) Serializer(org.bimserver.plugins.serializers.Serializer)

Example 8 with PluginManager

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

the class LocalDevPluginLoader method createPluginManager.

public static PluginManager createPluginManager(Path home, Path[] pluginDirectories) throws PluginException {
    if (!Files.exists(home)) {
        try {
            Files.createDirectories(home);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    MavenPluginRepository mavenPluginRepository = new MavenPluginRepository(home.resolve("maven"));
    PluginManager pluginManager = new PluginManager(home.resolve("tmp"), home.resolve("plugins"), mavenPluginRepository, System.getProperty("java.class.path"), null, null, null);
    loadPlugins(pluginManager, pluginDirectories);
    pluginManager.initAllLoadedPlugins();
    return pluginManager;
}
Also used : PluginManager(org.bimserver.plugins.PluginManager) MavenPluginRepository(org.bimserver.plugins.MavenPluginRepository) IOException(java.io.IOException)

Example 9 with PluginManager

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

the class LocalDevSetup method setupPluginManager.

public static final PluginManagerInterface setupPluginManager(String[] args) {
    try {
        Path home = Paths.get("home");
        if (!Files.exists(home)) {
            Files.createDirectory(home);
        }
        Path tmp = home.resolve("tmp");
        if (!Files.exists(tmp)) {
            Files.createDirectories(tmp);
        }
        MavenPluginRepository mavenPluginRepository = new MavenPluginRepository(home.resolve("maven"));
        PluginManager pluginManager = new PluginManager(tmp, home.resolve("plugins"), mavenPluginRepository, System.getProperty("java.class.path"), null, null, null);
        MetaDataManager metaDataManager = new MetaDataManager(tmp);
        pluginManager.setMetaDataManager(metaDataManager);
        loadPlugins(pluginManager, Paths.get(".."), new OptionsParser(args).getPluginDirectories());
        metaDataManager.init();
        pluginManager.initAllLoadedPlugins();
        return pluginManager;
    } catch (PluginException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return null;
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) MavenPluginRepository(org.bimserver.plugins.MavenPluginRepository) PluginException(org.bimserver.shared.exceptions.PluginException) MetaDataManager(org.bimserver.emf.MetaDataManager) IOException(java.io.IOException) OptionsParser(org.bimserver.plugins.OptionsParser)

Example 10 with PluginManager

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

the class LocalDevSetup method setupProtocolBuffers.

public static final BimServerClientInterface setupProtocolBuffers(String address) {
    Path home = Paths.get("home");
    Path tmp = home.resolve("tmp");
    MetaDataManager metaDataManager = new MetaDataManager(tmp);
    try (BimServerClientFactory factory = new ProtocolBuffersBimServerClientFactory(address, 8000, 8000, null, metaDataManager, new SServicesMap())) {
        PluginManager pluginManager = LocalDevPluginLoader.createPluginManager(home);
        pluginManager.setMetaDataManager(metaDataManager);
        return factory.create(new UsernamePasswordAuthenticationInfo("admin@bimserver.org", "admin"));
    } catch (PluginException e) {
        LOGGER.error("", e);
    } catch (ServiceException e) {
        LOGGER.error("", e);
    } catch (ChannelConnectionException e) {
        LOGGER.error("", e);
    } catch (BimServerClientException e) {
        LOGGER.error("", e);
    } catch (Exception e) {
        LOGGER.error("", e);
    }
    return null;
}
Also used : Path(java.nio.file.Path) PluginManager(org.bimserver.plugins.PluginManager) SServicesMap(org.bimserver.shared.meta.SServicesMap) ServiceException(org.bimserver.shared.exceptions.ServiceException) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) UsernamePasswordAuthenticationInfo(org.bimserver.shared.UsernamePasswordAuthenticationInfo) PluginException(org.bimserver.shared.exceptions.PluginException) MetaDataManager(org.bimserver.emf.MetaDataManager) ProtocolBuffersBimServerClientFactory(org.bimserver.client.protocolbuffers.ProtocolBuffersBimServerClientFactory) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ProtocolBuffersBimServerClientFactory(org.bimserver.client.protocolbuffers.ProtocolBuffersBimServerClientFactory) JsonBimServerClientFactory(org.bimserver.client.json.JsonBimServerClientFactory) BimServerClientFactory(org.bimserver.shared.BimServerClientFactory) SoapBimServerClientFactory(org.bimserver.client.soap.SoapBimServerClientFactory) ChannelConnectionException(org.bimserver.shared.ChannelConnectionException) PluginException(org.bimserver.shared.exceptions.PluginException) BimServerClientException(org.bimserver.shared.exceptions.BimServerClientException) ServiceException(org.bimserver.shared.exceptions.ServiceException) IOException(java.io.IOException)

Aggregations

PluginManager (org.bimserver.plugins.PluginManager)12 IOException (java.io.IOException)10 PluginException (org.bimserver.shared.exceptions.PluginException)10 Path (java.nio.file.Path)8 MetaDataManager (org.bimserver.emf.MetaDataManager)7 JsonBimServerClientFactory (org.bimserver.client.json.JsonBimServerClientFactory)5 Deserializer (org.bimserver.plugins.deserializers.Deserializer)5 DeserializerPlugin (org.bimserver.plugins.deserializers.DeserializerPlugin)5 UsernamePasswordAuthenticationInfo (org.bimserver.shared.UsernamePasswordAuthenticationInfo)5 FileNotFoundException (java.io.FileNotFoundException)4 IfcModelInterface (org.bimserver.emf.IfcModelInterface)4 BimServerClientFactory (org.bimserver.shared.BimServerClientFactory)4 ProtocolBuffersBimServerClientFactory (org.bimserver.client.protocolbuffers.ProtocolBuffersBimServerClientFactory)3 SoapBimServerClientFactory (org.bimserver.client.soap.SoapBimServerClientFactory)3 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)3 MavenPluginRepository (org.bimserver.plugins.MavenPluginRepository)3 PluginConfiguration (org.bimserver.plugins.PluginConfiguration)3 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)3 Serializer (org.bimserver.plugins.serializers.Serializer)3 SerializerException (org.bimserver.plugins.serializers.SerializerException)3