package net.sourceforge.fenixedu.domain.accessControl; import java.util.Set; import net.sourceforge.fenixedu.domain.Attends; import net.sourceforge.fenixedu.domain.Grouping; import net.sourceforge.fenixedu.domain.Person; import net.sourceforge.fenixedu.domain.accessControl.groups.language.Argument; import net.sourceforge.fenixedu.domain.accessControl.groups.language.GroupBuilder; import net.sourceforge.fenixedu.domain.accessControl.groups.language.exceptions.GroupDynamicExpressionException; import net.sourceforge.fenixedu.domain.accessControl.groups.language.operators.IdOperator; public class GroupingGroup extends DomainBackedGroup { private static final long serialVersionUID = 1L; public GroupingGroup(Grouping grouping) { super(grouping); } @Override public Set getElements() { Set persons = super.buildSet(); if (getObject() != null) { for (Attends attend : getObject().getAttends()) { persons.add(attend.getRegistration().getStudent().getPerson()); } } return super.freezeSet(persons); } @Override protected Argument[] getExpressionArguments() { return new Argument[] { new IdOperator(getObject()) }; } public static class Builder implements GroupBuilder { public Group build(Object[] arguments) { try { return new GroupingGroup((Grouping) arguments[0]); } catch (ClassCastException e) { throw new GroupDynamicExpressionException("accessControl.group.builder.grouping.notGrouping", arguments[0] .toString()); } } public int getMinArguments() { return 0; } public int getMaxArguments() { return 1; } } }