private void handleCommonFields(IfcTypeObject type, IfcOwnerHistory oh, TypeType newType) {
   newType.setName(IfcToType.nameFromTypeObject(type));
   newType.setCreatedBy(COBieIfcUtility.getEmailFromOwnerHistory(oh));
   newType.setCreatedOn(IfcToContact.getCreatedOn(oh.getCreationDate()));
   newType.setCategory(IfcToType.categoryFromTypeObject(type));
   newType.setDescription(IfcToType.descriptionFromTypeObject(type));
   newType.setExtSystem(COBieIfcUtility.getApplicationName(oh));
   newType.setExtObject(IfcToType.extObjectFromTypeObject(type));
   newType.setExtIdentifier(COBieIfcUtility.identifierFromObjectDefinition(type));
 }
  public static void writeResources(COBIEType cType, IfcModelInterface model) {
    LogHandler loggerHandler = new LogHandler(sheetName, LOGGER);
    loggerHandler.sheetWriteBegin();
    COBIEType.Resources resources;
    String name;
    IfcOwnerHistory oh;
    String createdBy;
    Calendar createdOn;
    String category;
    String extSystem;
    String extObject;
    String extIdentifier;
    String description;
    try {
      resources = cType.getResources();
      if (resources == null) {
        resources = cType.addNewResources();
      }
    } catch (Exception ex) {
      resources = cType.addNewResources();
    }

    for (IfcConstructionEquipmentResource equipmentResource :
        model.getAll(IfcConstructionEquipmentResource.class)) {
      try {

        name = IfcToResource.nameFromConstructionEquipmentResource(equipmentResource);
        oh = equipmentResource.getOwnerHistory();
        createdBy = COBieUtility.getEmailFromOwnerHistory(oh);
        createdOn = IfcToContact.getCreatedOn(oh.getCreationDate());
        category = IfcToResource.categoryFromConstructionEquipmentResource(equipmentResource);
        extSystem = COBieUtility.getApplicationName(oh);
        extObject = COBieUtility.extObjectFromObjectDef(equipmentResource);
        extIdentifier = COBieUtility.extIdFromRoot(equipmentResource);
        description = IfcToResource.descriptionFromConstructionEquipmentResource(equipmentResource);

        ResourceType resource = resources.addNewResource();
        resource.setName(name);
        resource.setCreatedBy(createdBy);
        resource.setCreatedOn(createdOn);
        resource.setCategory(category);
        resource.setExtSystem(extSystem);
        resource.setExtObject(extObject);
        resource.setExtIdentifier(extIdentifier);
        resource.setDescription(description);
        loggerHandler.rowWritten();
      } catch (Exception ex) {
        loggerHandler.error(ex);
      }
    }
    loggerHandler.sheetWritten();
  }
  private static void exportDocumentInformationObjects(
      IfcModelInterface model,
      LogHandler loggerHandler,
      ArrayList<String> documentNames,
      COBIEType.Documents documents) {
    String name;
    String createdBy;
    Calendar createdOn;
    String category;
    String approvalBy;
    String stage;
    String sheetName;
    String rowName;
    String directory;
    String file;
    String extSystem;
    String extObject;
    String extIdentifier;
    String description;
    String reference;
    IfcOwnerHistory oh;
    DocumentType tempDocument;
    for (IfcRelAssociatesDocument relAssociatesDocument :
        model.getAll(IfcRelAssociatesDocument.class)) {
      IfcDocumentSelect docInfoSelect = relAssociatesDocument.getRelatingDocument();
      if (docInfoSelect instanceof IfcDocumentInformation) {
        IfcDocumentInformation docInfo = (IfcDocumentInformation) docInfoSelect;
        try {

          name = IfcToDocument.nameFromDocumentInformation(docInfo);
          oh = relAssociatesDocument.getOwnerHistory();
          createdBy = COBieIfcUtility.getEmailFromOwnerHistory(oh);
          createdOn = IfcToContact.getCreatedOn(oh.getCreationDate());
          category = IfcToDocument.categoryFromDocumentInformation(docInfo);
          approvalBy = IfcToDocument.approvalByFromDocumentInformation(docInfo);
          stage = IfcToDocument.stageFromDocumentInformation(docInfo);
          sheetName = IfcToDocument.sheetNameFromRelAssociatesDocument(relAssociatesDocument);
          rowName = IfcToDocument.rowNameFromRelAssociatesDocument(relAssociatesDocument);
          directory = IfcToDocument.directoryFromDocumentInformation(docInfo);
          file = IfcToDocument.fileFromDocumentInformation(docInfo);
          extSystem = COBieIfcUtility.getApplicationName(oh);
          extObject = IfcToDocument.extObjectFromRelAssociatesDocument(relAssociatesDocument);
          extIdentifier = IfcToDocument.extIdFromRelAssociatesDocument(relAssociatesDocument);
          description = IfcToDocument.descriptionFromDocumentInformation(docInfo);
          reference = IfcToDocument.referenceFromDocumentInformation(docInfo);

          tempDocument = documents.addNewDocument();
          tempDocument.setName(name);
          tempDocument.setCreatedBy(createdBy);
          tempDocument.setCreatedOn(createdOn);
          tempDocument.setCategory(category);
          tempDocument.setApprovalBy(approvalBy);
          tempDocument.setStage(stage);
          tempDocument.setSheetName(sheetName);
          tempDocument.setRowName(rowName);
          tempDocument.setDirectory(directory);
          tempDocument.setFile(file);
          tempDocument.setExtSystem(extSystem);
          tempDocument.setExtIdentifier(extIdentifier);
          tempDocument.setExtObject(extObject);
          tempDocument.setDescription(description);
          tempDocument.setReference(reference);
          documentNames.add(name);
          loggerHandler.rowWritten();
        } catch (Exception ex) {
          loggerHandler.error(ex);
        }
      }
    }
  }
  private static void exportTypeInformation(
      IfcModelInterface model,
      LogHandler loggerHandler,
      ArrayList<String> typeNames,
      ArrayList<String> documentNames,
      COBIEType.Documents documents) {
    String name;
    String createdBy;
    Calendar createdOn;
    String category;
    String approvalBy;
    String stage;
    String sheetName;
    String rowName;
    String directory;
    String file;
    String extSystem;
    String extObject;
    String extIdentifier;
    String description;
    String reference;
    IfcOwnerHistory oh;
    DocumentType tempDocument;
    if (documentNames.size() == 0) {
      for (IfcRelDefinesByType defByType : model.getAll(IfcRelDefinesByType.class)) {
        try {
          IfcTypeObject type = defByType.getRelatingType();
          if (type != null) {
            name = IfcToDocument.nameFromTypeObject(type);
            if (!typeNames.contains(name)) {

              oh = COBieIfcUtility.firstOwnerHistoryFromModel(model);
              createdBy = COBieIfcUtility.getEmailFromOwnerHistory(oh);
              createdOn = IfcToContact.getCreatedOn(oh.getCreationDate());
              category = IfcToDocument.categoryFromTypeObject(type);
              approvalBy = IfcToDocument.ApprovalBy;
              stage = IfcToDocument.Stage;
              sheetName = IfcToDocument.TypeSheetName;
              rowName = IfcToType.nameFromTypeObject(type);
              directory = IfcToDocument.Directory;
              file = IfcToDocument.File;
              extSystem = COBieIfcUtility.getApplicationName(oh);
              extObject = IfcToType.extObjectFromTypeObject(type);
              extIdentifier = COBieIfcUtility.extIdFromRoot(type);
              description = IfcToDocument.descriptionFromTypeObject(type);
              reference = IfcToDocument.Reference;

              tempDocument = documents.addNewDocument();
              typeNames.add(name);
              tempDocument.setName(name);
              tempDocument.setCreatedBy(createdBy);
              tempDocument.setCreatedOn(createdOn);
              tempDocument.setCategory(category);
              tempDocument.setApprovalBy(approvalBy);
              tempDocument.setStage(stage);
              tempDocument.setSheetName(sheetName);
              tempDocument.setRowName(rowName);
              tempDocument.setDirectory(directory);
              tempDocument.setFile(file);
              tempDocument.setExtSystem(extSystem);
              tempDocument.setExtObject(extObject);
              tempDocument.setExtIdentifier(extIdentifier);
              tempDocument.setDescription(description);
              tempDocument.setReference(reference);
              loggerHandler.rowWritten();
            }
          }
        } catch (Exception ex) {
          loggerHandler.error(ex);
        }
      }
    }
  }
  private static void exportBAMieClassificationReferences(
      IfcModelInterface model,
      LogHandler loggerHandler,
      ArrayList<String> documentNames,
      COBIEType.Documents documents) {
    String name;
    String createdBy;
    Calendar createdOn;
    String category;
    String approvalBy;
    String stage;
    String sheetName;
    String rowName;
    String directory;
    String extSystem;
    String extObject;
    String extIdentifier;
    String description;
    String reference;
    IfcOwnerHistory oh;
    DocumentType tempDocument;
    for (IfcDistributionElement element : model.getAllWithSubTypes(IfcDistributionElement.class)) {
      try {
        for (IfcRelAssociates relAssociates : element.getHasAssociations()) {
          if (relAssociates instanceof IfcRelAssociatesClassification) {
            category = COBieIfcUtility.getObjectClassificationCategoryString(element);
            if (ClassificationHandler.isBAMieRelAssociatesClassification(
                (IfcRelAssociatesClassification) relAssociates)) {
              name = COBieUtility.getCOBieString(element.getName());
              oh = element.getOwnerHistory();
              createdBy = COBieIfcUtility.getEmailFromOwnerHistory(oh);
              createdOn = IfcToContact.getCreatedOn(oh.getCreationDate());
              category = IfcToDocument.BAMIE_CATEGORY;
              approvalBy = IfcToDocument.ApprovalBy;
              stage = IfcToDocument.Stage;
              sheetName = COBieUtility.CobieSheetName.Component.name();
              rowName = IfcToDocument.bamieRowNameFromDistributionElement(element);
              extSystem = COBieIfcUtility.getApplicationName(oh);
              extObject = IfcToComponent.extObjectFromProduct(element);
              extIdentifier = COBieIfcUtility.extIdFromRoot(element);
              description = COBieUtility.getCOBieString(element.getName());
              reference = IfcToDocument.Reference;

              IfcClassificationReference classificationReference =
                  COBieIfcUtility.getObjectClassificationReference(element);
              directory = COBieUtility.getCOBieString(classificationReference.getLocation());

              tempDocument = documents.addNewDocument();
              tempDocument.setName(name);
              tempDocument.setCreatedBy(createdBy);
              tempDocument.setCreatedOn(createdOn);
              tempDocument.setCategory(category);
              tempDocument.setApprovalBy(approvalBy);
              tempDocument.setStage(stage);
              tempDocument.setSheetName(sheetName);
              tempDocument.setRowName(rowName);
              tempDocument.setDirectory(directory);
              tempDocument.setFile(COBieUtility.COBieNA);
              tempDocument.setExtSystem(extSystem);
              tempDocument.setExtObject(extObject);
              tempDocument.setExtIdentifier(extIdentifier);
              tempDocument.setDescription(description);
              tempDocument.setReference(reference);
              loggerHandler.rowWritten();
            }
          }
        }
      } catch (Exception ex) {

      }
    }
  }