ItemObserved updated
This commit is contained in:
parent
c5b031f6c8
commit
1e50bd74ca
|
@ -1,5 +1,9 @@
|
||||||
package org.gcube.application.cms.plugins.events;
|
package org.gcube.application.cms.plugins.events;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.gcube.application.geoportal.common.model.document.Project;
|
import org.gcube.application.geoportal.common.model.document.Project;
|
||||||
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
||||||
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
||||||
|
@ -23,14 +27,13 @@ public class ItemObserved<T extends Project> implements ItemObservable {
|
||||||
T project;
|
T project;
|
||||||
EventManager.Event event;
|
EventManager.Event event;
|
||||||
|
|
||||||
|
|
||||||
public String getProjectId() {
|
public String getProjectId() {
|
||||||
log.debug("Called getProjectId");
|
log.debug("Called getProjectId");
|
||||||
if (project == null)
|
if (project == null)
|
||||||
return null;
|
return null;
|
||||||
return project.getId();
|
return project.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUCD_Id() {
|
public String getUCD_Id() {
|
||||||
log.debug("Called getUCD_Id");
|
log.debug("Called getUCD_Id");
|
||||||
|
@ -39,4 +42,28 @@ public class ItemObserved<T extends Project> implements ItemObservable {
|
||||||
return useCaseDescriptor.getId();
|
return useCaseDescriptor.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LinkedHashMap<String, Object> getDocumentEntries(int limit) {
|
||||||
|
|
||||||
|
LinkedHashMap<String, Object> documentAsMap = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
Iterator<Entry<String, Object>> entrySetsIt = project.getTheDocument().entrySet().iterator();
|
||||||
|
int i = 0;
|
||||||
|
while (entrySetsIt.hasNext()) {
|
||||||
|
if (i + 1 > limit)
|
||||||
|
break;
|
||||||
|
|
||||||
|
Entry<String, Object> entry = entrySetsIt.next();
|
||||||
|
documentAsMap.put(entry.getKey(), entry.getValue() != null ? entry.getValue().toString() : null);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
return documentAsMap;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue