Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: Yet another Implementation of an organization unit tree #383

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading