コード例 #1
0
 private Pset_Warranty getWarrantyWithWarrantyIdentifierContaining(
     List<Pset_Warranty> psetWarranties, String searchString) {
   Pset_Warranty laborWarranty = null;
   for (Pset_Warranty warranty : psetWarranties) {
     IfcPropertySingleValue warrantyId = warranty.getWarrantyIdentifier();
     IfcSingleValueToCOBieString id = new IfcSingleValueToCOBieString(warrantyId);
     if (id.getValueString().toLowerCase().contains(searchString)) {
       laborWarranty = warranty;
     }
   }
   if (laborWarranty == null) {
     throw new UnsupportedOperationException(
         "No matches found for warranty with identifier containing " + searchString);
   }
   return laborWarranty;
 }
コード例 #2
0
  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);
    }
  }