Search in sources :

Example 1 with ObjectIDM

use of org.bimserver.plugins.objectidms.ObjectIDM in project BIMserver by opensourceBIM.

the class LongDownloadAction method init.

public void init(Thread thread) {
    super.init(thread);
    if (getBimServer().getServerSettingsCache().getServerSettings().getCacheOutputFiles() && getBimServer().getDiskCacheManager().contains(downloadParameters)) {
        return;
    }
    ObjectIDM objectIDM = null;
    if (downloadParameters.getUseObjectIDM()) {
        session = getBimServer().getDatabase().createSession();
        try {
            SerializerPluginConfiguration serializerPluginConfiguration = session.get(StorePackage.eINSTANCE.getSerializerPluginConfiguration(), downloadParameters.getSerializerOid(), OldQuery.getDefault());
            if (serializerPluginConfiguration != null) {
                ObjectIDMPluginConfiguration objectIdm = serializerPluginConfiguration.getObjectIDM();
                if (objectIdm != null) {
                    ObjectIDMPlugin objectIDMPlugin = getBimServer().getPluginManager().getObjectIDMByName(objectIdm.getPluginDescriptor().getPluginClassName(), true);
                    if (objectIDMPlugin != null) {
                        objectIDM = objectIDMPlugin.getObjectIDM(new PluginConfiguration());
                    }
                }
            }
        } catch (BimserverDatabaseException e) {
            LOGGER.error("", e);
        } finally {
            session.close();
        }
    }
    session = getBimServer().getDatabase().createSession();
    switch(downloadParameters.getDownloadType()) {
        case DOWNLOAD_BY_NEW_JSON_QUERY:
            action = new DownloadByNewJsonQueryDatabaseAction(getBimServer(), session, accessMethod, downloadParameters.getRoids(), downloadParameters.getJsonQuery(), downloadParameters.getSerializerOid(), getAuthorization());
            break;
        case DOWNLOAD_PROJECTS:
            action = new DownloadProjectsDatabaseAction(getBimServer(), session, accessMethod, downloadParameters.getRoids(), downloadParameters.getSerializerOid(), getAuthorization(), objectIDM);
            break;
        case DOWNLOAD_COMPARE:
            action = new DownloadCompareDatabaseAction(getBimServer(), session, accessMethod, downloadParameters.getRoids(), downloadParameters.getModelCompareIdentifier(), downloadParameters.getCompareType(), getAuthorization(), objectIDM);
            break;
    }
    action.addProgressListener(this);
}
Also used : DownloadProjectsDatabaseAction(org.bimserver.database.actions.DownloadProjectsDatabaseAction) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) ObjectIDMPluginConfiguration(org.bimserver.models.store.ObjectIDMPluginConfiguration) DownloadCompareDatabaseAction(org.bimserver.database.actions.DownloadCompareDatabaseAction) DownloadByNewJsonQueryDatabaseAction(org.bimserver.database.actions.DownloadByNewJsonQueryDatabaseAction) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) ObjectIDMPluginConfiguration(org.bimserver.models.store.ObjectIDMPluginConfiguration) PluginConfiguration(org.bimserver.plugins.PluginConfiguration) ObjectIDMPlugin(org.bimserver.plugins.objectidms.ObjectIDMPlugin) ObjectIDM(org.bimserver.plugins.objectidms.ObjectIDM)

Example 2 with ObjectIDM

use of org.bimserver.plugins.objectidms.ObjectIDM in project BIMserver by opensourceBIM.

the class ModelHelper method initObjectIdmCache.

private static void initObjectIdmCache(final MetaDataManager metaDataManager) {
    hideAllInverseMap = new HashMap<EPackage, HideAllInversesObjectIDM>();
    objectIdmCache = new HashMap<EClass, ObjectIDM>();
    for (PackageMetaData packageMetaData : metaDataManager.getAllIfc()) {
        final HideAllInversesObjectIDM hideAllInverse = new HideAllInversesObjectIDM(Collections.singleton(packageMetaData.getEPackage()), packageMetaData);
        hideAllInverseMap.put(packageMetaData.getEPackage(), hideAllInverse);
        for (final EClass onlyIncludeRepresentationForThisClass : packageMetaData.getAllSubClasses(packageMetaData.getEClass("IfcProduct"))) {
            ObjectIDM objectIdm = new ObjectIDM() {

                @Override
                public boolean shouldIncludeClass(EClass originalClass, EClass eClass) {
                    return hideAllInverse.shouldIncludeClass(originalClass, eClass);
                }

                @Override
                public boolean shouldFollowReference(EClass originalClass, EClass eClass, EStructuralFeature eStructuralFeature) {
                    if (eStructuralFeature.getName().equals("Representation") && onlyIncludeRepresentationForThisClass != eClass) {
                        return false;
                    } else {
                        if (eStructuralFeature.getName().equals("StyledByItem")) {
                            return true;
                        }
                        return hideAllInverse.shouldFollowReference(originalClass, eClass, eStructuralFeature);
                    }
                }
            };
            objectIdmCache.put(onlyIncludeRepresentationForThisClass, objectIdm);
        }
    }
    skipRepresentation = new ObjectIDM() {

        private ObjectIDM hideAllInverse = new HideAllInversesObjectIDM(hideAllInverseMap.keySet(), metaDataManager.getPackageMetaData("ifc2x3tc1"));

        @Override
        public boolean shouldIncludeClass(EClass originalClass, EClass eClass) {
            return hideAllInverse.shouldIncludeClass(originalClass, eClass);
        }

        @Override
        public boolean shouldFollowReference(EClass originalClass, EClass eClass, EStructuralFeature eStructuralFeature) {
            if (eStructuralFeature.getName().equals("Representation")) {
                return false;
            } else {
                return hideAllInverse.shouldFollowReference(originalClass, eClass, eStructuralFeature);
            }
        }
    };
}
Also used : EClass(org.eclipse.emf.ecore.EClass) PackageMetaData(org.bimserver.emf.PackageMetaData) HideAllInversesObjectIDM(org.bimserver.plugins.objectidms.HideAllInversesObjectIDM) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) ObjectIDM(org.bimserver.plugins.objectidms.ObjectIDM) HideAllInversesObjectIDM(org.bimserver.plugins.objectidms.HideAllInversesObjectIDM) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

ObjectIDM (org.bimserver.plugins.objectidms.ObjectIDM)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DownloadByNewJsonQueryDatabaseAction (org.bimserver.database.actions.DownloadByNewJsonQueryDatabaseAction)1 DownloadCompareDatabaseAction (org.bimserver.database.actions.DownloadCompareDatabaseAction)1 DownloadProjectsDatabaseAction (org.bimserver.database.actions.DownloadProjectsDatabaseAction)1 PackageMetaData (org.bimserver.emf.PackageMetaData)1 ObjectIDMPluginConfiguration (org.bimserver.models.store.ObjectIDMPluginConfiguration)1 SerializerPluginConfiguration (org.bimserver.models.store.SerializerPluginConfiguration)1 PluginConfiguration (org.bimserver.plugins.PluginConfiguration)1 HideAllInversesObjectIDM (org.bimserver.plugins.objectidms.HideAllInversesObjectIDM)1 ObjectIDMPlugin (org.bimserver.plugins.objectidms.ObjectIDMPlugin)1 EClass (org.eclipse.emf.ecore.EClass)1 EPackage (org.eclipse.emf.ecore.EPackage)1 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)1