protected static String stageFromDocumentInformation(IfcDocumentInformation documentInformation) {
   String stage = documentInformation.getScope();
   if (COBieUtility.isNA(stage)) {
     stage = IfcToDocument.Stage;
   }
   return COBieUtility.getCOBieString(stage);
 }
  protected static String fileFromDocumentInformation(IfcDocumentInformation documentInformation) {
    String fileName = "";
    try {
      if ((documentInformation != null)
          && (documentInformation.getDocumentReferences() != null)
          && (documentInformation.getDocumentReferences().size() > 0)) {
        IfcDocumentReference firstReference = documentInformation.getDocumentReferences().get(0);
        String itemReference = "";
        String name = "";
        if (firstReference.isSetItemReference()) {
          itemReference = firstReference.getItemReference();
        }
        if (firstReference.isSetName()) {
          name = firstReference.getName();
        }
        if (!COBieUtility.isNA(name) && !documentInformation.getName().equals(name)) {
          fileName = name;
        } else if (!COBieUtility.isNA(itemReference)) {
          fileName = itemReference;
        }
        fileName = documentInformation.getDocumentReferences().get(0).getItemReference();
      }
      if (COBieUtility.isNA(fileName)) {
        fileName = IfcToDocument.File;
      }
    } catch (Exception ex) {

    }

    return fileName;
  }
 protected static String approvalByFromDocumentInformation(
     IfcDocumentInformation documentInformation) {
   String approvalBy = documentInformation.getIntendedUse();
   if (COBieUtility.isNA(approvalBy)) {
     approvalBy = IfcToDocument.ApprovalBy;
   }
   return COBieUtility.getCOBieString(approvalBy);
 }
 protected static String referenceFromDocumentInformation(
     IfcDocumentInformation documentInformation) {
   String referenceString = "";
   if (!COBieUtility.isNA(documentInformation.getDescription())) {
     referenceString = documentInformation.getDescription();
   } else {
     referenceString = documentInformation.getName();
   }
   return COBieUtility.getCOBieString(referenceString);
 }
 protected static String extObjectFromRelAssociatesDocument(
     IfcRelAssociatesDocument relAssociatesDocument) {
   String extObject = "";
   if ((relAssociatesDocument.getRelatedObjects() != null)
       && (relAssociatesDocument.getRelatedObjects().size() > 0)) {
     extObject = relAssociatesDocument.getRelatedObjects().get(0).getClass().getSimpleName();
   }
   extObject = COBieUtility.trimImplFromClassNameString(extObject);
   return COBieUtility.getCOBieString(extObject);
 }
 protected static String bamieRowNameFromDistributionElement(
     IfcDistributionElement distributionElement) {
   String rowName = "";
   for (IfcRelDecomposes decomposeRelation : distributionElement.getIsDecomposedBy()) {
     if ((decomposeRelation instanceof IfcRelAggregates) && COBieUtility.isNA(rowName)) {
       IfcRelAggregates aggregates = (IfcRelAggregates) decomposeRelation;
       rowName = aggregates.getRelatingObject().getName();
     }
   }
   return COBieUtility.getCOBieString(rowName);
 }
 protected static String sheetNameFromRelAssociatesDocument(
     IfcRelAssociatesDocument relAssociatesDocument) {
   String sheetName = "";
   if ((relAssociatesDocument.getRelatedObjects() != null)
       && (relAssociatesDocument.getRelatedObjects().size() > 0)) {
     sheetName = sheetNameFromRoot(relAssociatesDocument.getRelatedObjects().get(0));
   }
   return COBieUtility.getCOBieString(sheetName);
 }
 protected static String extIdFromRelAssociatesDocument(
     IfcRelAssociatesDocument relAssociatesDocument) {
   String extId = "";
   if ((relAssociatesDocument.getRelatedObjects() != null)
       && (relAssociatesDocument.getRelatedObjects().size() > 0)) {
     extId = COBieIfcUtility.extIdFromRoot(relAssociatesDocument.getRelatedObjects().get(0));
   }
   return COBieUtility.getCOBieString(extId);
 }
 @SuppressWarnings("deprecation")
 private static ArrayList<String> getExistingTypes(COBIEType.Documents documents) {
   ArrayList<String> existingTypes = new ArrayList<String>();
   for (DocumentType document : documents.getDocumentArray()) {
     if (document.getSheetName().equalsIgnoreCase(COBieUtility.CobieSheetName.Type.name())
         && !COBieUtility.isNA(document.getName())) {
       existingTypes.add(document.getName());
     }
   }
   return existingTypes;
 }
  private void assignWarrantyInformationByPropertyNames(
      IfcTypeObject type, TypeType newType, boolean assignOnlyOnNulls) {

    if (assignOnlyOnNulls) {
      if (COBieUtility.isNA(newType.getWarrantyGuarantorParts())) {
        newType.setWarrantyGuarantorParts(IfcToType.warrantyGuarantorPartsFromTypeObject(type));
      }
      if (COBieUtility.isNA(newType.getWarrantyDurationParts())) {
        newType.setWarrantyDurationParts(IfcToType.warrantyDurationPartsFromTypeObject(type));
      }
      if (COBieUtility.isNA(newType.getWarrantyGuarantorLabor())) {
        newType.setWarrantyGuarantorLabor(IfcToType.warrantyGuarantorLaborFromTypeObject(type));
      }
      if (COBieUtility.isNA(newType.getWarrantyDurationLabor())) {
        newType.setWarrantyDurationLabor(IfcToType.warrantyDurationLaborFromTypeObject(type));
      }
      if (COBieUtility.isNA(newType.getWarrantyDurationUnit())) {
        newType.setWarrantyDurationUnit(IfcToType.warrantyDurationUnitsFromTypeObject(type, model));
      }
      if (COBieUtility.isNA(newType.getWarrantyDescription())) {
        newType.setWarrantyDescription(IfcToType.warrantyDescriptionFromTypeObject(type));
      }
    } else {
      newType.setWarrantyGuarantorParts(IfcToType.warrantyGuarantorPartsFromTypeObject(type));
      newType.setWarrantyDurationParts(IfcToType.warrantyDurationPartsFromTypeObject(type));
      newType.setWarrantyGuarantorLabor(IfcToType.warrantyGuarantorLaborFromTypeObject(type));
      newType.setWarrantyDurationLabor(IfcToType.warrantyDurationLaborFromTypeObject(type));
      newType.setWarrantyDurationUnit(IfcToType.warrantyDurationUnitsFromTypeObject(type, model));
      newType.setWarrantyDescription(IfcToType.warrantyDescriptionFromTypeObject(type));
    }
  }
 protected static String directoryFromDocumentInformation(
     IfcDocumentInformation documentInformation) {
   String directoryName = "";
   if ((documentInformation != null)
       && (documentInformation.getDocumentReferences() != null)
       && (documentInformation.getDocumentReferences().size() > 0)) {
     directoryName = documentInformation.getDocumentReferences().get(0).getLocation();
   }
   if (COBieUtility.isNA(directoryName)) {
     directoryName = IfcToDocument.Directory;
   }
   return directoryName;
 }
  private void assignFromWarranty(
      WarrantyType warrantyType,
      Pset_Warranty warranty,
      TypeType newType,
      boolean assignOnlyOnNulls) {
    IfcPropertySingleValue duration = warranty.getWarrantyPeriod();
    IfcPropertyReferenceValue guarantor = warranty.getPointOfContact();

    IfcSingleValueToCOBieString durationStrings = null;
    IfcSingleValueToCOBieString warrantyDescription = null;
    try {
      durationStrings = new IfcSingleValueToCOBieString(duration);
    } catch (Exception ex) {

    }
    try {
      warrantyDescription = new IfcSingleValueToCOBieString(warranty.getWarrantyContent());
    } catch (Exception ex) {

    }

    String durationValue = (durationStrings == null ? null : durationStrings.getValueString());
    String durationUnit = (durationStrings == null ? null : durationStrings.getUnitString());
    String guarantorEmail = "";
    String existingDuration, existingGuarantor, existingDescription;
    String description =
        (warrantyDescription == null ? null : warrantyDescription.getValueString());
    existingDescription = newType.getWarrantyDescription();
    if ((guarantor != null)
        && (guarantor.getPropertyReference() != null)
        && (guarantor.getPropertyReference() instanceof IfcOrganization)) {
      guarantorEmail =
          COBieIfcUtility.getEmailFromOrganization(
              (IfcOrganization) guarantor.getPropertyReference());
    }
    switch (warrantyType) {
      case LABOR:
        if (assignOnlyOnNulls) {
          existingDuration = newType.getWarrantyDurationLabor();
          existingGuarantor = newType.getWarrantyGuarantorLabor();

          if (COBieUtility.isNA(existingDuration)) {
            newType.setWarrantyDurationLabor(durationValue);
          }
          if (COBieUtility.isNA(existingGuarantor)) {
            newType.setWarrantyGuarantorLabor(guarantorEmail);
          }
        } else {
          newType.setWarrantyDurationLabor(durationValue);
          newType.setWarrantyGuarantorLabor(guarantorEmail);
        }
        break;
      case PARTS:
        if (assignOnlyOnNulls) {
          existingDuration = newType.getWarrantyDurationParts();
          existingGuarantor = newType.getWarrantyGuarantorParts();
          if (COBieUtility.isNA(existingDuration)) {
            newType.setWarrantyDurationParts(durationValue);
          }
          if (COBieUtility.isNA(existingGuarantor)) {
            newType.setWarrantyGuarantorParts(guarantorEmail);
          }
        } else {
          newType.setWarrantyDurationParts(durationValue);
          newType.setWarrantyGuarantorParts(guarantorEmail);
        }
        break;
      default:
        break;
    }
    if (assignOnlyOnNulls) {
      if (COBieUtility.isNA(newType.getWarrantyDurationUnit())) {
        newType.setDurationUnit(durationUnit);
      }
      if (COBieUtility.isNA(existingDescription)) {
        newType.setWarrantyDescription(existingDescription);
      }
    } else {
      newType.setDurationUnit(durationUnit);
      newType.setWarrantyDescription(description);
    }
  }
 protected static String descriptionFromDocumentInformation(
     IfcDocumentInformation documentInformation) {
   String documentation = documentInformation.getDescription();
   return COBieUtility.getCOBieString(documentation);
 }
 protected static String categoryFromDocumentInformation(
     IfcDocumentInformation documentInformation) {
   String category = "";
   category = documentInformation.getPurpose();
   return COBieUtility.getCOBieString(category);
 }
 protected static String nameFromDocumentInformation(IfcDocumentInformation documentInformation) {
   String name = documentInformation.getName();
   return COBieUtility.getCOBieString(name);
 }
  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) {

      }
    }
  }