@SuppressWarnings("unchecked")
 private void addSearchResult(IEntity entity, ISearchField projectField) {
   String fieldName = projectField.getFieldName();
   if (isRelationshipField(projectField)) {
     // CMS-3430 : treat a projection of relationship field as
     // project on the reference oid
     List<IEntity> projectFieldValues = (List<IEntity>) entity.getFieldValues(fieldName);
     for (IEntity e : projectFieldValues) {
       rootProjections.add(e.getId());
     }
   } else {
     rootProjections.addAll(projectField.getSearchValue(entity));
   }
 }
Exemple #2
0
  @Test
  public void testSub03() {
    String sub =
        "ServiceInstance[@name=~\"srp-app.*\" and @runsOn =& Compute[@name=~\"compute-0000.*\"]]";

    IQueryResult result = queryService.query(sub, raptorContext);
    Assert.assertNotNull(result);
    Assert.assertNotNull(result.getEntities());
    Assert.assertEquals(8, result.getEntities().size());

    // the service instance that have no compute attached
    String notIn1 = "4fbb314fc681caf13e283a7a";
    // the service instance that have compute name as compute-00010 (not match the regex).
    String notIn2 = "4fbb314fc681caf13e283a8c";
    for (IEntity entity : result.getEntities()) {
      Assert.assertEquals("ServiceInstance", entity.getType());
      Assert.assertFalse(entity.getId().equals(notIn1));
      Assert.assertFalse(entity.getId().equals(notIn2));
    }
  }