public Deserializer createDeserializer(long deserializerOid)
     throws PluginException, UserException {
   DatabaseSession session = bimDatabase.createSession();
   try {
     DeserializerPluginConfiguration deserializerPluginConfiguration =
         session.get(
             StorePackage.eINSTANCE.getDeserializerPluginConfiguration(),
             deserializerOid,
             Query.getDefault());
     if (deserializerPluginConfiguration != null) {
       DeserializerPlugin deserializerPlugin =
           (DeserializerPlugin)
               pluginManager.getPlugin(
                   deserializerPluginConfiguration.getPluginDescriptor().getPluginClassName(),
                   true);
       if (deserializerPlugin != null) {
         ObjectType settings = deserializerPluginConfiguration.getSettings();
         return deserializerPlugin.createDeserializer(new PluginConfiguration(settings));
       } else {
         throw new UserException("No (enabled) deserializer found with oid " + deserializerOid);
       }
     }
   } catch (BimserverDatabaseException e) {
     LOGGER.error("", e);
   } finally {
     session.close();
   }
   return null;
 }
Exemplo n.º 2
0
 @SuppressWarnings({"rawtypes", "unchecked"})
 @Override
 public void execute(
     IfcModelInterface model,
     Project project,
     ConcreteRevision concreteRevision,
     DatabaseSession databaseSession,
     Map<Long, IdEObject> created,
     Map<Long, IdEObject> deleted)
     throws UserException, BimserverLockConflictException, BimserverDatabaseException {
   PackageMetaData packageMetaData =
       databaseSession.getMetaDataManager().getPackageMetaData(project.getSchema());
   IdEObject idEObject =
       databaseSession.get(
           model, oid, new Query(packageMetaData, project.getId(), concreteRevision.getId(), -1));
   EClass eClass = databaseSession.getEClassForOid(oid);
   if (idEObject == null) {
     idEObject = created.get(oid);
   }
   if (idEObject == null) {
     throw new UserException(
         "No object of type + "
             + eClass.getName()
             + " with oid "
             + oid
             + " found in project with pid "
             + project.getId());
   }
   EAttribute eAttribute = packageMetaData.getEAttribute(eClass.getName(), attributeName);
   if (eAttribute == null) {
     throw new UserException(
         "No attribute with the name " + attributeName + " found in class " + eClass.getName());
   }
   if (!eAttribute.isMany()) {
     throw new UserException("Attribute is not of type 'many'");
   }
   List list = (List) idEObject.eGet(eAttribute);
   list.add(value);
   databaseSession.store(idEObject, project.getId(), concreteRevision.getId());
 }
 public String getFileNameWithoutExtension() {
   switch (downloadType) {
     case DOWNLOAD_REVISION:
       return getRoidsString();
     case DOWNLOAD_BY_GUIDS:
       return getRoidsString() + "-" + getGuidsString();
     case DOWNLOAD_BY_NAMES:
       return getRoidsString() + "-" + getNamesString();
     case DOWNLOAD_BY_OIDS:
       return getRoidsString() + "-" + getOidsString();
     case DOWNLOAD_OF_TYPE:
       return getRoidsString() + "-" + classNames;
     case DOWNLOAD_PROJECTS:
       DatabaseSession session = bimServer.getDatabase().createSession();
       StringBuilder fileName = new StringBuilder();
       for (long roid : roids) {
         Revision revision;
         try {
           revision =
               session.get(
                   session.getEClassForName("store", "Revision"), roid, Query.getDefault());
           for (ConcreteRevision concreteRevision : revision.getConcreteRevisions()) {
             fileName.append(concreteRevision.getProject().getName() + "-");
           }
         } catch (BimserverDatabaseException e) {
           e.printStackTrace();
         }
       }
       fileName.delete(fileName.length() - 1, fileName.length());
       return fileName.toString();
     case DOWNLOAD_COMPARE:
       return "compare";
     case DOWNLOAD_JSON_QUERY:
       return getRoidsString();
     case DOWNLOAD_QUERY:
       return "query";
   }
   return "unknown";
 }