Search in sources :

Example 41 with IdEObject

use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.

the class DatabaseSession method readWrappedValue.

private IdEObject readWrappedValue(EStructuralFeature feature, ByteBuffer buffer, EClass eClass, QueryInterface query) {
    EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature("wrappedValue");
    Object primitiveValue = readPrimitiveValue(eStructuralFeature.getEType(), buffer, query);
    IdEObject eObject = createInternal(eClass, query);
    // We don't want to go lazy load
    ((IdEObjectImpl) eObject).setLoaded();
    // this
    eObject.eSet(eStructuralFeature, primitiveValue);
    if (eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDouble() || eStructuralFeature.getEType() == EcorePackage.eINSTANCE.getEDoubleObject()) {
        EStructuralFeature strFeature = eClass.getEStructuralFeature("wrappedValueAsString");
        Object stringVal = readPrimitiveValue(EcorePackage.eINSTANCE.getEString(), buffer, query);
        eObject.eSet(strFeature, stringVal);
    }
    return eObject;
}
Also used : IdEObjectImpl(org.bimserver.emf.IdEObjectImpl) IdEObject(org.bimserver.emf.IdEObject) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) VirtualObject(org.bimserver.shared.VirtualObject) HashMapVirtualObject(org.bimserver.shared.HashMapVirtualObject) EObject(org.eclipse.emf.ecore.EObject) IdEObject(org.bimserver.emf.IdEObject)

Example 42 with IdEObject

use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.

the class CheckoutDatabaseAction method realCheckout.

private IfcModel realCheckout(Project project, Revision revision, DatabaseSession databaseSession, User user) throws BimserverLockConflictException, BimserverDatabaseException, UserException {
    PluginConfiguration serializerPluginConfiguration = getDatabaseSession().get(StorePackage.eINSTANCE.getPluginConfiguration(), serializerOid, OldQuery.getDefault());
    final long totalSize = revision.getSize();
    final AtomicLong total = new AtomicLong();
    IfcModelSet ifcModelSet = new IfcModelSet();
    PackageMetaData lastPackageMetaData = null;
    for (ConcreteRevision subRevision : revision.getConcreteRevisions()) {
        PackageMetaData packageMetaData = getBimServer().getMetaDataManager().getPackageMetaData(subRevision.getProject().getSchema());
        lastPackageMetaData = packageMetaData;
        IfcModel subModel = new BasicIfcModel(packageMetaData, null);
        int highestStopId = findHighestStopRid(project, subRevision);
        OldQuery query = new OldQuery(packageMetaData, subRevision.getProject().getId(), subRevision.getId(), revision.getOid(), null, Deep.YES, highestStopId);
        subModel.addChangeListener(new IfcModelChangeListener() {

            @Override
            public void objectAdded(IdEObject idEObject) {
                total.incrementAndGet();
                if (totalSize == 0) {
                    setProgress("Preparing checkout...", 0);
                } else {
                    setProgress("Preparing checkout...", (int) Math.round(100.0 * total.get() / totalSize));
                }
            }
        });
        getDatabaseSession().getMap(subModel, query);
        try {
            checkGeometry(serializerPluginConfiguration, getBimServer().getPluginManager(), subModel, project, subRevision, revision);
        } catch (GeometryGeneratingException e) {
            throw new UserException(e);
        }
        subModel.getModelMetaData().setDate(subRevision.getDate());
        ifcModelSet.add(subModel);
    }
    IfcModelInterface ifcModel = new BasicIfcModel(lastPackageMetaData, null);
    if (ifcModelSet.size() > 1) {
        try {
            ifcModel = getBimServer().getMergerFactory().createMerger(getDatabaseSession(), getAuthorization().getUoid()).merge(revision.getProject(), ifcModelSet, new ModelHelper(getBimServer().getMetaDataManager(), ifcModel));
        } catch (MergeException e) {
            throw new UserException(e);
        }
    } else {
        ifcModel = ifcModelSet.iterator().next();
    }
    ifcModel.getModelMetaData().setName(project.getName() + "." + revision.getId());
    ifcModel.getModelMetaData().setRevisionId(project.getRevisions().indexOf(revision) + 1);
    ifcModel.getModelMetaData().setAuthorizedUser(user.getName());
    ifcModel.getModelMetaData().setDate(new Date());
    return (IfcModel) ifcModel;
}
Also used : ModelHelper(org.bimserver.plugins.ModelHelper) IdEObject(org.bimserver.emf.IdEObject) PackageMetaData(org.bimserver.emf.PackageMetaData) IfcModelInterface(org.bimserver.emf.IfcModelInterface) IfcModelChangeListener(org.bimserver.ifc.IfcModelChangeListener) GeometryGeneratingException(org.bimserver.GeometryGeneratingException) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) Date(java.util.Date) OldQuery(org.bimserver.database.OldQuery) BasicIfcModel(org.bimserver.ifc.BasicIfcModel) IfcModel(org.bimserver.ifc.IfcModel) AtomicLong(java.util.concurrent.atomic.AtomicLong) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) MergeException(org.bimserver.plugins.modelmerger.MergeException) PluginConfiguration(org.bimserver.models.store.PluginConfiguration) IfcModelSet(org.bimserver.plugins.IfcModelSet) UserException(org.bimserver.shared.exceptions.UserException)

Example 43 with IdEObject

use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.

the class DownloadByNewJsonQueryDatabaseAction method convertWrapped.

private IdEObject convertWrapped(Revision revision, IfcModelInterface ifcModel, HashMapWrappedVirtualObject hashMapWrappedVirtualObject) throws IfcModelInterfaceException {
    IdEObject embeddedObject = ifcModel.create(hashMapWrappedVirtualObject.eClass());
    ((IdEObjectImpl) embeddedObject).setOid(-1);
    ((IdEObjectImpl) embeddedObject).setPid(revision.getProject().getId());
    for (EAttribute eAttribute : hashMapWrappedVirtualObject.eClass().getEAllAttributes()) {
        embeddedObject.eSet(eAttribute, hashMapWrappedVirtualObject.eGet(eAttribute));
    }
    return embeddedObject;
}
Also used : IdEObjectImpl(org.bimserver.emf.IdEObjectImpl) EAttribute(org.eclipse.emf.ecore.EAttribute) IdEObject(org.bimserver.emf.IdEObject)

Example 44 with IdEObject

use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.

the class DownloadCompareDatabaseAction method createStyledItemStyles.

@SuppressWarnings("unchecked")
private void createStyledItemStyles(IfcModelInterface model, String representationIdentifier, IdEObject ifcStyledItem, IdEObject color) throws IfcModelInterfaceException {
    IdEObject ifcPresentationStyleAssignment = model.create(model.getPackageMetaData().getEClass("IfcPresentationStyleAssignment"));
    EStructuralFeature stylesFeature = ifcStyledItem.eClass().getEStructuralFeature("Styles");
    List<IdEObject> list = (List<IdEObject>) ifcStyledItem.eGet(stylesFeature);
    list.add(ifcPresentationStyleAssignment);
    createPresentationStyleAssignmentStyles(model, representationIdentifier, ifcPresentationStyleAssignment, color);
}
Also used : IdEObject(org.bimserver.emf.IdEObject) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Example 45 with IdEObject

use of org.bimserver.emf.IdEObject in project BIMserver by opensourceBIM.

the class DownloadCompareDatabaseAction method createPresentationStyleAssignmentStyles.

@SuppressWarnings("unchecked")
private void createPresentationStyleAssignmentStyles(IfcModelInterface model, String representationIdentifier, IdEObject ifcPresentationStyleAssignment, IdEObject color) throws IfcModelInterfaceException {
    if (representationIdentifier.equals("Body")) {
        IdEObject ifcPresentationStyleSelect = model.create(model.getPackageMetaData().getEClass("IfcSurfaceStyle"));
        EStructuralFeature stylesFeature = ifcPresentationStyleAssignment.eClass().getEStructuralFeature("Styles");
        List<IdEObject> list = (List<IdEObject>) ifcPresentationStyleAssignment.eGet(stylesFeature);
        list.add(ifcPresentationStyleSelect);
        createSurfaceStyleStyles(model, representationIdentifier, ifcPresentationStyleSelect, color);
    } else {
    // Unimplemented
    }
}
Also used : IdEObject(org.bimserver.emf.IdEObject) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) EList(org.eclipse.emf.common.util.EList) List(java.util.List)

Aggregations

IdEObject (org.bimserver.emf.IdEObject)68 List (java.util.List)25 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)25 EClass (org.eclipse.emf.ecore.EClass)20 EReference (org.eclipse.emf.ecore.EReference)18 IdEObjectImpl (org.bimserver.emf.IdEObjectImpl)15 UserException (org.bimserver.shared.exceptions.UserException)15 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)14 EList (org.eclipse.emf.common.util.EList)14 EObject (org.eclipse.emf.ecore.EObject)14 ArrayList (java.util.ArrayList)12 AbstractEList (org.eclipse.emf.common.util.AbstractEList)12 HashSet (java.util.HashSet)10 IfcModelInterface (org.bimserver.emf.IfcModelInterface)10 HashMapVirtualObject (org.bimserver.shared.HashMapVirtualObject)10 OldQuery (org.bimserver.database.OldQuery)9 IfcModelInterfaceException (org.bimserver.emf.IfcModelInterfaceException)9 VirtualObject (org.bimserver.shared.VirtualObject)9 EAttribute (org.eclipse.emf.ecore.EAttribute)9 Project (org.bimserver.models.store.Project)8