private static boolean has(SolrDocument doc, SolrName field) { return doc.containsKey(field.solrName()); }
/** * helper to retrieve one value from a field * @param doc to examine * @param field to check doc for * @return retrieved string or null */ private static String getOneValueFromField(SolrDocument doc, String field) { // sanity if (doc == null || field == null || field.isEmpty() || !doc.containsKey(field)) return null; Object o = doc.get(field); if (o == null) return null; // should not happen, but anyways if (o instanceof List) return (String) ((List)o).get(0); if (o instanceof String) return (String) o; logger.warn("Unknown type " + o.getClass() + " for field " + field); return null; }
private static Set<String> getStringSet(SolrDocument doc, SolrName field) { Set<String> set = new HashSet<String>(); if (doc.containsKey(field.solrName())) { for (Object val : doc.getFieldValues(field.solrName())) { set.add((String) val); } } return set; }
String id = e.getKey(); SolrDocument doc = e.getValue(); if (doc.containsKey(TREENODE_ROOT)) { treeNodeRemoved.put(id, doc); attachmentInTree.remove(doc);
/** * helper to convert main stuff of solr document to hit * @param doc * @return */ private SearchHit createHitFromDocument(SolrDocument doc) { SearchHit searchHit = new SearchHit(); searchHit.setId((String) doc.get(this.id)); searchHit.setClassName((String) doc.get(this.className)); searchHit.setTitle(getOneValueFromField(doc, this.title)); searchHit.setSubTitles(getOneValueFromField(doc, this.subTitles)); // get tags if (doc.containsKey(this.tag)) { Object o = doc.get(this.tag); if (o instanceof List) { List<String> l = (List<String>) o; String[] tags = new String[l.size()]; tags = l.toArray(tags); searchHit.setTagIds(tags); } else logger.warn("Unknown type " + o.getClass() + " for field " + this.tag); } // color Object colorLocal = doc.get("color"); if (colorLocal != null && !(colorLocal instanceof String)) colorLocal = colorLocal.toString(); searchHit.setColor(colorLocal!=null?new Integer((String)colorLocal):null); searchHit.setIconFileIdentifier(getOneValueFromField(doc, this.icon)); return searchHit; }
if (oldParentDoc.containsKey(TREENODE_ROOT)) { root = SolrUtil.getStringFieldValue(oldParentDoc,TREENODE_ROOT); Collection<String> p = SolrUtil.getStringFieldValues(oldParentDoc, TREENODE_PARENTS);
String id = e.getKey(); SolrDocument doc = e.getValue(); if (doc.containsKey(TREENODE_ROOT)) { treeNodeRemoved.put(id, doc); attachmentInTree.remove(doc);
if (oldParentDoc.containsKey(TREENODE_ROOT)) { root = (String) oldParentDoc.getFieldValue(TREENODE_ROOT); Collection p = oldParentDoc.getFieldValues(TREENODE_PARENTS);
if (doc != null) { if (doc.containsKey(TREENODE_DEPTH)) {
if (doc != null) { if (doc.containsKey(TREENODE_DEPTH)) {
if (doc != null) { if (doc.containsKey(TREENODE_DEPTH)) {
if (doc.containsKey(RodaConstants.INDEX_STATE)) {
@Override public Notification fromSolrDocument(SolrDocument doc, List<String> fieldsToReturn) throws GenericException { final Notification notification = super.fromSolrDocument(doc, fieldsToReturn); notification.setSubject(SolrUtils.objectToString(doc.get(RodaConstants.NOTIFICATION_SUBJECT), null)); notification.setBody(SolrUtils.objectToString(doc.get(RodaConstants.NOTIFICATION_BODY), null)); notification.setSentOn(SolrUtils.objectToDate(doc.get(RodaConstants.NOTIFICATION_SENT_ON))); notification.setFromUser(SolrUtils.objectToString(doc.get(RodaConstants.NOTIFICATION_FROM_USER), null)); notification.setRecipientUsers(SolrUtils.objectToListString(doc.get(RodaConstants.NOTIFICATION_RECIPIENT_USERS))); notification .setAcknowledgeToken(SolrUtils.objectToString(doc.get(RodaConstants.NOTIFICATION_ACKNOWLEDGE_TOKEN), null)); notification .setAcknowledged(SolrUtils.objectToBoolean(doc.get(RodaConstants.NOTIFICATION_IS_ACKNOWLEDGED), Boolean.FALSE)); if (fieldsToReturn.isEmpty() || fieldsToReturn.contains(RodaConstants.NOTIFICATION_ACKNOWLEDGED_USERS)) { notification.setAcknowledgedUsers( JsonUtils.getMapFromJson(SolrUtils.objectToString(doc.get(RodaConstants.NOTIFICATION_ACKNOWLEDGED_USERS), ""))); } if (doc.containsKey(RodaConstants.NOTIFICATION_STATE)) { String defaultState = Notification.NOTIFICATION_STATE.COMPLETED.toString(); notification.setState(Notification.NOTIFICATION_STATE .valueOf(SolrUtils.objectToString(doc.get(RodaConstants.NOTIFICATION_STATE), defaultState))); } return notification; }
LOG_ENTRY_STATE state = null; if (doc.containsKey(RodaConstants.LOG_STATE)) { state = LOG_ENTRY_STATE .valueOf(SolrUtils.objectToString(doc.get(RodaConstants.LOG_STATE), LOG_ENTRY_STATE.UNKNOWN.toString()));
job.setStartDate(SolrUtils.objectToDateWithMillis(doc.get(RodaConstants.JOB_START_DATE))); job.setEndDate(SolrUtils.objectToDateWithMillis(doc.get(RodaConstants.JOB_END_DATE))); if (doc.containsKey(RodaConstants.JOB_STATE)) { job.setState(JOB_STATE.valueOf(SolrUtils.objectToString(doc.get(RodaConstants.JOB_STATE), null))); jobStats.setOutcomeObjectsWithManualIntervention( SolrUtils.objectToInteger(doc.get(RodaConstants.JOB_OUTCOME_OBJECTS_WITH_MANUAL_INTERVENTION), 0)); if (doc.containsKey(RodaConstants.JOB_PLUGIN_TYPE)) { job.setPluginType(PluginType.valueOf(SolrUtils.objectToString(doc.get(RodaConstants.JOB_PLUGIN_TYPE), null)));
if (doc.containsKey(RodaConstants.TRANSFERRED_RESOURCE_PARENT_ID)) { parentId = SolrUtils.objectToString(doc.get(RodaConstants.TRANSFERRED_RESOURCE_PARENT_ID), null); parentUUID = SolrUtils.objectToString(doc.get(RodaConstants.TRANSFERRED_RESOURCE_PARENT_UUID), null);
if (koulutusDoc.containsKey(KAUSI_URI)) { perustieto.setKoulutuksenAlkamiskausiUri(IndexDataUtils.createKoodistoKoodi(KAUSI_URI, KAUSI_FI, KAUSI_SV, KAUSI_EN, koulutusDoc)); if (koulutusDoc.containsKey(VUOSI_KOODI)) { try { perustieto.setKoulutuksenAlkamisVuosi(new Integer((String) koulutusDoc.getFieldValue(VUOSI_KOODI)));
@Override public RiskIncidence fromSolrDocument(SolrDocument doc, List<String> fieldsToReturn) throws GenericException { final RiskIncidence incidence = super.fromSolrDocument(doc, fieldsToReturn); incidence.setAipId(SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_AIP_ID), null)); incidence .setRepresentationId(SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_REPRESENTATION_ID), null)); incidence.setFilePath(SolrUtils.objectToListString(doc.get(RodaConstants.RISK_INCIDENCE_FILE_PATH))); incidence.setFileId(SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_FILE_ID), null)); incidence.setObjectClass(SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_OBJECT_CLASS), null)); incidence.setRiskId(SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_RISK_ID), null)); incidence.setDescription(SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_DESCRIPTION), null)); if (doc.containsKey(RodaConstants.RISK_INCIDENCE_STATUS)) { incidence.setStatus(INCIDENCE_STATUS.valueOf(SolrUtils .objectToString(doc.get(RodaConstants.RISK_INCIDENCE_STATUS), INCIDENCE_STATUS.UNMITIGATED.toString()))); } if (doc.containsKey(RodaConstants.RISK_INCIDENCE_SEVERITY)) { incidence.setSeverity(SEVERITY_LEVEL.valueOf( SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_SEVERITY), SEVERITY_LEVEL.MODERATE.toString()))); } incidence.setDetectedOn(SolrUtils.objectToDate(doc.get(RodaConstants.RISK_INCIDENCE_DETECTED_ON))); incidence.setDetectedBy(SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_DETECTED_BY), null)); incidence.setMitigatedOn(SolrUtils.objectToDate(doc.get(RodaConstants.RISK_INCIDENCE_MITIGATED_ON))); incidence.setMitigatedBy(SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_MITIGATED_BY), null)); incidence.setMitigatedDescription( SolrUtils.objectToString(doc.get(RodaConstants.RISK_INCIDENCE_MITIGATED_DESCRIPTION), null)); return incidence; }
jobReport .setOutcomeObjectClass(SolrUtils.objectToString(doc.get(RodaConstants.JOB_REPORT_OUTCOME_OBJECT_CLASS), null)); if (doc.containsKey(RodaConstants.JOB_REPORT_OUTCOME_OBJECT_STATE)) { jobReport.setOutcomeObjectState(AIPState.valueOf(SolrUtils .objectToString(doc.get(RodaConstants.JOB_REPORT_OUTCOME_OBJECT_STATE), AIPState.getDefault().toString())));
risk.setPreMitigationImpact(SolrUtils.objectToInteger(doc.get(RodaConstants.RISK_PRE_MITIGATION_IMPACT), 0)); risk.setPreMitigationSeverity(SolrUtils.objectToInteger(doc.get(RodaConstants.RISK_PRE_MITIGATION_SEVERITY), 0)); if (doc.containsKey(RodaConstants.RISK_PRE_MITIGATION_SEVERITY_LEVEL)) { risk.setPreMitigationSeverityLevel(SolrUtils .objectToEnum(doc.get(RodaConstants.RISK_PRE_MITIGATION_SEVERITY_LEVEL), Risk.SEVERITY_LEVEL.class, null)); risk.setPostMitigationImpact(SolrUtils.objectToInteger(doc.get(RodaConstants.RISK_POST_MITIGATION_IMPACT), 0)); risk.setPostMitigationSeverity(SolrUtils.objectToInteger(doc.get(RodaConstants.RISK_POST_MITIGATION_SEVERITY), 0)); if (doc.containsKey(RodaConstants.RISK_POST_MITIGATION_SEVERITY_LEVEL)) { risk.setPostMitigationSeverityLevel(SolrUtils .objectToEnum(doc.get(RodaConstants.RISK_POST_MITIGATION_SEVERITY_LEVEL), Risk.SEVERITY_LEVEL.class, null));