From 79dbb8e54c4578cf9d5bf1ee070d767462607f3c Mon Sep 17 00:00:00 2001
From: jakubs <jakubs>
Date: Wed, 11 Mar 2015 14:27:30 +0000
Subject: [PATCH] SSDM-1625: add projects to spaces, and experiments to
 projects

SVN: 33629
---
 .../api/v3/dto/entity/project/Project.java    | 25 ++++++++++++++++++
 .../shared/api/v3/dto/entity/space/Space.java | 25 ++++++++++++++++++
 .../project/ProjectFetchOptions.java          | 26 +++++++++++++++++++
 .../fetchoptions/space/SpaceFetchOptions.java | 26 +++++++++++++++++++
 .../api/v3/dto/generators/Generator.java      | 12 ++++++---
 5 files changed, 110 insertions(+), 4 deletions(-)

diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/project/Project.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/project/Project.java
index 7cf014c05c2..381d47b7c3b 100644
--- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/project/Project.java
+++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/project/Project.java
@@ -15,6 +15,7 @@
  */
 package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.project;
 
+import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.person.Person;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.space.Space;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.project.ProjectFetchOptions;
@@ -26,6 +27,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * Class automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
@@ -56,6 +58,9 @@ public class Project implements Serializable
     @JsonProperty
     private Date modificationDate;
 
+    @JsonProperty
+    private List<Experiment> experiments;
+
     @JsonProperty
     private Space space;
 
@@ -156,6 +161,26 @@ public class Project implements Serializable
         this.modificationDate = modificationDate;
     }
 
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    @JsonIgnore
+    public List<Experiment> getExperiments()
+    {
+        if (getFetchOptions().hasExperiments())
+        {
+            return experiments;
+        }
+        else
+        {
+            throw new NotFetchedException("Expreiments have not been fetched.");
+        }
+    }
+
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    public void setExperiments(List<Experiment> experiments)
+    {
+        this.experiments = experiments;
+    }
+
     // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
     @JsonIgnore
     public Space getSpace()
diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/space/Space.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/space/Space.java
index c706969efbe..196038ef6c2 100644
--- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/space/Space.java
+++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/entity/space/Space.java
@@ -16,6 +16,7 @@
 package ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.space;
 
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.person.Person;
+import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.project.Project;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.space.SpaceFetchOptions;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.id.space.SpacePermId;
 import ch.ethz.sis.openbis.generic.shared.api.v3.exceptions.NotFetchedException;
@@ -24,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import java.io.Serializable;
 import java.util.Date;
+import java.util.List;
 
 /**
  * Class automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
@@ -51,6 +53,9 @@ public class Space implements Serializable
     @JsonProperty
     private Person registrator;
 
+    @JsonProperty
+    private List<Project> projects;
+
     // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
     @JsonIgnore
     public SpaceFetchOptions getFetchOptions()
@@ -136,4 +141,24 @@ public class Space implements Serializable
         this.registrator = registrator;
     }
 
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    @JsonIgnore
+    public List<Project> getProjects()
+    {
+        if (getFetchOptions().hasProjects())
+        {
+            return projects;
+        }
+        else
+        {
+            throw new NotFetchedException("Projects have not been fetched.");
+        }
+    }
+
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    public void setProjects(List<Project> projects)
+    {
+        this.projects = projects;
+    }
+
 }
diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/project/ProjectFetchOptions.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/project/ProjectFetchOptions.java
index fe938b8b5b2..410a9ece1f6 100644
--- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/project/ProjectFetchOptions.java
+++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/project/ProjectFetchOptions.java
@@ -15,6 +15,7 @@
  */
 package ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.project;
 
+import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.experiment.ExperimentFetchOptions;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.person.PersonFetchOptions;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.space.SpaceFetchOptions;
 import ch.systemsx.cisd.base.annotation.JsonObject;
@@ -29,6 +30,9 @@ public class ProjectFetchOptions implements Serializable
 {
     private static final long serialVersionUID = 1L;
 
+    @JsonProperty
+    private ExperimentFetchOptions experiments;
+
     @JsonProperty
     private SpaceFetchOptions space;
 
@@ -38,6 +42,28 @@ public class ProjectFetchOptions implements Serializable
     @JsonProperty
     private PersonFetchOptions modifier;
 
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    public ExperimentFetchOptions withExperiments()
+    {
+        if (experiments == null)
+        {
+            experiments = new ExperimentFetchOptions();
+        }
+        return experiments;
+    }
+
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    public ExperimentFetchOptions withExperimentsUsing(ExperimentFetchOptions fetchOptions)
+    {
+        return experiments = fetchOptions;
+    }
+
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    public boolean hasExperiments()
+    {
+        return experiments != null;
+    }
+
     // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
     public SpaceFetchOptions withSpace()
     {
diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/space/SpaceFetchOptions.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/space/SpaceFetchOptions.java
index dbbe4317631..2fe0392f776 100644
--- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/space/SpaceFetchOptions.java
+++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/fetchoptions/space/SpaceFetchOptions.java
@@ -16,6 +16,7 @@
 package ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.space;
 
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.person.PersonFetchOptions;
+import ch.ethz.sis.openbis.generic.shared.api.v3.dto.fetchoptions.project.ProjectFetchOptions;
 import ch.systemsx.cisd.base.annotation.JsonObject;
 import com.fasterxml.jackson.annotation.JsonProperty;
 import java.io.Serializable;
@@ -31,6 +32,9 @@ public class SpaceFetchOptions implements Serializable
     @JsonProperty
     private PersonFetchOptions registrator;
 
+    @JsonProperty
+    private ProjectFetchOptions projects;
+
     // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
     public PersonFetchOptions withRegistrator()
     {
@@ -53,4 +57,26 @@ public class SpaceFetchOptions implements Serializable
         return registrator != null;
     }
 
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    public ProjectFetchOptions withProjects()
+    {
+        if (projects == null)
+        {
+            projects = new ProjectFetchOptions();
+        }
+        return projects;
+    }
+
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    public ProjectFetchOptions withProjectsUsing(ProjectFetchOptions fetchOptions)
+    {
+        return projects = fetchOptions;
+    }
+
+    // Method automatically generated with {@link ch.ethz.sis.openbis.generic.shared.api.v3.dto.generators.DtoGenerator}
+    public boolean hasProjects()
+    {
+        return projects != null;
+    }
+
 }
diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/Generator.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/Generator.java
index e56c0c19829..a282d5f04e8 100644
--- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/Generator.java
+++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/shared/api/v3/dto/generators/Generator.java
@@ -13,6 +13,7 @@ import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.DataSetType;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.ExternalData;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.FileFormatType;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.dataset.LocatorType;
+import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.Experiment;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.experiment.ExperimentType;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.person.Person;
 import ch.ethz.sis.openbis.generic.shared.api.v3.dto.entity.project.Project;
@@ -322,6 +323,9 @@ public class Generator extends AbstractGenerator
         addRegistrationDate(gen);
         addModificationDate(gen);
 
+        gen.addFetchedField("List<Experiment>", List.class.getName(), "experiments", "Expreiments", ExperimentFetchOptions.class);
+        gen.addClassForImport(Experiment.class);
+
         addSpace(gen);
         addRegistrator(gen);
         addModifier(gen);
@@ -337,9 +341,9 @@ public class Generator extends AbstractGenerator
         addCode(gen);
         addDescription(gen);
         addRegistrationDate(gen);
-
         addRegistrator(gen);
-
+        gen.addFetchedField("List<Project>", List.class.getName(), "projects", "Projects", ProjectFetchOptions.class);
+        gen.addClassForImport(Project.class);
         return gen;
     }
 
@@ -378,8 +382,8 @@ public class Generator extends AbstractGenerator
             System.out.print("Generating api classes for " + gen + "...");
             gen.generateDTO();
             gen.generateFetchOptions();
-            gen.generateDTOJS();
-            gen.generateFetchOptionsJS();
+            // gen.generateDTOJS();
+            // gen.generateFetchOptionsJS();
             System.out.println("done");
         }
     }
-- 
GitLab