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); }
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(); } } } }