Skip to content

Commit

Permalink
orgunittree services and rest endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
floriangantner committed Sep 6, 2023
1 parent 5766d8c commit 1000b86
Show file tree
Hide file tree
Showing 18 changed files with 1,520 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.layout;

/**
*
* Implementation of {@link CrisLayoutSectionComponent} that allows definition
* of a section containing some trees or orgunits list of counters.
*
* @author Florian Gantner ([email protected])
*
*/
public class CrisLayoutOrgunittreeComponent implements CrisLayoutSectionComponent {

private String style = "";

private String title = "";

@Override
public String getStyle() {
return style;
}

public void setStyle(String style) {
this.style = style;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.uniba.orgunittree;

import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.UUID;

/**
* The OrgUnitTree model
* Contains a list of rootnodes and some hashmap of all nodes for easier access
*
* @author Florian Gantner ([email protected])
*
*/
public class Orgunittree {
private Date date;
private List<OrgunittreeNode> rootnodes = new LinkedList<>();

public Orgunittree() {
this.date = new Date();
}

public void addRoot(OrgunittreeNode node) {
if (!this.rootnodes.contains(node)) {
rootnodes.add(node);
}
}

public List<OrgunittreeNode> getNodes() {
return this.rootnodes;
}

public OrgunittreeNode findNodeByUUID(UUID uuid) {
OrgunittreeNode res = null;
for (OrgunittreeNode root : rootnodes) {
if (res != null) {
return res;
}
res = recursiveSearch(uuid, root);
}
return res;
}

private OrgunittreeNode recursiveSearch(UUID uuid,OrgunittreeNode node) {
if (node.getUuid().equals(uuid)) {
return node;
}
List<OrgunittreeNode> children = node.getChild();
OrgunittreeNode res = null;
for (int i = 0; res == null && i < children.size(); i++) {
res = recursiveSearch(uuid, children.get(i));
}
return res;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.uniba.orgunittree;

/**
* The OrgunittreeMetrics to some single orgunittreenode
*
* @author Florian Gantner ([email protected])
*/
public class OrgunittreeMetrics {

private Integer value;

private String shortname;

private boolean aggregated;

public String getShortname() {
return shortname;
}

public void setShortname(String shortname) {
this.shortname = shortname;
}

public Integer getValue() {
return value;
}

public void setValue(Integer value) {
this.value = value;
}

public boolean getAggregated() {
return aggregated;
}

public void setAggregated(boolean aggregated) {
this.aggregated = aggregated;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.uniba.orgunittree;

import java.util.ArrayList;
import java.util.List;

/**
* The OrgUnitTreeNode Metrics configuration settings
*
* @author Florian Gantner ([email protected])
*
*/
public class OrgunittreeMetricsConfiguration {

public OrgunittreeMetricsConfiguration() {
this.filterquery = new ArrayList<>();
}
private String shortname;
private boolean aggregate = false;
private String query;
private List<String> filterquery;

public void setShortname(String shortname) {
this.shortname = shortname;
}
public String getShortname() {
return this.shortname;
}

public void setQuery(String query) {
this.query = query;
}
public String getQuery() {
return this.query;
}
public void setAggregate(boolean aggregate) {
this.aggregate = aggregate;
}
public boolean isAggregate() {
return this.aggregate;
}
public void setFilterquery(List<String> filterquery) {
this.filterquery = filterquery;
}
public List<String> getFilterquery() {
return this.filterquery;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
/**
* The contents of this file are subject to the license and copyright
* detailed in the LICENSE and NOTICE files at the root of the source
* tree and available online at
*
* http://www.dspace.org/license/
*/
package org.dspace.uniba.orgunittree;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.dspace.content.Item;
import org.dspace.util.UUIDUtils;

/**
* The OrgUnitTreeNode Model
*
* @author Florian Gantner ([email protected])
*
*/
public class OrgunittreeNode {

public OrgunittreeNode(Item item) {
this.item = item;
this.uuid = item.getID();
this.displayname = item.getName();
this.childs = new ArrayList<>();
this.child_uuid = new ArrayList<>();
this.metrics = new HashMap<>();
}

private Map<String,OrgunittreeMetrics> metrics;
private final List<OrgunittreeNode> childs;
private final List<UUID> child_uuid;

//The item of the node
private Item item;

//uuid of the dspace object
private UUID uuid;
//displayname (as fallback)
private String displayname;

public void addChild(OrgunittreeNode node) {
if (!this.getChild().contains(node)) {
this.getChild().add(node);
}
}

public void addChild_UUID(UUID id) {
if (!this.getChild_uuid().contains(id)) {
this.getChild_uuid().add(id);
}
}

public List<OrgunittreeNode> getChild() {
return this.childs;
}

public UUID getUuid() {
return uuid;
}

public String getUuidString() {
return UUIDUtils.toString(uuid);
}

public void setUuid(UUID uuid) {
this.uuid = uuid;
}

public String getDisplayname() {
return displayname;
}

public void setDisplayname(String displayname) {
this.displayname = displayname;
}

public Item getItem() {
return item;
}

public void setItem(Item item) {
this.item = item;
}

public Map<String, OrgunittreeMetrics> getMetrics() {
return metrics;
}

public void setMetrics(HashMap<String, OrgunittreeMetrics> metrics) {
this.metrics = metrics;
}
public void addMetric(OrgunittreeMetrics node) {
if (!this.metrics.containsKey(node.getShortname())) {
this.metrics.put(node.getShortname(),node);
}
}

public List<UUID> getChild_uuid() {
return child_uuid;
}
}
Loading

0 comments on commit 1000b86

Please sign in to comment.