Search in sources :

Example 6 with IfcHeader

use of org.bimserver.models.store.IfcHeader in project BIMserver by opensourceBIM.

the class SharedJsonSerializer method write.

public boolean write(OutputStream outputStream, ProgressReporter progressReporter) throws SerializerException {
    this.outputStream = outputStream;
    try {
        if (mode == Mode.HEADER) {
            print("{");
            IfcHeader ifcHeader = model.getModelMetaData().getIfcHeader();
            if (ifcHeader != null) {
                print("\"header\":");
                writeObject(ifcHeader);
                print("\n,");
            }
            print("\"objects\":[");
            mode = Mode.BODY;
            iterator = model.iterator();
            return true;
        } else if (mode == Mode.BODY) {
            if (iterator.hasNext()) {
                IdEObject object = iterator.next();
                if (object.getOid() == -1) {
                    throw new SerializerException("Object cannot have oid -1 " + object.eClass().getName());
                }
                if (object.eClass().getEAnnotation("hidden") == null || includeHidden) {
                    if (!firstObject) {
                        print(",");
                    } else {
                        firstObject = false;
                    }
                    writeObject(object);
                }
                return true;
            } else {
                print("]");
                print("}");
                mode = Mode.FOOTER;
                return true;
            }
        } else if (mode == Mode.FOOTER) {
            mode = Mode.DONE;
            return false;
        }
    } catch (Throwable e) {
        throw new SerializerException(e);
    }
    return false;
}
Also used : IfcHeader(org.bimserver.models.store.IfcHeader) SerializerException(org.bimserver.plugins.serializers.SerializerException)

Aggregations

IfcHeader (org.bimserver.models.store.IfcHeader)6 ConcreteRevision (org.bimserver.models.store.ConcreteRevision)4 Revision (org.bimserver.models.store.Revision)4 User (org.bimserver.models.store.User)4 UserException (org.bimserver.shared.exceptions.UserException)4 HashMap (java.util.HashMap)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 IdEObject (org.bimserver.emf.IdEObject)3 IfcModelInterface (org.bimserver.emf.IfcModelInterface)3 ByteBuffer (java.nio.ByteBuffer)2 Date (java.util.Date)2 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)2 GenerateGeometryResult (org.bimserver.GenerateGeometryResult)2 GeometryGeneratingException (org.bimserver.GeometryGeneratingException)2 ServerIfcModel (org.bimserver.ServerIfcModel)2 SummaryMap (org.bimserver.SummaryMap)2 OldQuery (org.bimserver.database.OldQuery)2 PostCommitAction (org.bimserver.database.PostCommitAction)2 PackageMetaData (org.bimserver.emf.PackageMetaData)2 IfcModel (org.bimserver.ifc.IfcModel)2