use of org.hisp.dhis.node.types.SimpleNode in project dhis2-core by dhis2.
the class IndexController method createRootNode.
private RootNode createRootNode() {
RootNode rootNode = NodeUtils.createMetadata();
CollectionNode collectionNode = rootNode.addChild(new CollectionNode("resources"));
for (Schema schema : schemaService.getSchemas()) {
if (schema.haveApiEndpoint()) {
ComplexNode complexNode = collectionNode.addChild(new ComplexNode("resource"));
// TODO add i18n to this
complexNode.addChild(new SimpleNode("displayName", beautify(schema.getPlural())));
complexNode.addChild(new SimpleNode("singular", schema.getSingular()));
complexNode.addChild(new SimpleNode("plural", schema.getPlural()));
complexNode.addChild(new SimpleNode("href", contextService.getApiPath() + schema.getRelativeApiEndpoint()));
}
}
return rootNode;
}
use of org.hisp.dhis.node.types.SimpleNode in project dhis2-core by dhis2.
the class CsvNodeSerializer method startWriteRootNode.
@Override
protected void startWriteRootNode(RootNode rootNode) throws Exception {
for (Node child : rootNode.getChildren()) {
if (child.isCollection()) {
for (Node node : child.getChildren()) {
csvGenerator.writeStartObject();
for (Node property : node.getChildren()) {
if (property.isSimple()) {
writeSimpleNode((SimpleNode) property);
}
}
csvGenerator.writeEndObject();
}
}
}
}
use of org.hisp.dhis.node.types.SimpleNode in project dhis2-core by dhis2.
the class ExcelNodeSerializer method startWriteRootNode.
@Override
protected void startWriteRootNode(RootNode rootNode) throws Exception {
XSSFCreationHelper creationHelper = workbook.getCreationHelper();
int rowIdx = 1;
for (Node collectionNode : rootNode.getChildren()) {
if (collectionNode.isCollection()) {
for (Node complexNode : collectionNode.getChildren()) {
XSSFRow row = sheet.createRow(rowIdx++);
int cellIdx = 0;
for (Node node : complexNode.getChildren()) {
if (node.isSimple()) {
XSSFCell cell = row.createCell(cellIdx++);
cell.setCellValue(getValue((SimpleNode) node));
if (node.haveProperty() && PropertyType.URL.equals(node.getProperty().getPropertyType())) {
XSSFHyperlink hyperlink = creationHelper.createHyperlink(HyperlinkType.URL);
hyperlink.setAddress(getValue((SimpleNode) node));
hyperlink.setLabel(getValue((SimpleNode) node));
cell.setHyperlink(hyperlink);
} else if (node.haveProperty() && PropertyType.EMAIL.equals(node.getProperty().getPropertyType())) {
XSSFHyperlink hyperlink = creationHelper.createHyperlink(HyperlinkType.EMAIL);
hyperlink.setAddress(getValue((SimpleNode) node));
hyperlink.setLabel(getValue((SimpleNode) node));
cell.setHyperlink(hyperlink);
}
}
}
}
}
}
}
use of org.hisp.dhis.node.types.SimpleNode in project dhis2-core by dhis2.
the class DefaultMetadataVersionService method getMetadataVersionsAsNode.
@Override
public RootNode getMetadataVersionsAsNode(List<MetadataVersion> versions) {
RootNode rootNode = NodeUtils.createRootNode("metadataversions");
CollectionNode collectionNode = new CollectionNode("metadataversions", true);
rootNode.addChild(collectionNode);
for (MetadataVersion version : versions) {
ComplexNode complexNode = new ComplexNode("");
complexNode.addChild(new SimpleNode("name", version.getName()));
complexNode.addChild(new SimpleNode("type", version.getType()));
complexNode.addChild(new SimpleNode("created", version.getCreated()));
complexNode.addChild(new SimpleNode("id", version.getUid()));
complexNode.addChild(new SimpleNode("importdate", version.getImportDate()));
complexNode.addChild(new SimpleNode("hashCode", version.getHashCode()));
collectionNode.addChild(complexNode);
}
return rootNode;
}
use of org.hisp.dhis.node.types.SimpleNode in project dhis2-core by dhis2.
the class SystemController method getUuid.
@RequestMapping(value = "/uuid", method = RequestMethod.GET, produces = { MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_XML_VALUE })
@ResponseBody
public RootNode getUuid(@RequestParam(required = false, defaultValue = "1") Integer limit) throws IOException, InvalidTypeException {
limit = Math.min(limit, 10000);
RootNode rootNode = new RootNode("codes");
CollectionNode collectionNode = rootNode.addChild(new CollectionNode("codes"));
collectionNode.setWrapping(false);
for (int i = 0; i < limit; i++) {
collectionNode.addChild(new SimpleNode("code", UUID.randomUUID().toString()));
}
return rootNode;
}
Aggregations