@Override
 public Field<?> build(RecordVO recordVO, MetadataVO metadataVO) {
   Field<?> field;
   String metadataCode = MetadataVO.getCodeWithoutPrefix(metadataVO.getCode());
   RetentionRuleVO retentionRuleVO = (RetentionRuleVO) recordVO;
   switch (metadataCode) {
     case RetentionRule.COPY_RETENTION_RULES:
       field =
           new CopyRetentionRuleTable(retentionRuleVO, true, getOpenPeriodsDDVList()) {
             @Override
             protected void onDisposalTypeChange(CopyRetentionRule copyRetentionRule) {
               RetentionRuleFieldFactory.this.onDisposalTypeChange(copyRetentionRule);
             }
           };
       postBuild(field, recordVO, metadataVO);
       return field;
     case RetentionRule.DOCUMENT_TYPES_DETAILS:
       field = new ListAddRemoveRetentionRuleDocumentTypeField();
       postBuild(field, recordVO, metadataVO);
       return field;
     case "categories":
       field = super.build(recordVO, metadataVO);
       ((ListAddRemoveRecordLookupField) field).setIgnoreLinkability(true);
       return field;
     default:
       return super.build(recordVO, metadataVO);
   }
 }
  public void sort(MetadataVO[] propertyId, boolean[] ascending) {
    query.clearSort();

    for (int i = 0; i < propertyId.length; i++) {
      Metadata metadata;
      MetadataSchema schema = query.getSchemaCondition();
      MetadataVO metadataVO = propertyId[i];
      metadata = schema.getMetadata(metadataVO.getCode());

      if (ascending[i]) {
        query = query.sortAsc(metadata);
      } else {
        query = query.sortDesc(metadata);
      }
    }
  }