checkArgument(mapDTO.getGreenScore() >= 0);
checkArgument(mapDTO.getObjectives().length == mapModel.getObjectives().size());
// 1. synchronize objectives
Optional<IWVWObjective> optionalObjectiveModel;
IWVWObjective objectiveModel;
Optional<IWorld> potentialNewOwner;
Optional<IGuildDetailsDTO> claimedByGuildDTO;
for (IWVWObjectiveDTO objectiveDTO : mapDTO.getObjectives()) {
optionalObjectiveModel = mapModel.getByObjectiveId(objectiveDTO.getId());
if (optionalObjectiveModel.isPresent()) {
objectiveModel = optionalObjectiveModel.get();
objectiveModel.updateOnSynchronization();
if (LOGGER.isTraceEnabled()) {
LOGGER.trace("Going to synchronize model=" + objectiveModel + " with dto=" + objectiveDTO);
}
// 1.1 synchronize owner
potentialNewOwner = match.getWorldByDTOOwnerString(objectiveDTO.getOwner());
objectiveModel.capture(potentialNewOwner.orNull());
// 1.2 synchronize claiming guild
claimedByGuildDTO = objectiveDTO.getGuildDetails();
if (claimedByGuildDTO.isPresent()) {
final IGuild guild = MODEL_FACTORY.getOrCreateGuild(claimedByGuildDTO.get().getId(), claimedByGuildDTO.get().getName(), claimedByGuildDTO.get().getTag());
objectiveModel.claim(guild);
} else {
objectiveModel.claim(null);
}
} else {
LOGGER.error("Missing " + IWVWObjective.class.getSimpleName() + " for objectiveId=" + objectiveDTO.getId());
}
}