use of org.openstreetmap.atlas.checks.maproulette.data.Challenge in project atlas-checks by osmlab.
the class MapRouletteClient method upload.
private void upload(final Tuple<String, String> key) {
final Set<Task> batchList = this.batch.get(key);
if (batchList != null && batchList.size() > 0) {
try {
// retrieve the already created project and challenge
final Project project = this.projects.get(key.getFirst());
if (project == null) {
logger.warn("Failed to upload batch to MapRoulette, Project {} has not been created.", key.getFirst());
} else {
final Challenge challenge = this.challenges.get(project.getId()).get(key.getSecond());
if (challenge == null) {
logger.warn("Failed to upload batch to MapRoulette, Challenge {} has not been created.", key.getSecond());
} else {
this.connection.uploadBatchTasks(challenge.getId(), batchList);
batchList.clear();
}
}
} catch (final UnsupportedEncodingException e) {
logger.debug("Failed to upload batch to map roulette [{}]", this.connection.getConnectionInfo());
} catch (final URISyntaxException e) {
logger.debug("Failed to upload batch to map roulette", e);
}
}
}
use of org.openstreetmap.atlas.checks.maproulette.data.Challenge in project atlas-checks by osmlab.
the class ChallengeDeserializer method deserialize.
@Override
public Challenge deserialize(final JsonElement json, final Type typeOfT, final JsonDeserializationContext context) throws JsonParseException {
final JsonObject challengeObject = json.getAsJsonObject();
ChallengeDifficulty difficulty;
try {
difficulty = ChallengeDifficulty.valueOf(this.getStringValue(challengeObject, KEY_DIFFICULTY, ""));
} catch (final IllegalArgumentException e) {
logger.trace("Failed to read difficulty value from Challenge JSON, defaulting to EASY");
difficulty = ChallengeDifficulty.EASY;
}
ChallengePriority priority;
try {
priority = ChallengePriority.valueOf(this.getStringValue(challengeObject, Challenge.KEY_DEFAULT_PRIORITY, ""));
} catch (final IllegalArgumentException e) {
logger.trace("Failed to read priority value from Challenge JSON, defaulting to NONE");
priority = ChallengePriority.NONE;
}
return new Challenge(this.getStringValue(challengeObject, Challenge.KEY_NAME, ""), this.getStringValue(challengeObject, KEY_DESCRIPTION, ""), this.getStringValue(challengeObject, KEY_BLURB, ""), this.getStringValue(challengeObject, KEY_INSTRUCTION, ""), difficulty, priority, this.getValue(challengeObject, Challenge.KEY_HIGH_PRIORITY, null), this.getValue(challengeObject, Challenge.KEY_MEDIUM_PRIORITY, null), this.getValue(challengeObject, Challenge.KEY_LOW_PRIORITY, null), this.getStringValue(challengeObject, Challenge.KEY_TAGS, ""));
}
Aggregations