@Override public Object retrieve(String field) { if (field == null) { return null; } else if (field.equals(MAPVALUE)) { return getMapValue(); } else { return super.retrieve(field); } }
@Transactional(readOnly=false) @Override public Object doWork(Session session, ServiceFactory sf) { MapAnnotation ma = new MapAnnotation(); ma.setNs(NAMESPACE); ma.setDescription(parseStream(stream)); ma.setMapValue(new ArrayList<NamedValue>()); ma.getMapValue().add(new NamedValue("from", from)); ma.getMapValue().add(new NamedValue("to", recipient)); ma = sf.getUpdateService().saveAndReturnObject(ma); log.info("Saved email: MapAnnotation:" + ma.getId()); return ma; }}); }
/** * Creates {@link Field} instances for {@link MapAnnotation} named-value * pair. * * @param document * @param opts * @param mapAnnotation */ private void handleMapAnnotation(final Document document, final LuceneOptions opts, MapAnnotation mapAnnotation) { List<NamedValue> nvs = mapAnnotation.getMapValue(); if (nvs != null && nvs.size() > 0) { for (NamedValue nv : nvs) { if (nv != null) { add(document, nv.getName(), nv.getValue(), opts); add(document, "has_key", nv.getName(), opts); add(document, "annotation", nv.getValue(), opts); add(document, "annotation", nv.getName(), opts); } } } }