ItemObserved updated

This commit is contained in:
Francesco Mangiacrapa 2024-03-21 15:53:09 +01:00
parent c5b031f6c8
commit 1e50bd74ca
1 changed files with 29 additions and 2 deletions

View File

@ -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,14 +27,13 @@ public class ItemObserved<T extends Project> implements ItemObservable {
T project;
EventManager.Event event;
public String getProjectId() {
log.debug("Called getProjectId");
if (project == null)
return null;
return project.getId();
}
@Override
public String getUCD_Id() {
log.debug("Called getUCD_Id");
@ -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;
}
}