use of org.hl7.elm.r1.IndexOf in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testFindActionDetail.
@Test
public void testFindActionDetail() throws Exception {
ActionDetail actionDetail = fieldActionsService.findActionDetail(new Prepend(), FieldType.STRING);
assertNotNull(actionDetail);
System.out.println(new ObjectMapper().writeValueAsString(actionDetail.getActionSchema()));
actionDetail = fieldActionsService.findActionDetail(new IndexOf(), FieldType.STRING);
assertNotNull(actionDetail);
actionDetail = fieldActionsService.findActionDetail(new Action() {
}, FieldType.STRING);
assertNull(actionDetail);
actionDetail = fieldActionsService.findActionDetail(new IndexOf(), null);
assertNotNull(actionDetail);
actionDetail = fieldActionsService.findActionDetail(new IndexOf(), FieldType.STRING);
assertNotNull(actionDetail);
actionDetail = fieldActionsService.findActionDetail(new IndexOf(), FieldType.ANY);
assertNotNull(actionDetail);
actionDetail = fieldActionsService.findActionDetail(new IndexOf(), FieldType.NONE);
assertNotNull(actionDetail);
actionDetail = fieldActionsService.findActionDetail(new IndexOf(), FieldType.BOOLEAN);
assertNotNull(actionDetail);
}
use of org.hl7.elm.r1.IndexOf in project atlasmap by atlasmap.
the class StringComplexFieldActionsTest method testIndexOf.
@Test
public void testIndexOf() {
IndexOf action = new IndexOf();
action.setString("");
assertEquals(-1, StringComplexFieldActions.indexOf(action, null));
assertEquals(0, StringComplexFieldActions.indexOf(action, ""));
assertEquals(0, StringComplexFieldActions.indexOf(action, "foo"));
action.setString("bar");
assertEquals(-1, StringComplexFieldActions.indexOf(action, null));
assertEquals(-1, StringComplexFieldActions.indexOf(action, ""));
assertEquals(-1, StringComplexFieldActions.indexOf(action, "foo"));
assertEquals(3, StringComplexFieldActions.indexOf(action, "foobar"));
assertEquals(3, StringComplexFieldActions.indexOf(action, "foobarbar"));
}
use of org.hl7.elm.r1.IndexOf in project kindling by HL7.
the class SpreadSheetReloader method parseStatus.
private void parseStatus(Element ed, String value) {
ed.removeExtension(BuildExtensions.EXT_FMM_LEVEL);
ed.removeExtension(BuildExtensions.EXT_STANDARDS_STATUS);
ed.removeExtension(BuildExtensions.EXT_NORMATIVE_VERSION);
if (!Utilities.noString(value) && value.contains("/")) {
String[] p = value.split("\\/");
if (Utilities.noString(p[0].trim())) {
ed.removeExtension(BuildExtensions.EXT_FMM_LEVEL);
} else {
ed.addExtension(BuildExtensions.EXT_FMM_LEVEL, new IntegerType(p[0]));
}
if (p[1].contains(";")) {
ed.addExtension(BuildExtensions.EXT_STANDARDS_STATUS, new CodeType(p[1].substring(0, p[1].indexOf(";"))));
ed.addExtension(BuildExtensions.EXT_NORMATIVE_VERSION, new CodeType(p[1].substring(p[1].indexOf("from=") + 5)));
} else {
ed.addExtension(BuildExtensions.EXT_STANDARDS_STATUS, new CodeType(p[1]));
}
}
sortExtensions(ed);
}
use of org.hl7.elm.r1.IndexOf in project kindling by HL7.
the class ValueSetFinder method checkSearchParams.
private static void checkSearchParams(File f) throws Exception {
String folder = Utilities.getDirectoryForFile(f.getAbsolutePath());
System.out.println(f.getName());
try {
Set<String> s = new HashSet<>();
for (File fsp : new File(folder).listFiles()) {
if (fsp.getName().startsWith("searchparameter-")) {
SearchParameter sp = (SearchParameter) new XmlParser().parseAndClose(new FileInputStream(fsp));
s.add(sp.getId());
}
}
for (File fig : new File(folder).listFiles()) {
if (fig.getName().startsWith("implementationguide-")) {
ImplementationGuide ig = (ImplementationGuide) new XmlParser().parseAndClose(new FileInputStream(fig));
ig.getDefinition().getResource().removeIf(res -> res.getReference().getReference().startsWith("SearchParameter/") && !s.contains(res.getReference().getReference().substring(res.getReference().getReference().indexOf("/") + 1)));
if (ig.getDefinition().getResource().isEmpty()) {
fig.delete();
} else {
new XmlParser().setOutputStyle(OutputStyle.PRETTY).compose(new FileOutputStream(fig), ig);
}
}
}
} catch (Exception e) {
System.out.println(" " + e.getMessage());
}
}
use of org.hl7.elm.r1.IndexOf in project kindling by HL7.
the class PageProcessor method checkFormat.
private void checkFormat(String filename, String res, ResourceDefn r) throws FHIRException {
XhtmlNode doc;
try {
doc = new XhtmlParser().parse("<div>" + res + "</div>", null).getFirstElement();
if (doc.getFirstElement() == null || !doc.getFirstElement().getName().equals("div"))
log("file \"" + filename + "\": root element should be 'div'", LogMessageType.Error);
else if (doc.getFirstElement() == null) {
log("file \"" + filename + "\": there is no 'Scope and Usage'", LogMessageType.Error);
} else {
XhtmlNode scope = null;
XhtmlNode context = null;
for (XhtmlNode x : doc.getChildNodes()) {
if (x.getNodeType() == NodeType.Element) {
if (!x.getName().equals("div")) {
log("file \"" + filename + "\": all child elements of the root div should be 'div's too (found '" + x.getName() + "')", LogMessageType.Error);
return;
} else if (x.getChildNodes().isEmpty()) {
log("file \"" + filename + "\": div/div[" + Integer.toString(doc.getChildNodes().indexOf(x)) + "] must have at least an h2", LogMessageType.Error);
return;
} else if (!isFirstChildElementH2(x)) {
log("file \"" + filename + "\": div/div[" + Integer.toString(doc.getChildNodes().indexOf(x)) + "] must start with an h2", LogMessageType.Error);
return;
} else {
XhtmlNode fn = getH2Element(x);
String s = fn.allText();
if (!((s.equals("Scope and Usage")) || (s.equals("Boundaries and Relationships")) || (s.equals("Background and Context")))) {
log("file \"" + filename + "\": div/div[" + Integer.toString(doc.getChildNodes().indexOf(x)) + "]/h2 must be either 'Scope and Usage', 'Boundaries and Relationships', or 'Background and Context'", LogMessageType.Error);
return;
} else {
if (scope == null) {
if (s.equals("Scope and Usage")) {
scope = x;
if (r != null)
r.setRequirements(new XhtmlComposer(XhtmlComposer.HTML).composePlainText(x));
} else {
log("file \"" + filename + "\": 'Scope and Usage' must come first", LogMessageType.Error);
return;
}
if (s.equals("Boundaries and Relationships")) {
if (context != null) {
log("file \"" + filename + "\": 'Boundaries and Relationships' must come first before 'Background and Context'", LogMessageType.Error);
return;
}
}
if (s.equals("Background and Context"))
context = x;
}
}
boolean found = false;
for (XhtmlNode n : x.getChildNodes()) {
if (!found)
found = n == fn;
else {
if ("h1".equals(n.getName()) || "h2".equals(n.getName())) {
log("file \"" + filename + "\": content of a <div> inner section cannot contain h1 or h2 headings", LogMessageType.Error);
return;
}
}
}
}
}
}
}
List<String> allowed = Arrays.asList("div", "h2", "h3", "h4", "h5", "i", "b", "code", "pre", "blockquote", "p", "a", "img", "table", "thead", "tbody", "tr", "th", "td", "ol", "ul", "li", "br", "span", "em", "strong");
iterateAllChildNodes(doc, allowed);
} catch (Exception e) {
throw new FHIRException("Error processing " + filename + ": " + e.getMessage(), e);
}
}
Aggregations