Пример #1
0
  public void addArgument(IPeopleQueryArgument argument) {

    if (getArgumentMap().containsKey(argument.getName())) {
      throw new RuntimeException(
          "There is already exists an argument with name "
              + argument.getName()
              + " within the people query.");
    }

    List<Peoplequeryargument> peopleQueryArgEntities = peopleQueryEntity.getPeoplequeryarguments();

    /* If the people query doesn't contain any arguments yet the list
     * of people query arguments is null.
     */
    if (peopleQueryArgEntities == null) {
      peopleQueryArgEntities = new ArrayList<Peoplequeryargument>();
      peopleQueryEntity.setPeoplequeryarguments(peopleQueryArgEntities);
    }

    Peoplequeryargument peopleQueryArgEntity = (Peoplequeryargument) argument.getAdaptee();
    /*
     * There is a bidirectional relation between people
     * query entities and people query argument entities consequently
     * both sides of the relationship have to be set.
     */
    peopleQueryArgEntities.add(peopleQueryArgEntity);
    peopleQueryArgEntity.setPeoplequeryBean(peopleQueryEntity);
  }
Пример #2
0
  public PeopleQueryWrapper(Peoplequery adaptee) {

    if (adaptee.getLogicalpeoplegroupdef() == null) {
      throw new RuntimeException(
          "Invalid people query. "
              + "There must be always a logical people group definition "
              + "associated with the people query.");
    }
    this.peopleQueryEntity = adaptee;
  }
Пример #3
0
  public void removeArgument(IPeopleQueryArgument argumentToRemove) {
    List<Peoplequeryargument> queryArgumentEntities = peopleQueryEntity.getPeoplequeryarguments();

    /* Search for the argument that is to be removed (simply by name).
     * If the people query hasn't any arguments queryArgumentEntities is null */
    if (queryArgumentEntities != null) {
      Iterator<Peoplequeryargument> iter = queryArgumentEntities.iterator();
      /* Iterate over all arguments and remove the argument that has the same
       * name like the argument that is to be delete.  */
      while (iter.hasNext()) {
        String argumentName = getPeopleQueryArgumentName(iter.next());
        if (argumentName.equals(argumentToRemove.getName())) {
          /* Remove people query argument */
          iter.remove();
        }
      }
    }
  }
Пример #4
0
  protected Map<String, IPeopleQueryArgument> getArgumentMap() {
    List<Peoplequeryargument> argumentEntities = peopleQueryEntity.getPeoplequeryarguments();

    Map<String, IPeopleQueryArgument> arguments = new HashMap<String, IPeopleQueryArgument>();
    if (argumentEntities != null) {
      /* Get all people query arguments and their associated names */
      Iterator<Peoplequeryargument> iter = argumentEntities.iterator();
      while (iter.hasNext()) {
        Peoplequeryargument peoplequeryArgument = (Peoplequeryargument) iter.next();
        /* Get the name of the people query argument */
        String argumentName = getPeopleQueryArgumentName(peoplequeryArgument);
        if (argumentName != null) {
          /* Add the name and the people query argument model to the map */
          arguments.put(
              argumentName,
              /* Determine the model of the people query argument */
              ModelElementFactory.newInstance().createPeopleGroupArgument(peoplequeryArgument));
        }
      }
    }
    return arguments;
  }
Пример #5
0
  public void setLogicalPeopleGroupDef(ILogicalPeopleGroupDef lpgDefinition) {
    Logicalpeoplegroupdef lpgDefEntity = (Logicalpeoplegroupdef) lpgDefinition.getAdaptee();

    /*
     * There is a bidirectional relation between LPG definitions and people
     * queries in the generated JPA entities consequently both sides of the relationship
     * have to be set.
     */

    peopleQueryEntity.setLogicalpeoplegroupdef(lpgDefEntity);

    /* The list contains all people queries which are already
     * associated with the LPG definition */
    List<Peoplequery> peopleQueryEntities = lpgDefEntity.getPeoplequeries();

    /* If this people query is the first one that is associated with the
     * LPG definition the list is null thus it has to be instantiated */
    if (peopleQueryEntities == null) {
      peopleQueryEntities = new ArrayList<Peoplequery>();
      lpgDefEntity.setPeoplequeries(peopleQueryEntities);
    }
    peopleQueryEntities.add(peopleQueryEntity);
  }
Пример #6
0
 public String getId() {
   return Integer.toString(peopleQueryEntity.getId());
 }
Пример #7
0
 public ILogicalPeopleGroupDef getBoundPeopleGroup() {
   /* Create the model of the LPG definition from the entity model */
   return ModelElementFactory.newInstance()
       .createPeopleGroupDefinition(peopleQueryEntity.getLogicalpeoplegroupdef());
 }