]> git.argeo.org Git - gpl/argeo-suite.git/blob - org.argeo.app.core/src/org/argeo/app/docbook/DbkAcrUtils.java
Releasing
[gpl/argeo-suite.git] / org.argeo.app.core / src / org / argeo / app / docbook / DbkAcrUtils.java
1 package org.argeo.app.docbook;
2
3 import org.argeo.api.acr.Content;
4 import org.argeo.app.api.EntityType;
5
6 /** Utilities when using ACR to access DocBook. */
7 public class DbkAcrUtils {
8 /** Whether this DocBook element is of this type. */
9 public static boolean isDbk(Content content, DbkType type) {
10 return content.isContentClass(type.qName());
11 }
12
13 public static String getMediaFileref(Content node) {
14 Content mediadata;
15 if (node.hasChild(DbkType.imageobject)) {
16 mediadata = node.child(DbkType.imageobject).child(DbkType.imagedata);
17 } else {
18 mediadata = node.child(DbkType.videoobject).child(DbkType.videodata);
19 }
20
21 if (mediadata.containsKey(DbkAttr.fileref)) {
22 return mediadata.attr(DbkAttr.fileref);
23 } else {
24 return null;
25 }
26 }
27
28 public static Content getMetadata(Content infoContainer) {
29 if (!infoContainer.hasChild(DbkType.info))
30 return null;
31 Content info = infoContainer.child(DbkType.info);
32 if (!info.hasChild(EntityType.local))
33 return null;
34 return info.child(EntityType.local);
35 }
36
37 /** singleton */
38 private DbkAcrUtils() {
39 }
40 }