Created
November 12, 2014 17:38
-
-
Save pedrosan7os/12286574202612a66017 to your computer and use it in GitHub Desktop.
InitializeAdministrativeOffices
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pt.ist.fenix.webapp; | |
import org.fenixedu.academic.domain.administrativeOffice.AdministrativeOffice; | |
import org.fenixedu.academic.domain.organizationalStructure.Accountability; | |
import org.fenixedu.academic.domain.organizationalStructure.PersonFunction; | |
import org.fenixedu.academic.domain.organizationalStructure.Unit; | |
import org.fenixedu.bennu.core.domain.Bennu; | |
import org.fenixedu.bennu.core.domain.User; | |
import org.fenixedu.bennu.scheduler.custom.CustomTask; | |
public class InitializeAdministrativeOffices extends CustomTask { | |
@Override | |
public void runTask() throws Exception { | |
for (AdministrativeOffice office : Bennu.getInstance().getAdministrativeOfficesSet()) { | |
office.setName(office.getUnit().getPartyName().toLocalizedString()); | |
office.setCoordinator(getActiveUnitCoordinator(office.getUnit())); | |
office.setCampus(office.getUnit().getCampus()); | |
} | |
} | |
private static User getActiveUnitCoordinator(Unit unit) { | |
for (final Accountability accountability : unit.getUnitCoordinatorFunction().getAccountabilitiesSet()) { | |
if (accountability.isPersonFunction() && accountability.isActive()) { | |
return ((PersonFunction) accountability).getPerson().getUser(); | |
} | |
} | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment