use of org.bimserver.plugins.modelcompare.ModelCompareException in project BIMserver by opensourceBIM.
the class CompareDatabaseAction method execute.
@Override
public CompareResult execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
// bimServer.getCompareCache().getCompareResults(roid1,
CompareResult compareResults = null;
// sCompareIdentifier);
if (compareResults == null) {
IfcModelInterface model1 = new DownloadDatabaseAction(bimServer, getDatabaseSession(), getAccessMethod(), roid1, -1, serializerOid, authorization, null).execute();
IfcModelInterface model2 = new DownloadDatabaseAction(bimServer, getDatabaseSession(), getAccessMethod(), roid2, -1, serializerOid, authorization, null).execute();
try {
compareResults = getModelCompare().compare(model1, model2, sCompareType);
} catch (ModelCompareException e) {
LOGGER.error("", e);
throw new UserException(e);
}
// bimServer.getCompareCache().storeResults(roid1, roid2, sCompareType, sCompareIdentifier, compareResults);
}
return compareResults;
}
use of org.bimserver.plugins.modelcompare.ModelCompareException in project BIMserver by opensourceBIM.
the class DownloadCompareDatabaseAction method execute.
@Override
public IfcModelInterface execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException, ServerException {
try {
Revision revision1 = getRevisionByRoid(roid1);
Revision revision2 = getRevisionByRoid(roid2);
Project project = revision1.getProject();
// bimServer.getCompareCache().getCompareResults(roid1,
CompareResult compareResults = null;
// roid2, compareType,
// compareIdentifier);
IfcModelInterface model1 = new DownloadDatabaseAction(getBimServer(), getDatabaseSession(), getAccessMethod(), roid1, -1, -1, getAuthorization(), null).execute();
IfcModelInterface model2 = new DownloadDatabaseAction(getBimServer(), getDatabaseSession(), getAccessMethod(), roid2, -1, -1, getAuthorization(), null).execute();
try {
compareResults = getModelCompare().compare(model1, model2, compareType);
} catch (ModelCompareException e) {
throw new UserException(e);
}
// bimServer.getCompareCache().storeResults(roid1, roid2,
// compareType, compareIdentifier, compareResults);
ModelMerger merger = getBimServer().getMergerFactory().createMerger(getDatabaseSession(), getAuthorization().getUoid());
PackageMetaData packageMetaData = model1.getPackageMetaData();
IfcModelInterface mergedModel = new ServerIfcModel(packageMetaData, null, getDatabaseSession());
mergedModel = merger.merge(project, new IfcModelSet(model1, model2), new ModelHelper(getBimServer().getMetaDataManager(), mergedModel));
mergedModel.getModelMetaData().setName(project.getName() + "." + revision1.getId() + "." + revision2.getId());
Set<Long> added = new HashSet<Long>();
Set<Long> modified = new HashSet<Long>();
Set<Long> deleted = new HashSet<Long>();
for (CompareContainer compareContainer : compareResults.getItems()) {
for (CompareItem compareItem : compareContainer.getItems()) {
DataObject dataObject = compareItem.getDataObject();
if (compareItem instanceof ObjectAdded) {
added.add(dataObject.getOid());
} else if (compareItem instanceof ObjectModified) {
modified.add(dataObject.getOid());
} else if (compareItem instanceof ObjectRemoved) {
deleted.add(dataObject.getOid());
}
}
}
EClass ifcColourRgbClass = packageMetaData.getEClass("IfcColourRgb");
EStructuralFeature nameFeature = ifcColourRgbClass.getEStructuralFeature("Name");
EStructuralFeature redFeature = ifcColourRgbClass.getEStructuralFeature("Red");
EStructuralFeature greenFeature = ifcColourRgbClass.getEStructuralFeature("Green");
EStructuralFeature blueFeature = ifcColourRgbClass.getEStructuralFeature("Blue");
IdEObject red = mergedModel.createAndAdd(ifcColourRgbClass);
red.eSet(nameFeature, "red");
red.eSet(redFeature, 0.5D);
red.eSet(greenFeature, 0.0D);
red.eSet(blueFeature, 0.0D);
IdEObject green = mergedModel.createAndAdd(ifcColourRgbClass);
green.eSet(nameFeature, "green");
green.eSet(redFeature, 0D);
green.eSet(greenFeature, 0.5D);
green.eSet(blueFeature, 0D);
IdEObject blue = mergedModel.createAndAdd(ifcColourRgbClass);
blue.eSet(nameFeature, "blue");
blue.eSet(redFeature, 0D);
blue.eSet(greenFeature, 0D);
blue.eSet(blueFeature, 0.5D);
for (IdEObject product : mergedModel.getAllWithSubTypes(packageMetaData.getEClass("IfcProduct"))) {
IdEObject color = null;
if (added.contains(product.getOid())) {
color = green;
} else if (deleted.contains(product.getOid())) {
color = red;
} else if (modified.contains(product.getOid())) {
color = blue;
}
if (color != null) {
setColor(mergedModel, product, color);
}
}
mergedModel.fixOidCounter();
return mergedModel;
} catch (IfcModelInterfaceException e) {
throw new UserException(e);
} catch (MergeException e) {
throw new UserException(e);
}
}
use of org.bimserver.plugins.modelcompare.ModelCompareException in project BIMserver by opensourceBIM.
the class DownloadCompareDatabaseAction method getModelCompare.
public org.bimserver.plugins.modelcompare.ModelCompare getModelCompare() throws ModelCompareException, BimserverDatabaseException {
Revision revision1 = getDatabaseSession().get(roid1, OldQuery.getDefault());
Revision revision2 = getDatabaseSession().get(roid2, OldQuery.getDefault());
PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(revision1.getProject().getSchema());
if (revision1.getProject().getSchema().equals(revision2.getProject().getSchema())) {
ModelComparePluginConfiguration modelCompareObject = getDatabaseSession().get(StorePackage.eINSTANCE.getModelComparePluginConfiguration(), mcid, OldQuery.getDefault());
if (modelCompareObject != null) {
ModelComparePlugin modelComparePlugin = getBimServer().getPluginManager().getModelComparePlugin(modelCompareObject.getPluginDescriptor().getPluginClassName(), true);
if (modelComparePlugin != null) {
org.bimserver.plugins.modelcompare.ModelCompare modelCompare = modelComparePlugin.createModelCompare(new PluginConfiguration(modelCompareObject.getSettings()), packageMetaData);
return modelCompare;
} else {
throw new ModelCompareException("No Model Compare found " + modelCompareObject.getPluginDescriptor().getPluginClassName());
}
} else {
throw new ModelCompareException("No configured Model Compare found");
}
} else {
throw new ModelCompareException("Schemas not the same");
}
}
use of org.bimserver.plugins.modelcompare.ModelCompareException in project BIMserver by opensourceBIM.
the class CompareDatabaseAction method getModelCompare.
public org.bimserver.plugins.modelcompare.ModelCompare getModelCompare() throws ModelCompareException, BimserverDatabaseException {
Revision revision1 = getDatabaseSession().get(roid1, OldQuery.getDefault());
Revision revision2 = getDatabaseSession().get(roid2, OldQuery.getDefault());
PackageMetaData packageMetaData = bimServer.getMetaDataManager().getPackageMetaData(revision1.getProject().getSchema());
if (revision1.getProject().getSchema().equals(revision2.getProject().getSchema())) {
ModelComparePluginConfiguration modelCompareObject = getDatabaseSession().get(StorePackage.eINSTANCE.getModelComparePluginConfiguration(), mcid, OldQuery.getDefault());
if (modelCompareObject != null) {
ModelComparePlugin modelComparePlugin = bimServer.getPluginManager().getModelComparePlugin(modelCompareObject.getPluginDescriptor().getPluginClassName(), true);
if (modelComparePlugin != null) {
org.bimserver.plugins.modelcompare.ModelCompare modelCompare = modelComparePlugin.createModelCompare(new PluginConfiguration(modelCompareObject.getSettings()), packageMetaData);
return modelCompare;
} else {
throw new ModelCompareException("No Model Compare found " + modelCompareObject.getPluginDescriptor().getPluginClassName());
}
} else {
throw new ModelCompareException("No configured Model Compare found");
}
} else {
throw new ModelCompareException("Not the same schema");
}
}
Aggregations