-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,106 additions
and
210 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.5.5 | ||
2.6.0-rc2 |
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package jobs; | ||
|
||
import com.google.common.base.Optional; | ||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.Lists; | ||
import dao.absences.AbsenceComponentDao; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
import javax.inject.Inject; | ||
import lombok.extern.slf4j.Slf4j; | ||
import models.Person; | ||
import models.absences.Absence; | ||
import org.joda.time.LocalDate; | ||
import play.Play; | ||
import play.jobs.Job; | ||
import play.jobs.OnApplicationStart; | ||
|
||
@Slf4j | ||
@OnApplicationStart(async = true) | ||
public class ParentalCodesFix extends Job { | ||
|
||
@Inject | ||
static AbsenceComponentDao absenceComponentDao; | ||
|
||
@Override | ||
public void doJob() { | ||
|
||
//in modo da inibire l'esecuzione dei job in base alla configurazione | ||
if (!"true".equals(Play.configuration.getProperty(Bootstrap.JOBS_CONF))) { | ||
log.info("{} interrotto. Disattivato dalla configurazione.", getClass().getName()); | ||
return; | ||
} | ||
log.info("Start Job parental codes fix"); | ||
List<String> codes = ImmutableList.of("25O", "252O", "253O", "254O", "25MO", "252MO", "253MO", | ||
"254MO", "25OH7", "252OH7", "253OH7", "254OH7"); | ||
List<Absence> allChildrenCodes = absenceComponentDao.absences(codes); | ||
List<Absence> childrenCodesFiltered = allChildrenCodes.stream() | ||
.filter(ab -> !ab.personDay.date.isBefore(new LocalDate(2022, 8, 13))) | ||
.collect(Collectors.toList()); | ||
log.debug("Ci sono {} assenze da modificare", childrenCodesFiltered.size() ); | ||
for (Absence abs : childrenCodesFiltered) { | ||
switch (abs.absenceType.code) { | ||
case "25O": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("25").get(); | ||
break; | ||
case "252O": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("252").get(); | ||
break; | ||
case "253O": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("253").get(); | ||
break; | ||
case "254O": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("254").get(); | ||
break; | ||
case "25MO": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("25M").get(); | ||
break; | ||
case "252MO": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("252M").get(); | ||
break; | ||
case "253MO": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("253M").get(); | ||
break; | ||
case "254MO": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("254M").get(); | ||
break; | ||
case "25OH7": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("25H7").get(); | ||
break; | ||
case "252OH7": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("252H7").get(); | ||
break; | ||
case "253OH7": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("253H7").get(); | ||
break; | ||
case "254OH7": | ||
abs.absenceType = absenceComponentDao.absenceTypeByCode("254H7").get(); | ||
break; | ||
default: | ||
break; | ||
} | ||
abs.save(); | ||
} | ||
|
||
log.info("End Job parental codes fix"); | ||
|
||
} | ||
} |
Oops, something went wrong.