/** * Get a metadatum element from one of the features. * * @param toFind the type of metadatum to get * @param lookIn the feature to get from, may be {@code null} * @return the metadatum specified in the feature, or {@code null} if it does not exist */ private FeatureMetadatum getMetadatumIfExists(String toFind, Feature lookIn) { return lookIn != null && lookIn.getMetadata() != null ? lookIn.getMetadata().get(toFind) : null; }
if (this.match != null && this.match.getMetadata() != null) { for (Map.Entry<String, ? extends FeatureMetadatum> entry : this.match.getMetadata().entrySet()) { this.matchedMetadata.put(entry.getKey(), new RestrictedFeatureMetadatumSimilarityView(entry.getValue(), getMetadatumIfExists(entry.getKey(), this.reference), this.access)); if (this.reference != null && this.reference.getMetadata() != null) { for (Map.Entry<String, ? extends FeatureMetadatum> entry : this.reference.getMetadata().entrySet()) { if (!this.matchedMetadata.containsKey(entry.getKey())) { this.matchedMetadata.put(entry.getKey(),
private JSONArray features(Patient patient) { JSONArray features = new JSONArray(); for (Feature patientFeature : patient.getFeatures()) { String featureId = patientFeature.getId(); if (featureId.isEmpty() || !this.hpoTerm.matcher(featureId).matches()) { this.logger.error("Patient feature parser: ignoring term with non-HPO id [{}]", featureId); continue; } JSONObject featureJson = new JSONObject(); featureJson.put(ApiConfiguration.JSON_FEATURE_ID, featureId); featureJson.put(ApiConfiguration.JSON_FEATURE_OBSERVED, observedStatusToJSONString(patientFeature)); Map<String, ? extends FeatureMetadatum> metadata = patientFeature.getMetadata(); FeatureMetadatum ageOfOnset = metadata.get(ApplicationConfiguration.FEATURE_METADATA_AGEOFONSET); if (ageOfOnset != null) { featureJson.put(ApiConfiguration.JSON_FEATURE_AGE_OF_ONSET, ageOfOnset.getId()); } features.put(featureJson); } return features; }
/** * Updates metadata for a {@code feature}. * * @param doc the {@link XWikiDocument} object for the patient * @param feature the {@link Feature} of interest * @param context the {@link XWikiContext} * @throws XWikiException if meta data cannot be updated */ private void updateMetaData( @Nonnull final XWikiDocument doc, @Nonnull final Feature feature, @Nonnull final XWikiContext context) throws XWikiException { @SuppressWarnings("unchecked") final Map<String, FeatureMetadatum> metadata = (Map<String, FeatureMetadatum>) feature.getMetadata(); if (!metadata.isEmpty() || !feature.getNotes().isEmpty()) { final BaseObject metaObject = doc.newXObject(FeatureMetadatum.CLASS_REFERENCE, context); metaObject.set(PhenoTipsFeature.META_PROPERTY_NAME, feature.getPropertyName(), context); metaObject.set(PhenoTipsFeature.META_PROPERTY_VALUE, feature.getValue(), context); metadata.forEach((type, metadatum) -> metaObject.set(type, metadatum.getId(), context)); metaObject.set("comments", feature.getNotes(), context); } }
private void updateMetaData(PatientData<Feature> features, XWikiDocument doc, XWikiContext context) throws XWikiException { doc.removeXObjects(FeatureMetadatum.CLASS_REFERENCE); Iterator<Feature> iterator = features.iterator(); while (iterator.hasNext()) { Feature feature = iterator.next(); @SuppressWarnings("unchecked") Map<String, FeatureMetadatum> metadataMap = (Map<String, FeatureMetadatum>) feature.getMetadata(); if (metadataMap.isEmpty() && feature.getNotes().isEmpty()) { continue; } BaseObject metaObject = doc.newXObject(FeatureMetadatum.CLASS_REFERENCE, context); metaObject.set(PhenoTipsFeature.META_PROPERTY_NAME, feature.getPropertyName(), context); metaObject.set(PhenoTipsFeature.META_PROPERTY_VALUE, feature.getValue(), context); for (String type : metadataMap.keySet()) { PhenoTipsFeatureMetadatum metadatum = (PhenoTipsFeatureMetadatum) metadataMap.get(type); metaObject.set(type, metadatum.getId(), context); } metaObject.set("comments", feature.getNotes(), context); } }
Collection<? extends FeatureMetadatum> featureMetadatum = feature.getMetadata().values(); Boolean metaPresent = !featureMetadatum.isEmpty(); int offset = 0;
section.addCell(new DataCell(feature.getId(), ++x, y, StyleOption.FEATURE_SEPARATOR)); if (present.contains("meta.name")) { Collection<? extends FeatureMetadatum> featureMetadatum = feature.getMetadata().values(); Boolean metaPresent = !featureMetadatum.isEmpty(); for (FeatureMetadatum meta : featureMetadatum) {