Beispiel #1
0
  @Test
  public void testQueryByProperty() throws IOException {

    org.seadva.registry.database.model.obj.vaRegistry.Collection collection =
        new org.seadva.registry.database.model.obj.vaRegistry.Collection();
    collection.setId(UUID.randomUUID().toString());
    collection.setName("test");
    collection.setVersionNum("1");
    collection.setIsObsolete(0);
    collection.setEntityName("test");
    collection.setEntityCreatedTime(new Date());
    collection.setEntityLastUpdatedTime(new Date());
    collection.setState(client.getStateByName("PublishedObject"));

    Property property = new Property();
    property.setMetadata(client.getMetadataByType("abstract"));
    property.setValuestr("value_1.0");
    collection.addProperty(property);

    client.postCollection(collection);

    List<BaseEntity> entityList =
        client.queryByProperty("abstract", "value_1.0", QueryAttributeType.PROPERTY);
    assertTrue(entityList.size() > 0);
  }
Beispiel #2
0
  @Test
  public void testUpdateProperty() throws IOException {

    List<BaseEntity> entityList =
        client.queryByProperty("abstract", "value_1.0", QueryAttributeType.PROPERTY);
    for (BaseEntity entity : entityList) {

      Iterator props = entity.getProperties().iterator();
      Set<Property> updatesProperties = new HashSet<Property>();
      while (props.hasNext()) {
        Property property = (Property) props.next();
        if (property.getMetadata().getMetadataElement().contains("abstract"))
          property.setValuestr("value_2.0");
        updatesProperties.add(property);
        props.remove();
      }

      entity.setProperties(updatesProperties);
      client.postEntity(entity);
    }
    List<BaseEntity> entityList2 =
        client.queryByProperty("abstract", "value_2.0", QueryAttributeType.PROPERTY);
    assertTrue(entityList2.size() > 0);
  }