@Override public Map<String, String> attributes() { String data = getNullableField(IssueIndexDefinition.FIELD_ISSUE_ATTRIBUTES); if (data == null) { return Collections.emptyMap(); } else { return KeyValueFormat.parse(data); } }
private void initializeForOtherLeaf(CounterInitializationContext context) { Optional<Measure> measure = context.getMeasure(NCLOC_LANGUAGE_DISTRIBUTION_KEY); if (measure.isPresent()) { Map<String, Integer> parse = KeyValueFormat.parse( measure.get().getData(), newStringConverter(), newIntegerConverter()); for (Map.Entry<String, Integer> entry : parse.entrySet()) { multiset.add(entry.getKey(), entry.getValue()); } } }
public void validate(Measure<?> measure, InputFile inputFile) { Metric<?> metric = measure.getMetric(); if (!isLineMetrics(metric)) { return; } Map<Integer, Integer> m = KeyValueFormat.parseIntInt(measure.getData()); validatePositiveLine(m, inputFile.absolutePath()); validateMaxLine(m, inputFile); }
public void save(Activity activity) { ActivityDto dto = new ActivityDto() .setKey(Uuids.create()) .setAuthor(userSession.getLogin()) .setAction(activity.getAction()) .setMessage(activity.getMessage()) .setData(KeyValueFormat.format(activity.getData())) .setType(activity.getType().name()); dbClient.activityDao().insert(dto); indexer.index(); }
/** {@inheritDoc} */ public void decorate(Resource resource, DecoratorContext context) { if (ResourceUtils.isProject(resource)) { Collection<Measure> childMeasures = context.getChildrenMeasures(CodesizeMetrics.CODE_COUNTERS); if (!childMeasures.isEmpty()) { Measure projectMeasure = context.getMeasure(CodesizeMetrics.CODE_COUNTERS); final PropertiesBuilder<String, Integer> counters = new PropertiesBuilder<String, Integer>(CodesizeMetrics.CODE_COUNTERS); if (projectMeasure != null) { Map<String, Integer> map = KeyValueFormat.parseStringInt(projectMeasure.getData()); counters.addAll(map); } for (Measure childMeasure : childMeasures) { Map<String, Integer> childcounters = KeyValueFormat.parseStringInt(childMeasure.getData()); for (Entry<String, Integer> entry : childcounters.entrySet()) { String key = entry.getKey(); Integer value = entry.getValue(); if (counters.getProps().containsKey(key)) { counters.add(key, value + counters.getProps().get(key)); } else { counters.add(key, value); } } } if (projectMeasure != null) { projectMeasure.setData(counters.buildData()); } else { context.saveMeasure(counters.build()); } } } }