Example usage for java.time ZoneId of

List of usage examples for java.time ZoneId of

Introduction

In this page you can find the example usage for java.time ZoneId of.

Prototype

public static ZoneId of(String zoneId) 

Source Link

Document

Obtains an instance of ZoneId from an ID ensuring that the ID is valid and available for use.

Usage

From source file:com.streamsets.pipeline.stage.origin.tcp.TCPObjectToRecordHandler.java

private void evaluateElAndSendResponse(ELEval eval, ELVars vars, String expression, ChannelHandlerContext ctx,
        Charset charset, boolean recordLevel, String expressionDescription) {
    if (Strings.isNullOrEmpty(expression)) {
        return;/*  w w  w.  j  av  a  2 s .  c  om*/
    }
    if (lastRecord != null) {
        RecordEL.setRecordInContext(vars, lastRecord);
    }
    final Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone(ZoneId.of(timeZoneId)));
    TimeEL.setCalendarInContext(vars, calendar);
    TimeNowEL.setTimeNowInContext(vars, Date.from(ZonedDateTime.now().toInstant()));
    final String elResult;
    try {
        elResult = eval.eval(vars, expression, String.class);
        ctx.writeAndFlush(Unpooled.copiedBuffer(elResult, charset));
    } catch (ELEvalException exception) {
        if (LOG.isErrorEnabled()) {
            LOG.error(String.format("ELEvalException caught attempting to evaluate %s expression",
                    expressionDescription), exception);
        }

        if (recordLevel) {
            switch (context.getOnErrorRecord()) {
            case DISCARD:
                // do nothing
                break;
            case STOP_PIPELINE:
                if (LOG.isErrorEnabled()) {
                    LOG.error(String.format(
                            "ELEvalException caught when evaluating %s expression to send client response; failing pipeline %s"
                                    + " as per stage configuration: %s",
                            expressionDescription, context.getPipelineId(), exception.getMessage()), exception);
                }
                stopPipelineHandler.stopPipeline(context.getPipelineId(), exception);
                break;
            case TO_ERROR:
                Record errorRecord = lastRecord != null ? lastRecord : context.createRecord(generateRecordId());
                batchContext.toError(errorRecord, exception);
                break;
            }
        } else {
            context.reportError(Errors.TCP_35, expressionDescription, exception.getMessage(), exception);
        }
    }
}

From source file:objective.taskboard.followup.FollowUpDataRepositoryByFileTest.java

@Test
public void whenHasDataHistoryWithCfdAndPassesZoneId_GetShouldRecalculateAnalyticsAndSynthetics() {
    // given// w  w w .ja  v  a 2s  . c o  m
    createProjectZipV1(PROJECT_TEST);
    ZoneId saoPauloTZ = ZoneId.of("America/Sao_Paulo"); // -03:00, no conversion
    ZoneId torontoTZ = ZoneId.of("America/Toronto"); // -04:00, changes date and hours
    ZoneId sydneyTZ = ZoneId.of("Australia/Sydney"); // +10:00, same day, different hours

    // when
    FollowUpData dataSaoPaulo = subject.get(YESTERDAY, saoPauloTZ, PROJECT_TEST);
    FollowUpData dataToronto = subject.get(YESTERDAY, torontoTZ, PROJECT_TEST);
    FollowUpData dataSydney = subject.get(YESTERDAY, sydneyTZ, PROJECT_TEST);

    // then
    List<ZonedDateTime> saoPauloAnalyticsDates = dataSaoPaulo.analyticsTransitionsDsList.get(0).rows
            .get(0).transitionsDates;
    assertEquals(saoPauloAnalyticsDates.get(0),
            DateTimeUtils.parseDateTime("2017-09-27", "00:00:00", saoPauloTZ));
    assertEquals(saoPauloAnalyticsDates.get(1),
            DateTimeUtils.parseDateTime("2017-09-26", "00:00:00", saoPauloTZ));
    assertEquals(saoPauloAnalyticsDates.get(2),
            DateTimeUtils.parseDateTime("2017-09-25", "00:00:00", saoPauloTZ));

    List<ZonedDateTime> torontoAnalyticsDates = dataToronto.analyticsTransitionsDsList.get(0).rows
            .get(0).transitionsDates;
    assertEquals(torontoAnalyticsDates.get(0),
            DateTimeUtils.parseDateTime("2017-09-26", "23:00:00", torontoTZ));
    assertEquals(torontoAnalyticsDates.get(1),
            DateTimeUtils.parseDateTime("2017-09-25", "23:00:00", torontoTZ));
    assertEquals(torontoAnalyticsDates.get(2),
            DateTimeUtils.parseDateTime("2017-09-24", "23:00:00", torontoTZ));

    List<ZonedDateTime> sydneyAnalyticsDates = dataSydney.analyticsTransitionsDsList.get(0).rows
            .get(0).transitionsDates;
    assertEquals(sydneyAnalyticsDates.get(0), DateTimeUtils.parseDateTime("2017-09-27", "13:00:00", sydneyTZ));
    assertEquals(sydneyAnalyticsDates.get(1), DateTimeUtils.parseDateTime("2017-09-26", "13:00:00", sydneyTZ));
    assertEquals(sydneyAnalyticsDates.get(2), DateTimeUtils.parseDateTime("2017-09-25", "13:00:00", sydneyTZ));

    List<SyntheticTransitionsDataRow> saoPauloSyntheticRows = dataSaoPaulo.syntheticsTransitionsDsList
            .get(0).rows;
    assertEquals(saoPauloSyntheticRows.get(0).date,
            DateTimeUtils.parseDateTime("2017-09-25", "00:00:00", saoPauloTZ));
    assertEquals(saoPauloSyntheticRows.get(1).date,
            DateTimeUtils.parseDateTime("2017-09-25", "00:00:00", saoPauloTZ));
    assertEquals(saoPauloSyntheticRows.get(2).date,
            DateTimeUtils.parseDateTime("2017-09-26", "00:00:00", saoPauloTZ));
    assertEquals(saoPauloSyntheticRows.get(3).date,
            DateTimeUtils.parseDateTime("2017-09-26", "00:00:00", saoPauloTZ));
    assertEquals(saoPauloSyntheticRows.get(4).date,
            DateTimeUtils.parseDateTime("2017-09-27", "00:00:00", saoPauloTZ));
    assertEquals(saoPauloSyntheticRows.get(5).date,
            DateTimeUtils.parseDateTime("2017-09-27", "00:00:00", saoPauloTZ));

    List<SyntheticTransitionsDataRow> torontoSyntheticRows = dataToronto.syntheticsTransitionsDsList
            .get(0).rows;
    assertEquals(torontoSyntheticRows.get(0).date,
            DateTimeUtils.parseDateTime("2017-09-24", "00:00:00", torontoTZ));
    assertEquals(torontoSyntheticRows.get(1).date,
            DateTimeUtils.parseDateTime("2017-09-24", "00:00:00", torontoTZ));
    assertEquals(torontoSyntheticRows.get(2).date,
            DateTimeUtils.parseDateTime("2017-09-25", "00:00:00", torontoTZ));
    assertEquals(torontoSyntheticRows.get(3).date,
            DateTimeUtils.parseDateTime("2017-09-25", "00:00:00", torontoTZ));
    assertEquals(torontoSyntheticRows.get(4).date,
            DateTimeUtils.parseDateTime("2017-09-26", "00:00:00", torontoTZ));
    assertEquals(torontoSyntheticRows.get(5).date,
            DateTimeUtils.parseDateTime("2017-09-26", "00:00:00", torontoTZ));

    List<SyntheticTransitionsDataRow> sydneySyntheticsRows = dataSydney.syntheticsTransitionsDsList.get(0).rows;
    assertEquals(sydneySyntheticsRows.get(0).date,
            DateTimeUtils.parseDateTime("2017-09-25", "00:00:00", sydneyTZ));
    assertEquals(sydneySyntheticsRows.get(1).date,
            DateTimeUtils.parseDateTime("2017-09-25", "00:00:00", sydneyTZ));
    assertEquals(sydneySyntheticsRows.get(2).date,
            DateTimeUtils.parseDateTime("2017-09-26", "00:00:00", sydneyTZ));
    assertEquals(sydneySyntheticsRows.get(3).date,
            DateTimeUtils.parseDateTime("2017-09-26", "00:00:00", sydneyTZ));
    assertEquals(sydneySyntheticsRows.get(4).date,
            DateTimeUtils.parseDateTime("2017-09-27", "00:00:00", sydneyTZ));
    assertEquals(sydneySyntheticsRows.get(5).date,
            DateTimeUtils.parseDateTime("2017-09-27", "00:00:00", sydneyTZ));
}

From source file:org.silverpeas.core.calendar.notification.CalendarContributionReminderUserNotificationTest.java

@Test
public void durationReminderOf0HourAndWithAnotherUserZoneIdOnCalendarContributionShouldWork() throws Exception {
    receiver.getUserPreferences().setZoneId(ZoneId.of("Asia/Muscat"));
    final DurationReminder durationReminder = initReminderBuilder(setupSimpleEventOnAllDay()).triggerBefore(0,
            TimeUnit.HOUR, "");
    triggerDateTime(durationReminder);/*from   w  w  w .j av a 2 s  . co  m*/
    final Map<String, String> titles = computeNotificationTitles(durationReminder);
    assertThat(titles.get(DE), is("Reminder about the event super test - 21.02.2018 (UTC)"));
    assertThat(titles.get(EN), is("Reminder about the event super test - 02/21/2018 (UTC)"));
    assertThat(titles.get(FR), is("Rappel sur l'vnement super test - 21/02/2018 (UTC)"));
    final Map<String, String> contents = computeNotificationContents(durationReminder);
    assertThat(contents.get(DE), is("REMINDER: The event <b>super test</b> will be on 21.02.2018 (UTC)."));
    assertThat(contents.get(EN), is("REMINDER: The event <b>super test</b> will be on 02/21/2018 (UTC)."));
    assertThat(contents.get(FR), is("RAPPEL : L'vnement <b>super test</b> aura lieu le 21/02/2018 (UTC)."));
}

From source file:io.stallion.settings.Settings.java

public void assignDefaults() {
    if (getLocalMode() == null) {
        if (empty(System.getenv().getOrDefault("STALLION_DEPLOY_TIME", ""))) {
            setLocalMode(true);/* ww w  . j  av  a2  s .co  m*/
        } else {
            setLocalMode(false);
        }
    }

    if (bundleDebug == null) {
        bundleDebug = getLocalMode();
    }

    if (getDebug() == null) {
        if (getEnv().equals("prod") && !getLocalMode()) {
            setDebug(false);
        } else {
            setDebug(true);
        }
    }

    if (timeZone == null) {
        timeZone = ZoneId.systemDefault().toString();
    }
    if (timeZoneId == null) {
        timeZoneId = ZoneId.of(timeZone);
    }

    if (logFile == null) {
        String nowString = DateUtils.formatNow("yyyy-MM-dd-HHmmss");
        String base = "";
        try {
            if (!empty(siteUrl)) {
                base = new URL(siteUrl.replace(":{port}", "")).getHost();
            }
        } catch (IOException e) {
            Log.exception(e, "Error parsing siteUrl " + siteUrl);
        }
        logFile = "/tmp/log/stallion/" + base + "-" + nowString + "-"
                + StringUtils.strip(GeneralUtils.slugify(targetFolder), "-") + ".log";
    }
    if (logToConsole == null) {
        logToConsole = getLocalMode();
    }
    if (logToFile == null) {
        logToFile = !logToConsole;
    }

    if (getEmailErrors() == null) {
        if ((getEnv().equals("prod") || getEnv().equals("qa")) && !getLocalMode()) {
            setEmailErrors(true);
        } else {
            setEmailErrors(false);
        }
    }

    if (getStrictnessLevel() == null) {
        if (getEnv().equals("prod") && !getLocalMode()) {
            setStrictnessLevel(StrictnessLevel.LAX);
        } else {
            setStrictnessLevel(StrictnessLevel.STRICT);
        }
    }

    if (!empty(secondaryDomains)) {
        secondaryDomainByDomain = map();
        for (SecondaryDomain d : secondaryDomains) {
            secondaryDomainByDomain.put(d.getDomain(), d);
        }
    }

    if (!StringUtils.isEmpty(getDataDirectory())) {
        if (!getDataDirectory().startsWith("/")) {
            setDataDirectory(targetFolder + "/" + getDataDirectory());
        }
    } else {
        setDataDirectory(targetFolder + "/app-data");
    }
    if (getDataDirectory().endsWith("/")) {
        setDataDirectory(getDataDirectory().substring(0, getDataDirectory().length() - 1));
    }

    if (getRewrites() != null) {
        // THe Toml library has a bug whereby if a map key is quoted, it keeps the
        // quotes as part of the key, rather than using the String inside the quotes
        Set<String> keys = new HashSet<>(getRewrites().keySet());
        for (String key : keys) {
            if (key.startsWith("\"") && key.endsWith("\"")) {
                getRewrites().put(key.substring(1, key.length() - 1), getRewrites().get(key));
            }
        }
    }

    if (getRedirects() != null) {
        // THe Toml library has a bug whereby if a map key is quoted, it keeps the
        // quotes as part of the key, rather than using the String inside the quotes
        Set<String> keys = new HashSet<>(getRedirects().keySet());
        for (String key : keys) {
            if (key.startsWith("\"") && key.endsWith("\"")) {
                getRedirects().put(key.substring(1, key.length() - 1), getRedirects().get(key));
            }
        }
    }

    if (getRewritePatterns() != null && getRewritePatterns().size() > 0) {
        if (rewriteCompiledPatterns == null) {
            rewriteCompiledPatterns = new ArrayList();
        }
        for (String[] entry : getRewritePatterns()) {
            if (entry.length != 2) {
                Log.warn("Invalid rewritePatterns entry, size should be 2 but is {0} {1}", entry.length, entry);
            }
            Pattern pattern = Pattern.compile(entry[0]);
            Map.Entry<Pattern, String> kv = new AbstractMap.SimpleEntry<Pattern, String>(pattern, entry[1]);
            getRewriteCompiledPatterns().add(kv);
        }
    }

    if (getEmail() != null) {
        // By default, in debug mode, we do not want to send real emails to people
        if (getEmail().getRestrictOutboundEmails() == null) {
            getEmail().setRestrictOutboundEmails(getDebug());
        }
        if (getEmail().getOutboundEmailTestAddress() == null) {
            if (getEmail().getAdminEmails() != null && getEmail().getAdminEmails().size() > 0) {
                getEmail().setOutboundEmailTestAddress(getEmail().getAdminEmails().get(0));
            }
        }
        if (!empty(getEmail().getAllowedTestingOutboundEmailPatterns())) {
            if (getEmail().getAllowedTestingOutboundEmailCompiledPatterns() == null) {
                getEmail().setAllowedTestingOutboundEmailCompiledPatterns(new ArrayList<>());
            }
            for (String emailPattern : getEmail().getAllowedTestingOutboundEmailPatterns()) {
                getEmail().getAllowedTestingOutboundEmailCompiledPatterns().add(Pattern.compile(emailPattern));
            }
        }
    }

    if (getSecrets() == null) {
        setSecrets(new SecretsSettings());
    }

    if (new File(targetFolder + "/pages").isDirectory()) {
        if (folders == null) {
            folders = new ArrayList<>();
        }
        folders.add(new ContentFolder().setPath(targetFolder + "/pages").setType("markdown")
                .setItemTemplate(getPageTemplate()));
    }

    if (userUploads != null && empty(userUploads.getUploadsDirectory())) {
        userUploads.setUploadsDirectory(getDataDirectory() + "/st-user-file-uploads");
    }

}

From source file:org.openhab.binding.airvisualnode.internal.handler.AirVisualNodeHandler.java

private State getChannelState(String channelId, NodeData nodeData) {
    State state = UnDefType.UNDEF;

    // Handle system channel IDs separately, because 'switch/case' expressions must be constant expressions
    if (CHANNEL_BATTERY_LEVEL.equals(channelId)) {
        state = new DecimalType(BigDecimal.valueOf(nodeData.getStatus().getBattery()).longValue());
    } else if (CHANNEL_WIFI_STRENGTH.equals(channelId)) {
        state = new DecimalType(
                BigDecimal.valueOf(Math.max(0, nodeData.getStatus().getWifiStrength() - 1)).longValue());
    } else {//from  w  w  w  .j  a  v  a2  s. co m
        // Handle binding-specific channel IDs
        switch (channelId) {
        case CHANNEL_CO2:
            state = new QuantityType<>(nodeData.getMeasurements().getCo2Ppm(), PARTS_PER_MILLION);
            break;
        case CHANNEL_HUMIDITY:
            state = new QuantityType<>(nodeData.getMeasurements().getHumidityRH(), PERCENT);
            break;
        case CHANNEL_AQI_US:
            state = new QuantityType<>(nodeData.getMeasurements().getPm25AQIUS(), ONE);
            break;
        case CHANNEL_PM_25:
            // PM2.5 is in ug/m3
            state = new QuantityType<>(nodeData.getMeasurements().getPm25Ugm3(),
                    MICRO(GRAM).divide(CUBIC_METRE));
            break;
        case CHANNEL_TEMP_CELSIUS:
            state = new QuantityType<>(nodeData.getMeasurements().getTemperatureC(), CELSIUS);
            break;
        case CHANNEL_TIMESTAMP:
            // It seem the Node timestamp is Unix timestamp converted from UTC time plus timezone offset.
            // Not sure about DST though, but it's best guess at now
            Instant instant = Instant.ofEpochMilli(nodeData.getStatus().getDatetime() * 1000L);
            ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(instant, ZoneId.of("UTC"));
            ZoneId zoneId = ZoneId.of(nodeData.getSettings().getTimezone());
            ZoneRules zoneRules = zoneId.getRules();
            zonedDateTime.minus(Duration.ofSeconds(zoneRules.getOffset(instant).getTotalSeconds()));
            if (zoneRules.isDaylightSavings(instant)) {
                zonedDateTime.minus(Duration.ofSeconds(zoneRules.getDaylightSavings(instant).getSeconds()));
            }
            state = new DateTimeType(zonedDateTime);
            break;
        case CHANNEL_USED_MEMORY:
            state = new DecimalType(BigDecimal.valueOf(nodeData.getStatus().getUsedMemory()).longValue());
            break;
        }
    }

    return state;
}

From source file:org.codelibs.fess.app.web.admin.backup.AdminBackupAction.java

private static StringBuilder appendJson(final String field, final Object value, final StringBuilder buf) {
    buf.append('"').append(StringEscapeUtils.escapeJson(field)).append('"').append(':');
    if (value == null) {
        buf.append("null");
    } else if (value instanceof LocalDateTime) {
        final String format = ((LocalDateTime) value).atZone(ZoneId.systemDefault())
                .withZoneSameInstant(ZoneId.of("UTC")).format(ISO_8601_FORMATTER);
        buf.append('"').append(StringEscapeUtils.escapeJson(format)).append('"');
    } else if (value instanceof String[]) {
        final String json = Arrays.stream((String[]) value)
                .map(s -> "\"" + StringEscapeUtils.escapeJson(s) + "\"").collect(Collectors.joining(","));
        buf.append('[').append(json).append(']');
    } else if (value instanceof List) {
        final String json = ((List<?>) value).stream()
                .map(s -> "\"" + StringEscapeUtils.escapeJson(s.toString()) + "\"")
                .collect(Collectors.joining(","));
        buf.append('[').append(json).append(']');
    } else if (value instanceof Map) {
        buf.append('{');
        final String json = ((Map<?, ?>) value).entrySet().stream().map(e -> {
            final StringBuilder tempBuf = new StringBuilder();
            appendJson(e.getKey().toString(), e.getValue(), tempBuf);
            return tempBuf.toString();
        }).collect(Collectors.joining(","));
        buf.append(json);//from  w  w  w  . j av  a2 s . com
        buf.append('}');
    } else if (value instanceof Long || value instanceof Integer) {
        buf.append(((Number) value).longValue());
    } else if (value instanceof Number) {
        buf.append(((Number) value).doubleValue());
    } else {
        buf.append('"').append(StringEscapeUtils.escapeJson(value.toString())).append('"');
    }
    return buf;
}

From source file:org.apache.james.mailbox.elasticsearch.json.MessageToElasticSearchJsonTest.java

@Test
public void recursiveEmailShouldBeWellConvertedToJson() throws IOException {
    MessageToElasticSearchJson messageToElasticSearchJson = new MessageToElasticSearchJson(
            new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES);
    MailboxMessage recursiveMail = new SimpleMailboxMessage(MESSAGE_ID, date, SIZE, BODY_START_OCTET,
            new SharedByteArrayInputStream(
                    IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("eml/recursiveMail.eml"))),
            new FlagsBuilder().add(Flags.Flag.DELETED, Flags.Flag.SEEN).add("debian", "security").build(),
            propertyBuilder, MAILBOX_ID);
    recursiveMail.setModSeq(MOD_SEQ);//from w  w  w.j a v a  2s.  c o m
    recursiveMail.setUid(UID);
    assertThatJson(messageToElasticSearchJson.convertToJson(recursiveMail,
            ImmutableList.of(new MockMailboxSession("username").getUser()))).when(IGNORING_ARRAY_ORDER)
                    .when(IGNORING_VALUES)
                    .isEqualTo(IOUtils.toString(ClassLoader.getSystemResource("eml/recursiveMail.json")));
}

From source file:it.tidalwave.northernwind.frontend.ui.component.sitemap.DefaultSitemapViewController.java

/*******************************************************************************************************************
 *
 *
 ******************************************************************************************************************/
@Nonnull/*  w  ww.j  ava2 s  . c o m*/
private ZonedDateTime getSiteNodeDateTime(final @Nonnull ResourceProperties properties) {
    try {
        final String string = properties.getProperty(Properties.PROPERTY_LATEST_MODIFICATION_DATE);
        return ZonedDateTime.parse(string, DateTimeFormatter.ISO_DATE_TIME);
    } catch (NotFoundException e) {
    } catch (IOException e) {
        log.warn("", e);
    }

    return Instant.ofEpochMilli(0).atZone(ZoneId.of("GMT"));
}

From source file:com.amazonaws.services.kinesis.io.ObjectExtractor.java

/**
 * {@inheritDoc}//from  w  w w . j  av a 2  s . c o  m
 */
@Override
public List<AggregateData> getData(InputEvent event) throws SerializationException {
    if (!validated) {
        try {
            validate();
        } catch (Exception e) {
            throw new SerializationException(e);
        }
    }

    try {
        List<AggregateData> data = new ArrayList<>();

        Object o = serialiser.toClass(event);

        // get the value of the reflected labels
        LabelSet labels = new LabelSet();
        for (String key : this.aggregateLabelMethods) {
            labels.put(key, aggregateLabelMethodMap.get(key).invoke(o).toString());
        }

        // get the unique ID value from the object
        String uniqueId = null;
        if (this.uniqueIdMethodName != null) {
            switch (this.uniqueIdMethodName) {
            case StreamAggregator.REF_PARTITION_KEY:
                uniqueId = event.getPartitionKey();
                break;
            case StreamAggregator.REF_SEQUENCE:
                uniqueId = event.getSequenceNumber();
                break;
            default:
                Object id = uniqueIdMethod.invoke(o);
                if (id != null) {
                    uniqueId = id.toString();
                }
                break;
            }
        }

        // get the date value from the object
        if (this.dateMethod != null) {
            eventDate = dateMethod.invoke(o);

            if (eventDate == null) {
                dateValue = OffsetDateTime.now(ZoneId.of("UTC"));
            } else {
                if (eventDate instanceof Date) {
                    dateValue = OffsetDateTime.ofInstant(((Date) eventDate).toInstant(), ZoneId.of("UTC"));
                } else if (eventDate instanceof Long) {
                    dateValue = OffsetDateTime.ofInstant(Instant.ofEpochMilli((Long) eventDate),
                            ZoneId.of("UTC"));
                } else {
                    throw new Exception(String.format("Cannot use data type %s for date value on event",
                            eventDate.getClass().getSimpleName()));
                }
            }
        }

        // extract all summed values from the serialised object
        if (this.aggregatorType.equals(AggregatorType.SUM)) {
            // lift out the aggregated method value
            for (String s : this.sumValueMap.keySet()) {
                summaryValue = this.sumValueMap.get(s).invoke(o);

                if (summaryValue != null) {
                    if (summaryValue instanceof Double) {
                        sumUpdates.put(s, (Double) summaryValue);
                    } else if (summaryValue instanceof Long) {
                        sumUpdates.put(s, ((Long) summaryValue).doubleValue());
                    } else if (summaryValue instanceof Integer) {
                        sumUpdates.put(s, ((Integer) summaryValue).doubleValue());
                    } else {
                        String msg = String.format("Unable to access  Summary %s due to NumberFormatException",
                                s);
                        LOG.error(msg);
                        throw new SerializationException(msg);
                    }
                }
            }
        }

        data.add(new AggregateData(uniqueId, labels, dateValue, sumUpdates));

        return data;
    } catch (Exception e) {
        throw new SerializationException(e);
    }
}

From source file:eu.fthevenet.binjr.sources.jrds.adapters.JrdsDataAdapter.java

@Override
public void loadParams(Map<String, String> params) throws DataAdapterException {
    if (params == null) {
        throw new InvalidAdapterParameterException(
                "Could not find parameter list for adapter " + getSourceName());
    }/*from w  ww.  j  a v  a 2  s. co  m*/
    super.loadParams(params);
    encoding = validateParameterNullity(params, ENCODING_PARAM_NAME);
    zoneId = validateParameter(params, ZONE_ID_PARAM_NAME, s -> {
        if (s == null) {
            throw new InvalidAdapterParameterException(
                    "Parameter " + ZONE_ID_PARAM_NAME + " is missing in adapter " + getSourceName());
        }
        return ZoneId.of(s);
    });
    treeViewTab = validateParameter(params, TREE_VIEW_TAB_PARAM_NAME,
            s -> s == null ? JrdsTreeViewTab.valueOf(params.get(TREE_VIEW_TAB_PARAM_NAME))
                    : JrdsTreeViewTab.HOSTS_TAB);
    this.filter = params.get(JRDS_FILTER);
}