@Test public void testToNonTechnicalMetadataJson() { final JSONObject scheduling = loadJsonObject("metadata.json"); final JSONObject expected = loadJsonObject("metadata-expected.json"); final JSONObject actual = BulkUpdateUtil.toNonTechnicalMetadataJson(scheduling); assertThat(actual.toJSONString(), SameJSONAs.sameJSONAs(expected.toJSONString())); }
@SuppressWarnings("unchecked") public static JSONObject toNonTechnicalMetadataJson(final JSONObject scheduling) { final List<JSONObject> fields = new ArrayList<>(); if (scheduling.containsKey(SCHEDULING_AGENT_ID_KEY)) { final JSONObject locationJson = new JSONObject(); locationJson.put("id", "location"); locationJson.put("value", scheduling.get(SCHEDULING_AGENT_ID_KEY)); fields.add(locationJson); } if (scheduling.containsKey(SCHEDULING_START_KEY) && scheduling.containsKey(SCHEDULING_END_KEY)) { final JSONObject startDateJson = new JSONObject(); startDateJson.put("id", "startDate"); final String startDate = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)) .atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + ".000Z"; startDateJson.put("value", startDate); fields.add(startDateJson); final JSONObject durationJson = new JSONObject(); durationJson.put("id", "duration"); final Instant start = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)); final Instant end = Instant.parse((String) scheduling.get(SCHEDULING_END_KEY)); final InternalDuration duration = InternalDuration.of(start, end); durationJson.put("value", duration.toString()); fields.add(durationJson); } final JSONObject result = new JSONObject(); result.put("flavor", MediaPackageElements.EPISODE.toString()); result.put("title", CommonEventCatalogUIAdapter.EPISODE_TITLE); result.put("fields", fields); return result; }
BulkUpdateUtil { @SuppressWarnings("unchecked") public static JSONObject toNonTechnicalMetadataJson(final JSONObject scheduling) { final List<JSONObject> fields = new ArrayList<>(); if (scheduling.containsKey(SCHEDULING_AGENT_ID_KEY)) { final JSONObject locationJson = new JSONObject(); locationJson.put("id", "location"); locationJson.put("value", scheduling.get(SCHEDULING_AGENT_ID_KEY)); fields.add(locationJson); } if (scheduling.containsKey(SCHEDULING_START_KEY) && scheduling.containsKey(SCHEDULING_END_KEY)) { final JSONObject startDateJson = new JSONObject(); startDateJson.put("id", "startDate"); final String startDate = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)) .atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + ".000Z"; startDateJson.put("value", startDate); fields.add(startDateJson); final JSONObject durationJson = new JSONObject(); durationJson.put("id", "duration"); final Instant start = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)); final Instant end = Instant.parse((String) scheduling.get(SCHEDULING_END_KEY)); final InternalDuration duration = InternalDuration.of(start, end); durationJson.put("value", duration.toString()); fields.add(durationJson); } final JSONObject result = new JSONObject(); result.put("flavor", MediaPackageElements.EPISODE.toString()); result.put("title", CommonEventCatalogUIAdapter.EPISODE_TITLE); result.put("fields", fields); return result; } }
BulkUpdateUtil { @SuppressWarnings("unchecked") public static JSONObject toNonTechnicalMetadataJson(final JSONObject scheduling) { final List<JSONObject> fields = new ArrayList<>(); if (scheduling.containsKey(SCHEDULING_AGENT_ID_KEY)) { final JSONObject locationJson = new JSONObject(); locationJson.put("id", "location"); locationJson.put("value", scheduling.get(SCHEDULING_AGENT_ID_KEY)); fields.add(locationJson); } if (scheduling.containsKey(SCHEDULING_START_KEY) && scheduling.containsKey(SCHEDULING_END_KEY)) { final JSONObject startDateJson = new JSONObject(); startDateJson.put("id", "startDate"); final String startDate = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)) .atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + ".000Z"; startDateJson.put("value", startDate); fields.add(startDateJson); final JSONObject durationJson = new JSONObject(); durationJson.put("id", "duration"); final Instant start = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)); final Instant end = Instant.parse((String) scheduling.get(SCHEDULING_END_KEY)); final InternalDuration duration = InternalDuration.of(start, end); durationJson.put("value", duration.toString()); fields.add(durationJson); } final JSONObject result = new JSONObject(); result.put("flavor", MediaPackageElements.EPISODE.toString()); result.put("title", CommonEventCatalogUIAdapter.EPISODE_TITLE); result.put("fields", fields); return result; } private  BulkUpdateUtil(); }
BulkUpdateUtil { @SuppressWarnings("unchecked") public static JSONObject toNonTechnicalMetadataJson(final JSONObject scheduling) { final List<JSONObject> fields = new ArrayList<>(); if (scheduling.containsKey(SCHEDULING_AGENT_ID_KEY)) { final JSONObject locationJson = new JSONObject(); locationJson.put("id", "location"); locationJson.put("value", scheduling.get(SCHEDULING_AGENT_ID_KEY)); fields.add(locationJson); } if (scheduling.containsKey(SCHEDULING_START_KEY) && scheduling.containsKey(SCHEDULING_END_KEY)) { final JSONObject startDateJson = new JSONObject(); startDateJson.put("id", "startDate"); final String startDate = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)) .atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + ".000Z"; startDateJson.put("value", startDate); fields.add(startDateJson); final JSONObject durationJson = new JSONObject(); durationJson.put("id", "duration"); final Instant start = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)); final Instant end = Instant.parse((String) scheduling.get(SCHEDULING_END_KEY)); final InternalDuration duration = InternalDuration.of(start, end); durationJson.put("value", duration.toString()); fields.add(durationJson); } final JSONObject result = new JSONObject(); result.put("flavor", MediaPackageElements.EPISODE.toString()); result.put("title", CommonEventCatalogUIAdapter.EPISODE_TITLE); result.put("fields", fields); return result; } private  BulkUpdateUtil(); static Optional<Event> getEvent(
    final IndexService indexSvc,
    final AdminUISearchIndex index,
    final String id); @SuppressWarnings("unchecked") static JSONObject addSchedulingDates(final Event event, final JSONObject scheduling); @SuppressWarnings("unchecked") static JSONObject toNonTechnicalMetadataJson(final JSONObject scheduling); @SuppressWarnings("unchecked") static JSONObject mergeMetadataFields(final JSONObject first, final JSONObject second); }
BulkUpdateUtil { @SuppressWarnings("unchecked") public static JSONObject toNonTechnicalMetadataJson(final JSONObject scheduling) { final List<JSONObject> fields = new ArrayList<>(); if (scheduling.containsKey(SCHEDULING_AGENT_ID_KEY)) { final JSONObject locationJson = new JSONObject(); locationJson.put("id", "location"); locationJson.put("value", scheduling.get(SCHEDULING_AGENT_ID_KEY)); fields.add(locationJson); } if (scheduling.containsKey(SCHEDULING_START_KEY) && scheduling.containsKey(SCHEDULING_END_KEY)) { final JSONObject startDateJson = new JSONObject(); startDateJson.put("id", "startDate"); final String startDate = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)) .atOffset(ZoneOffset.UTC) .format(DateTimeFormatter.ISO_LOCAL_DATE_TIME) + ".000Z"; startDateJson.put("value", startDate); fields.add(startDateJson); final JSONObject durationJson = new JSONObject(); durationJson.put("id", "duration"); final Instant start = Instant.parse((String) scheduling.get(SCHEDULING_START_KEY)); final Instant end = Instant.parse((String) scheduling.get(SCHEDULING_END_KEY)); final InternalDuration duration = InternalDuration.of(start, end); durationJson.put("value", duration.toString()); fields.add(durationJson); } final JSONObject result = new JSONObject(); result.put("flavor", MediaPackageElements.EPISODE.toString()); result.put("title", CommonEventCatalogUIAdapter.EPISODE_TITLE); result.put("fields", fields); return result; } private  BulkUpdateUtil(); static Optional<Event> getEvent(
    final IndexService indexSvc,
    final AdminUISearchIndex index,
    final String id); @SuppressWarnings("unchecked") static JSONObject addSchedulingDates(final Event event, final JSONObject scheduling); @SuppressWarnings("unchecked") static JSONObject toNonTechnicalMetadataJson(final JSONObject scheduling); @SuppressWarnings("unchecked") static JSONObject mergeMetadataFields(final JSONObject first, final JSONObject second);  }