本文整理汇总了Java中org.hl7.fhir.instance.model.AtomEntry类的典型用法代码示例。如果您正苦于以下问题:Java AtomEntry类的具体用法?Java AtomEntry怎么用?Java AtomEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AtomEntry类属于org.hl7.fhir.instance.model包,在下文中一共展示了AtomEntry类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: composeFeed
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
private void composeFeed(AtomFeed feed) throws Exception {
xml.open(ATOM_NS, "feed");
if (feed.getTitle() != null)
xml.element(ATOM_NS, "title", feed.getTitle());
if (feed.getId() != null)
xml.element(ATOM_NS, "id", feed.getId());
for (String n : feed.getLinks().keySet()) {
xml.attribute("href", feed.getLinks().get(n));
xml.attribute("rel", n);
xml.element(ATOM_NS, "link", null);
}
if (feed.getUpdated() != null)
xml.element(ATOM_NS, "updated", dateToXml(feed.getUpdated()));
if (feed.getAuthorName() != null || feed.getAuthorUri() != null) {
xml.open(ATOM_NS, "author");
if (feed.getAuthorName() != null)
xml.element(ATOM_NS, "name", feed.getAuthorName());
if (feed.getAuthorUri() != null)
xml.element(ATOM_NS, "uri", feed.getAuthorUri());
xml.close(ATOM_NS, "author");
}
for (AtomEntry e : feed.getEntryList())
composeEntry(e);
xml.close(ATOM_NS, "feed");
}
示例2: makeFeedWithNarratives
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
/**
*
* @param result
* @param manager
* @return
* @throws MapperException
*/
private AtomFeed makeFeedWithNarratives(EObject result, FHIRSearchManager manager) throws MapperException
{
// convert the result into an instance of the FHIR reference model
EPackage classModel = getMappedStructure(serverName, resourceName).getClassModelRoot();
EcoreReferenceBridge bridge = new EcoreReferenceBridge(classModel);
AtomFeed feed = bridge.getReferenceModelFeed(result);
feed.setTitle(serverName);
// set the narratives of all the resources in the feed
for (Iterator<AtomEntry<?>> it = feed.getEntryList().iterator();it.hasNext();)
{
AtomEntry<?> entry = it.next();
Resource resource = entry.getResource();
Narrative narrative = manager.getNarrative(entry.getId());
if (narrative != null) resource.setText(narrative);
}
return feed;
}
示例3: buildBundle
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
public static AtomFeed buildBundle(List<Patient> patientList, String fhirBase) {
DateAndTime now = new DateAndTime(new Date());
AtomFeed feed = new AtomFeed();
feed.setTitle("Patient matches");
feed.setId("urn:uuid:"+CDAUUID.generateUUIDString());
feed.setTotalResults(patientList.size());
feed.setUpdated(now);
feed.setAuthorName("PDS");
List<AtomEntry<? extends Resource>> list = feed.getEntryList();
for (Patient patient : patientList) {
String nhsNo = patient.getIdentifier().get(0).getValueSimple();
AtomEntry entry = new AtomEntry();
entry.setResource(patient);
entry.setTitle("PDS Patient match: " + nhsNo);
entry.setId(fhirBase + "Patient/" + nhsNo);
// FHIR requires an updated date for the resource - we don't get this back from PDS simple trace...
// TODO: Establish what we should use for the last updated date
entry.setUpdated(now);
// We also don't get an author back from a simple trace...
// TODO: Establish what we should use for the author
entry.setPublished(now);
entry.setAuthorName("PDS");
list.add(entry);
}
return feed;
}
示例4: parseEntry
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends Resource> AtomEntry<T> parseEntry(JsonObject json) throws Exception {
AtomEntry<T> res = new AtomEntry<T>();
if (json.has("title") && !json.get("title").isJsonNull())
res.setTitle(json.get("title").getAsString());
if (json.has("id") && !json.get("id").isJsonNull())
res.setId(json.get("id").getAsString());
if (json.has("updated") && !json.get("updated").isJsonNull())
res.setUpdated(new DateAndTime(json.get("updated").getAsString()));
if (json.has("published") && !json.get("published").isJsonNull())
res.setPublished(new DateAndTime(json.get("published").getAsString()));
if (json.has("link") && !json.get("link").isJsonNull()) {
JsonArray array = json.getAsJsonArray("link");
for (int i = 0; i < array.size(); i++) {
parseLink(res.getLinks(), array.get(i).getAsJsonObject());
}
}
if (json.has("author") && !json.get("author").isJsonNull()) {
JsonObject author = json.getAsJsonArray("author").get(0).getAsJsonObject();
if (author.has("name") && !author.get("name").isJsonNull())
res.setAuthorName(author.get("name").getAsString());
if (author.has("uri") && !author.get("uri").isJsonNull())
res.setAuthorUri(author.get("uri").getAsString());
}
if (json.has("category") && !json.get("category").isJsonNull()) {
for (JsonElement t : json.getAsJsonArray("category")) {
JsonObject cat = t.getAsJsonObject();
if (cat.has("term") && cat.has("scheme") && !cat.get("term").isJsonNull() && !cat.get("scheme").isJsonNull())
res.getTags().add(new AtomCategory(cat.get("scheme").getAsString(), cat.get("term").getAsString(), cat.has("label") ? cat.get("label").getAsString() : null));
}
}
if (json.has("summary") && !json.get("summary").isJsonNull())
res.setSummary(new XhtmlParser().parse(json.get("summary").getAsString(), "div").getChildNodes().get(0));
if (json.has("content") && !json.get("content").isJsonNull())
res.setResource((T)new JsonParser().parse(json.getAsJsonObject("content")));//TODO Architecture needs to be refactor to prevent this unsafe cast and better support generics
return res;
}
示例5: parseEntry
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
private AtomEntry parseEntry(JSONObject json) throws Exception {
AtomEntry res = new AtomEntry();
if (json.has("title"))
res.setTitle(json.getString("title"));
if (json.has("id"))
res.setId(json.getString("id"));
if (json.has("updated"))
res.setUpdated(xmlToDate(json.getString("updated")));
if (json.has("published"))
res.setPublished(xmlToDate(json.getString("published")));
if (json.has("links")) {
JSONArray array = json.getJSONArray("links");
for (int i = 0; i < array.length(); i++) {
parseLink(res.getLinks(), array.getJSONObject(i));
}
}
if (json.has("authors")) {
JSONObject author = json.getJSONArray("authors").getJSONObject(0);
if (author.has("name"))
res.setAuthorName(author.getString("name"));
if (author.has("uri"))
res.setAuthorUri(author.getString("uri"));
}
if (json.has("categories")) {
JSONObject cat = json.getJSONArray("categories").getJSONObject(0);
if (cat.has("term") && cat.has("scheme") && cat.getString("scheme").equals("http://hl7.org/fhir/tag"))
res.getTags().put(cat.getString("term"), cat.has("label") ? cat.getString("label") : null);
}
if (json.has("summary"))
res.setSummary(new XhtmlParser().parse(json.getString("summary"), "div").getChildNodes().get(0));
if (json.has("content"))
res.setResource(new JsonParser().parse(json.getJSONObject("content")));
return res;
}
示例6: addResource
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
/**
* add any Resource to an atom feed
* @param feed
* @param r
* @param title
* @param id
* @return
*/
private String addResource(AtomFeed feed, Resource r, String title, String id) {
AtomEntry e = new AtomEntry();
e.setUpdated(new DateAndTime(Calendar.getInstance()));
//e.setUpdated(Calendar.getInstance());
e.setResource(r);
e.setTitle(title);
e.setId(id);
// e.setCategory(r.getResourceType().toString()); // removed as method no longer recognised
feed.getEntryList().add(e);
return id;
}
示例7: mergeFeeds
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
/**
* merge the entries in a set of AtomFeeds
* @param feeds
* @return
*/
private AtomFeed mergeFeeds(Vector<AtomFeed> feeds)
{
AtomFeed result = null;
if (feeds.size() > 0)
{
result = feeds.get(0);
for (int f = 1; f < feeds.size();f++)
for (Iterator<AtomEntry<?>> it = feeds.get(f).getEntryList().iterator();it.hasNext();)
result.getEntryList().add(it.next());
}
return result;
}
示例8: compose
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
public void compose(IXMLWriter writer, AtomFeed feed, boolean htmlPretty) throws Exception {
this.htmlPretty = htmlPretty;
xml = writer;
xml.setDefaultNamespace(ATOM_NS);
xml.open(ATOM_NS, "feed");
if (feed.getTitle() != null)
xml.element(ATOM_NS, "title", feed.getTitle());
if (feed.getId() != null)
xml.element(ATOM_NS, "id", feed.getId());
for (String n : feed.getLinks().keySet()) {
xml.attribute("href", feed.getLinks().get(n));
xml.attribute("rel", n);
xml.element(ATOM_NS, "link", null);
}
if (feed.getTotalResults() != null) {
xml.setDefaultNamespace("http://a9.com/-/spec/opensearch/1.1/");
xml.element("totalResults", feed.getTotalResults().toString());
xml.setDefaultNamespace(ATOM_NS);
}
if (feed.getUpdated() != null)
xml.element(ATOM_NS, "updated", feed.getUpdated().toString());
if (feed.getAuthorName() != null || feed.getAuthorUri() != null) {
xml.open(ATOM_NS, "author");
if (feed.getAuthorName() != null)
xml.element(ATOM_NS, "name", feed.getAuthorName());
if (feed.getAuthorUri() != null)
xml.element(ATOM_NS, "uri", feed.getAuthorUri());
xml.close(ATOM_NS, "author");
}
for (AtomCategory cat : feed.getTags()) {
xml.attribute("scheme", cat.getScheme());
xml.attribute("term", cat.getTerm());
if (!Utilities.noString(cat.getLabel()))
xml.attribute("label", cat.getLabel());
xml.element("category", null);
}
for (AtomEntry<? extends Resource> e : feed.getEntryList())
composeEntry(e);
xml.close(ATOM_NS, "feed");
}
示例9: parseEntry
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private <T extends Resource> AtomEntry<T> parseEntry(XmlPullParser xpp) throws Exception {
AtomEntry<T> res = new AtomEntry<T>();
xpp.next();
int eventType = nextNoWhitespace(xpp);
while (eventType != XmlPullParser.END_TAG) {
if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("title")) {
res.setTitle(parseString(xpp));
} else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("id"))
res.setId(parseString(xpp));
else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("link")) {
res.getLinks().put(xpp.getAttributeValue(null, "rel"), xpp.getAttributeValue(null, "href"));
skipEmptyElement(xpp);
} else if(eventType == XmlPullParser.START_TAG && xpp.getName().equals("updated"))
res.setUpdated(parseDate(xpp));
else if(eventType == XmlPullParser.START_TAG && xpp.getName().equals("published"))
res.setPublished(parseDate(xpp));
else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("category")) {
res.getTags().add(new AtomCategory(xpp.getAttributeValue(null, "scheme"), xpp.getAttributeValue(null, "term"), xpp.getAttributeValue(null, "label")));
skipEmptyElement(xpp);
} else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("author")) {
xpp.next();
eventType = nextNoWhitespace(xpp);
while (eventType != XmlPullParser.END_TAG) {
if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("name")) {
res.setAuthorName(parseString(xpp));
} else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("uri"))
res.setAuthorUri(parseString(xpp));
else
throw new Exception("Bad Xml parsing entry.author");
eventType = nextNoWhitespace(xpp);
}
xpp.next();
}
else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("content")) {
xpp.next();
nextNoWhitespace(xpp);
XmlParser p = new XmlParser();
p.setAllowUnknownContent(this.isAllowUnknownContent());
res.setResource((T)p.parse(xpp));//TODO Refactor architecture to eliminate this unsafe cast and better support generics
xpp.next();
nextNoWhitespace(xpp);
if (xpp.getName().equals("content")){
xpp.next();
}
} else if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("summary")) {
xpp.next();
nextNoWhitespace(xpp);
res.setSummary(new XhtmlParser().parseHtmlNode(xpp));
xpp.next();
nextNoWhitespace(xpp);
if(xpp.getName().equals("summary")) {
xpp.next();
}
} else
throw new Exception("Bad Xml parsing entry");
eventType = nextNoWhitespace(xpp);
}
xpp.next();
return res;
}
示例10: composeFeed
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
private void composeFeed(AtomFeed feed) throws Exception {
prop("resourceType", "Bundle");
prop("title", feed.getTitle());
prop("id", feed.getId());
if (feed.getLinks().size() > 0) {
openArray("link");
for (String n : feed.getLinks().keySet()) {
json.beginObject();
prop("rel", n);
prop("href", feed.getLinks().get(n));
json.endObject();
}
closeArray();
}
if (feed.getTotalResults() != null) {
prop("totalResults", feed.getTotalResults());
}
if (feed.getUpdated() != null)
prop("updated", feed.getUpdated().toString());
if (feed.getTags().size() > 0) {
openArray("category");
for (AtomCategory cat : feed.getTags()) {
json.beginObject();
prop("scheme", cat.getScheme());
prop("term", cat.getTerm());
if (!Utilities.noString(cat.getLabel()))
prop("label", cat.getLabel());
json.endObject();
}
closeArray();
}
if (feed.getAuthorName() != null || feed.getAuthorUri() != null) {
openArray("author");
json.beginObject();
if (feed.getAuthorName() != null)
prop("name", feed.getAuthorName());
if (feed.getAuthorUri() != null)
prop("uri", feed.getAuthorUri());
json.endObject();
closeArray();
}
if (feed.getEntryList().size() > 0) {
openArray("entry");
for (AtomEntry<? extends Resource> e : feed.getEntryList())
composeEntry(e);
closeArray();
}
}
示例11: composeEntry
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
private <T extends Resource> void composeEntry(AtomEntry<T> e) throws Exception {
json.beginObject();
prop("title", e.getTitle());
prop("id", e.getId());
if (e.getLinks().size() > 0) {
openArray("link");
for (String n : e.getLinks().keySet()) {
json.beginObject();
prop("rel", n);
prop("href", e.getLinks().get(n));
json.endObject();
}
closeArray();
}
if (e.getUpdated() != null)
prop("updated", e.getUpdated().toString());
if (e.getPublished() != null)
prop("published", e.getPublished().toString());
if (e.getAuthorName() != null || e.getAuthorUri() != null) {
openArray("author");
json.beginObject();
if (e.getAuthorName() != null)
prop("name", e.getAuthorName());
if (e.getAuthorUri() != null)
prop("uri", e.getAuthorUri());
json.endObject();
closeArray();
}
if (e.getTags().size() > 0) {
openArray("category");
for (AtomCategory cat : e.getTags()) {
json.beginObject();
prop("scheme", cat.getScheme());
prop("term", cat.getTerm());
if (!Utilities.noString(cat.getLabel()))
prop("label", cat.getLabel());
json.endObject();
}
closeArray();
}
open("content");
composeResource(e.getResource());
close();
if (e.getSummary() != null) {
composeXhtml("summary", e.getSummary());
}
json.endObject();
}
示例12: composeEntry
import org.hl7.fhir.instance.model.AtomEntry; //导入依赖的package包/类
private void composeEntry(AtomEntry e) throws Exception {
xml.open(ATOM_NS, "entry");
if (e.getTitle() != null)
xml.element(ATOM_NS, "title", e.getTitle());
if (e.getId() != null)
xml.element(ATOM_NS, "id", e.getId());
for (String n : e.getLinks().keySet()) {
xml.attribute("href", e.getLinks().get(n));
xml.attribute("rel", n);
xml.element(ATOM_NS, "link", null);
}
if (e.getUpdated() != null)
xml.element(ATOM_NS, "updated", dateToXml(e.getUpdated()));
if (e.getPublished() != null)
xml.element(ATOM_NS, "published", dateToXml(e.getPublished()));
if (e.getAuthorName() != null || e.getAuthorUri() != null) {
xml.open(ATOM_NS, "author");
if (e.getAuthorName() != null)
xml.element(ATOM_NS, "name", e.getAuthorName());
if (e.getAuthorUri() != null)
xml.element(ATOM_NS, "uri", e.getAuthorUri());
xml.close(ATOM_NS, "author");
}
for (String uri : e.getTags().keySet()) {
xml.attribute("scheme", "http://hl7.org/fhir/tag");
xml.attribute("term", uri);
String lbl = e.getTags().get(uri);
if (!Utilities.noString(lbl))
xml.attribute("label", lbl);
xml.element(ATOM_NS, "category", null);
}
xml.attribute("type", "text/xml");
xml.open(ATOM_NS, "content");
new XmlComposer().compose(xml, e.getResource(), htmlPretty);
xml.close(ATOM_NS, "content");
if (e.getSummary() != null) {
xml.attribute("type", "xhtml");
xml.open(ATOM_NS, "summary");
xml.namespace(XhtmlComposer.XHTML_NS, null);
boolean oldPretty = xml.isPretty();
xml.setPretty(htmlPretty);
new XhtmlComposer().compose(xml, e.getSummary());
xml.setPretty(oldPretty);
xml.close(ATOM_NS, "summary");
}
xml.close(ATOM_NS, "entry");
}