예제 #1
0
 @Override
 public Promise<List<AdminEntityDTO>> apply(AdminEntityDTO input) {
   if (input.getParentId() == null) {
     return Promise.resolved(Collections.<AdminEntityDTO>emptyList());
   } else {
     return Promise.resolved(input.getParentId()).join(new FetchEntityFunction());
   }
 }
예제 #2
0
    @Override
    public CreateLocation apply(List<AdminEntityDTO> entities) {

      AdminEntityDTO entity = entities.get(0);
      Preconditions.checkState(entity.getLevelId() == locationType.getBoundAdminLevelId());

      Map<String, Object> properties = new HashMap<>();
      properties.put("id", locationId);
      properties.put("locationTypeId", locationType.getId());
      properties.put("name", entity.getName());

      for (AdminEntityDTO parent : entities) {
        properties.put(AdminLevelDTO.getPropertyName(parent.getLevelId()), parent.getId());
      }

      return new CreateLocation(properties);
    }