Пример #1
0
  private void addPropertyForSingleValueMetadata(
      Set<String> orgfilter,
      String typeId,
      PropertiesImpl result,
      Metadata metadata,
      Object value,
      String propertyCode) {
    if (metadata.getType().isStringOrText() || metadata.getType() == MetadataValueType.REFERENCE) {
      addPropertyString(result, typeId, orgfilter, propertyCode, (String) value);

    } else if (metadata.getType() == MetadataValueType.BOOLEAN) {
      addPropertyBoolean(result, typeId, orgfilter, propertyCode, (Boolean) value);

    } else if (metadata.getType() == MetadataValueType.ENUM) {
      addPropertyEnum(result, typeId, orgfilter, propertyCode, (EnumWithSmallCode) value);

    } else if (metadata.getType() == MetadataValueType.NUMBER) {
      addPropertyDouble(result, typeId, orgfilter, propertyCode, (Double) value);

    } else if (metadata.getType() == MetadataValueType.DATE_TIME
        || metadata.getType() == MetadataValueType.DATE) {
      GregorianCalendar calendarValue = getGregorianCalendar(value);
      addPropertyDateTime(result, typeId, orgfilter, propertyCode, calendarValue);

    } else if (metadata.getType() == MetadataValueType.CONTENT) {
      addPropertyString(result, typeId, orgfilter, propertyCode, ((Content) value).getId());
    }
  }
 private Metadata newAllAuthorizationsMetadata(String schemaCode) {
   String code = schemaCode + "_allauthorizations";
   Metadata metadata = mock(Metadata.class, code);
   when(metadata.getLocalCode()).thenReturn("allauthorizations");
   when(metadata.getCode()).thenReturn(code);
   when(metadata.getType()).thenReturn(MetadataValueType.STRING);
   return metadata;
 }
 private Metadata newPathMetadata(String schemaCode) {
   String code = schemaCode + "_path";
   Metadata metadata = mock(Metadata.class, code);
   when(metadata.getLocalCode()).thenReturn("path");
   when(metadata.getCode()).thenReturn(code);
   when(metadata.getType()).thenReturn(MetadataValueType.STRING);
   return metadata;
 }
Пример #4
0
  private void addPropertyForMultiValueMetadata(
      Set<String> orgfilter,
      String typeId,
      PropertiesImpl result,
      Metadata metadata,
      Object value,
      String propertyCode) {
    if (!((List) value).isEmpty()) {
      if (metadata.getType().isStringOrText()
          || metadata.getType() == MetadataValueType.REFERENCE) {
        addPropertyListString(result, typeId, orgfilter, propertyCode, (List<String>) value);

      } else if (metadata.getType() == MetadataValueType.ENUM) {
        addPropertyListEnum(
            result, typeId, orgfilter, propertyCode, (List<EnumWithSmallCode>) value);

      } else if (metadata.getType() == MetadataValueType.BOOLEAN) {
        addPropertyListBoolean(result, typeId, orgfilter, propertyCode, (List<Boolean>) value);

      } else if (metadata.getType() == MetadataValueType.NUMBER) {
        addPropertyListInteger(result, typeId, orgfilter, propertyCode, (List<Long>) value);

      } else if (metadata.getType() == MetadataValueType.DATE_TIME
          || metadata.getType() == MetadataValueType.DATE) {
        List<GregorianCalendar> calendarValues = new ArrayList<>();
        for (Object dateObject : (List<Object>) value) {
          calendarValues.add(getGregorianCalendar(dateObject));
        }
        addPropertyListDateTime(result, typeId, orgfilter, propertyCode, calendarValues);
      }
    }
  }
  private Metadata givenReferenceToSchemaType(
      Metadata metadata, MetadataSchemaTypes types, String code, boolean childOf, String type) {
    when(metadata.getCode()).thenReturn(code);
    when(metadata.getLocalCode()).thenReturn(code.split("_")[2]);
    when(metadata.getType()).thenReturn(MetadataValueType.REFERENCE);

    AllowedReferences allowedReferences = new AllowedReferences(type, null);
    when(metadata.getAllowedReferences()).thenReturn(allowedReferences);
    when(types.getMetadata(code)).thenReturn(metadata);

    return metadata;
  }
  @Before
  public void setUp() throws Exception {
    when(textMetadata.getDataStoreCode()).thenReturn("textMetadata");
    when(textMetadata.getType()).thenReturn(MetadataValueType.STRING);

    when(referenceMetadata.getDataStoreCode()).thenReturn("referenceMetadata");
    when(referenceMetadata.getType()).thenReturn(MetadataValueType.REFERENCE);

    when(numberMetadata.getDataStoreCode()).thenReturn("numberMetadata");
    when(numberMetadata.getType()).thenReturn(MetadataValueType.NUMBER);

    when(booleanMetadata.getDataStoreCode()).thenReturn("booleanMetadata");
    when(booleanMetadata.getType()).thenReturn(MetadataValueType.BOOLEAN);

    when(dateMetadata.getDataStoreCode()).thenReturn("dateTimeMetadata");
    when(dateMetadata.getType()).thenReturn(MetadataValueType.DATE_TIME);

    when(contentMetadata.getDataStoreCode()).thenReturn("contentMetadata");
    when(contentMetadata.getType()).thenReturn(MetadataValueType.CONTENT);
  }