diff --git a/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java b/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java index 350c0cb..6eca6ab 100644 --- a/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java +++ b/src/main/java/org/gcube/informationsystem/service/InformationSystemService.java @@ -19,6 +19,7 @@ import org.gcube.common.authorization.utils.secret.Secret; import org.gcube.informationsystem.base.reference.AccessType; import org.gcube.informationsystem.base.reference.Element; import org.gcube.informationsystem.contexts.reference.entities.Context; +import org.gcube.informationsystem.contexts.reference.relations.IsParentOf; import org.gcube.informationsystem.model.knowledge.ModelKnowledge; import org.gcube.informationsystem.model.reference.entities.Facet; import org.gcube.informationsystem.model.reference.entities.Resource; @@ -85,6 +86,30 @@ public class InformationSystemService { } + private String extractPath(Context ctx) { + String res = "/"+ctx.getName(); + if(ctx.getParent()==null) { + return res; + } + Context dad = ctx.getParent().getSource(); + res = "/"+ctx.getParent().getSource().getName()+res; + if(dad.getParent()==null) { + return res; + } + Context gdad = dad.getParent().getSource(); + res = "/"+dad.getParent().getSource().getName()+res; + if(gdad.getParent()==null) { + return res; + } + Context g2dad = gdad.getParent().getSource(); + res = "/"+gdad.getParent().getSource().getName()+res; + if(g2dad.getParent()==null) { + return res; + } + return res; + } + + public List getAllContexts() throws Exception { ArrayList res = new ArrayList(); @@ -92,9 +117,18 @@ public class InformationSystemService { ResourceRegistryClient resourceRegistryClient= ResourceRegistryClientFactory.create(); Listcontexts=resourceRegistryClient.getAllContext(); for(Context ctx:contexts) { + String pnt = " - "; //for the root + //TODO: da dove tiro fuori il path? ContextDTO dto = new ContextDTO(); dto.setId(ctx.getID().toString()); dto.setName(ctx.getName()); + if(ctx.getParent()!=null) { + if(ctx.getParent().getSource()!=null) { + pnt = ctx.getParent().getSource().getName(); + } + } + dto.setParent(pnt); + dto.setPath(extractPath(ctx)); res.add(dto); } log.debug("AllContexts: {}",contexts); diff --git a/src/main/java/org/gcube/informationsystem/service/dto/ContextDTO.java b/src/main/java/org/gcube/informationsystem/service/dto/ContextDTO.java index 4e008b2..9138eea 100644 --- a/src/main/java/org/gcube/informationsystem/service/dto/ContextDTO.java +++ b/src/main/java/org/gcube/informationsystem/service/dto/ContextDTO.java @@ -10,4 +10,6 @@ import lombok.NoArgsConstructor; public class ContextDTO { private String id; private String name; + private String parent; + private String path; } diff --git a/src/main/webapp/app/home/home.component.html b/src/main/webapp/app/home/home.component.html index f8c2d12..7dc128b 100644 --- a/src/main/webapp/app/home/home.component.html +++ b/src/main/webapp/app/home/home.component.html @@ -15,8 +15,6 @@ - -
@@ -25,7 +23,7 @@ You are logged in as user "{{account.login}}".
- - + -->
@@ -52,12 +49,9 @@ [formControl]="namefield" /> Please, enter a valid name! - + - {{ fctx.name }} - | ID: {{ fctx.id }} - + {{ fctx.path }} @@ -68,6 +62,9 @@ + diff --git a/src/main/webapp/app/home/home.component.ts b/src/main/webapp/app/home/home.component.ts index 9a72c26..f3a3c49 100644 --- a/src/main/webapp/app/home/home.component.ts +++ b/src/main/webapp/app/home/home.component.ts @@ -88,6 +88,24 @@ export class HomeComponent implements OnInit, OnDestroy { ); } + /* + getContexts(): string[] { + if (this.account != null && this.account.resourceAccessDTO != null) { + // eslint-disable-next-line no-console + var sc=this.account.resourceAccessDTO.resourceAccess; + var contexts=Array.from(Object.keys(sc)); + contexts=contexts.filter(element=> + element!==null&&element.startsWith("%2F")); + contexts=contexts.sort(); + // eslint-disable-next-line no-console + console.log(contexts); + return contexts; + + } else { + return []; + } + } + */ //TODO: CHECK WHY UNSUBSCRIBE DOES NOT WORK ngOnDestroy(): void { diff --git a/src/main/webapp/app/services/i-context-node.ts b/src/main/webapp/app/services/i-context-node.ts index 90a86cb..310f8b2 100644 --- a/src/main/webapp/app/services/i-context-node.ts +++ b/src/main/webapp/app/services/i-context-node.ts @@ -1,4 +1,6 @@ export interface IContextNode{ name: string; id: string; + parent: string; + path: string; }