ItemObserved updated
This commit is contained in:
parent
c5b031f6c8
commit
1e50bd74ca
|
@ -1,5 +1,9 @@
|
|||
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.accounting.Context;
|
||||
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
||||
|
@ -23,7 +27,6 @@ public class ItemObserved<T extends Project> implements ItemObservable {
|
|||
T project;
|
||||
EventManager.Event event;
|
||||
|
||||
|
||||
public String getProjectId() {
|
||||
log.debug("Called getProjectId");
|
||||
if (project == null)
|
||||
|
@ -39,4 +42,28 @@ public class ItemObserved<T extends Project> implements ItemObservable {
|
|||
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