Commit 61d834ac authored by PONCELET's avatar PONCELET

move network_attitude

parent 29967611
This diff is collapsed.
......@@ -3,15 +3,22 @@ package fr.ifremer.fr.xsf.generator.model;
import java.util.ArrayList;
import java.util.List;
enum GroupCategory{
eStandard,eSensor
}
public class Group extends Base{
GroupCategory groupCategory = GroupCategory.eStandard;
List<Attribute> attributes = new ArrayList<>();
List<Type> types = new ArrayList<>();
List<Dimension> dims = new ArrayList<>();
List<Variable> variables = new ArrayList<>();
List<Variable> coordinatevariables = new ArrayList<>();
public GroupCategory getGroupCategory() {
if (groupCategory==null) return GroupCategory.eStandard; //deserialization could lead to null values in this variables
return groupCategory;
}
protected List<Group> subGroups = new ArrayList<>();
public Group(String name, String description, String comment, String obligation) {
......
......@@ -77,8 +77,10 @@ public class SCGroupAdapter {
sourceCode.add(String.format("public class %s extends NCGroup {", getClassName(group, "")));
// Group name
sourceCode.add(String.format("\n\tpublic static final String GROUP_NAME = \"%s\";", group.name));
//if group is a sensor, group name is computed
if (group.getGroupCategory() == GroupCategory.eStandard)
sourceCode.add(String.format("\n\tpublic static final String GROUP_NAME = \"%s\";", group.name));
// Dimension name code generation
if(!group.dims.isEmpty())
{
......@@ -100,10 +102,21 @@ public class SCGroupAdapter {
// Dimension declaration
group.dims.forEach(d -> sourceCode.add(SCDimensionAdapter.getSourceDeclaration(d)));
// Start constructor
sourceCode.add(String.format(
"\n\tpublic %s(NCGroup parent, IDataProxy dataProxy) throws NCException {\n\t\tsuper(GROUP_NAME,parent);",
getClassName(group, "")));
// Start constructor if not a sensor
switch (group.getGroupCategory())
{
case eStandard:
sourceCode.add(String.format(
"\n\tpublic %s(NCGroup parent, IDataProxy dataProxy) throws NCException {\n\t\tsuper(GROUP_NAME,parent);",
getClassName(group, "")));
break;
case eSensor:
sourceCode.add(String.format(
"\n\tpublic %s(NCGroup parent, IDataProxy dataProxy, String sensor_id) throws NCException {\n\t\tsuper(sensor_id,parent);",
getClassName(group, "")));
break;
}
// Sub groups
if (!group.subGroups.isEmpty()) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment