From be4f78978faba3d3ceb88df02a7f93a2e09ff1e0 Mon Sep 17 00:00:00 2001 From: Kenji Hosokawa Date: Tue, 3 Aug 2021 18:42:39 +0900 Subject: Initial commit Bug-AGL: SPEC-4033 Signed-off-by: Kenji Hosokawa --- .../template/RBAModel.jsontemplate | 568 +++++++++++++++++++++ 1 file changed, 568 insertions(+) create mode 100644 rba.tool.editor.endpoint/template/RBAModel.jsontemplate (limited to 'rba.tool.editor.endpoint/template') diff --git a/rba.tool.editor.endpoint/template/RBAModel.jsontemplate b/rba.tool.editor.endpoint/template/RBAModel.jsontemplate new file mode 100644 index 0000000..ba311d2 --- /dev/null +++ b/rba.tool.editor.endpoint/template/RBAModel.jsontemplate @@ -0,0 +1,568 @@ +{ +<% boolean isFirst = true; %>\ + "root":{ + "model":<%if(util.project != null){%><%=util.project.version%><%}else{%>""<%}%>, + "template":"02.00.00", +<% if(util.areas.size) { %>\ + "areas":[ +<% area_last = util.areas.get(util.areas.size - 1); + util.areas.each {%>\ + { + "name":"<%=it.name%>", + "visibility":<%=util.getVisibility(it.name)%>, + "arbitrationPolicy":"<%=it.getArbitrationPolicy().name%>", + "zorder":<%=util.getZorder(it.name)%>, + "size":[ +<% size_last = it.size.get(it.size.size - 1); + it.size.each { %>\ + { +<% if(it.getClass().getName().toString() == "rba.view.impl.SizeReferenceImpl"){ %>\ + "name":"<%=it.getSize().name%>", + "width":<%=it.getSize().getWidth()%>, + "height":<%=it.getSize().getHeight()%> +<% }else if(it.getClass().getName().toString() == "rba.view.impl.SizeImpl"){ %>\ + "name":"<%=it.name%>", + "width":<%=it.getWidth()%>, + "height":<%=it.getHeight()%> +<% } %>\ + }<%if (it != size_last) {%>,<%}%> +<% } %>\ + ] +<% s = util2.jsonConstractorOtherThan(it, 3, Arrays.asList("class", "name", "arbitrationPolicy", "zorder", "contents", "allocatableGroup", "visibility", "size")); + if (s.size() > 1) {%><%=s%><%}%>\ + }<%if (it != area_last) {%>,<%}%> +<% } + isFirst = false; + } %>\ +<% if(util.getZones().size) { %>\ +<% if(!isFirst){ %>\ + ], +<% } %>\ + "zones":[ +<% util.getZones().each { + zone_last = util.getZones().get(util.getZones().size - 1); %>\ + { + "name":"<%=it.name%>", + "arbitrationPolicy":"<%=it.getArbitrationPolicy().name%>", + "priority":<%=util.getVisibility(it.name)%><% + if(it.getAttenuate() != null){%>, + "attenuateValue":<%=it.getAttenuate().value%>\ +<% } + s = util2.jsonConstractorOtherThan(it, 3, Arrays.asList("class", "name", "size", "arbitrationPolicy", "contents", "allocatableGroup", "visibility", "attenuate")); + if (s.size() > 1) {%><%=s%><%}%> + }<%if (it != zone_last) {%>,<%}%> +<% } + } %>\ +<% if(util.getViewContents().size) { %>\ + ], + "viewcontents":[ +<% cont_last = util.getViewContents().get(util.getViewContents().size - 1); + util.getViewContents().each { %>\ + { + "name":"<%=it.name%>",<%cont_name=it.name%> + "loserType":"<%=it.getLoserType()%>", + "size":[ +<% size_last = it.size.get(it.size.size - 1); + it.size.each { + if(it.getClass().getName().toString() == "rba.view.impl.SizeReferenceImpl"){ %>\ + { + "name":"<%=it.getSize().name%>", + "width":<%=it.getSize().getWidth()%>, + "height":<%=it.getSize().getHeight()%> + }<% if (it != size_last) {%>,<%}%> +<% }else if(it.getClass().getName().toString() == "rba.view.impl.SizeImpl"){ %>\ + { + "name":"<%=it.name%>", + "width":<%=it.getWidth()%>, + "height":<%=it.getHeight()%> + }<%if (it != size_last) {%>,<%}%> +<% } + } %>\ + ], + "states":[ +<% state_last = it.getStates().get(it.getStates().size - 1); + it.getStates().each { %>\ + { + "name":"<%=it.name%>", + "priority":<%=util.getPriority(cont_name, it.name)%> + }<%if (it != state_last) {%>,<%}%> +<% } %>\ + ], + "allocatable":[ +<% alloc_last = util2.getAllocatableList(it).get(util2.getAllocatableList(it).size - 1); + util2.getAllocatableList(it).each {%>\ + "<%=util2.getFullNameWithClassName(it)%>"<%if (it != alloc_last) {%>,<%} %> +<% } %>\ + ]<% + s = util2.jsonConstractorOtherThan(it, 3, Arrays.asList("class", "name", "size", "loserType", "contentGroup", "allocatable", "states")); + if (s.size() > 1) {%><%=s%><%}%> + }<%if (it != cont_last) {%>,<%}%> +<% } + } %>\ +<% if(util.getSoundContents().size) { %>\ + ], + "soundcontents":[ +<% cont_last = util.getSoundContents().get(util.getSoundContents().size - 1); + util.getSoundContents().each { %>\ + { + "name":"<%=it.name%>",<%cont_name=it.name%> + "loserType":"<%=it.getLoserType()%>", + "states":[ +<% state_last = it.getStates().get(it.getStates().size - 1); + it.getStates().each { %>\ + { + "name":"<%=it.name%>", + "priority":<%=util.getPriority(cont_name, it.name)%> + }<%if (it != state_last) {%>,<%}%> +<% } %>\ + ], + "allocatable":[ +<% alloc_last = util2.getAllocatableList(it).get(util2.getAllocatableList(it).size - 1); + util2.getAllocatableList(it).each {%>\ + "<%=util2.getFullNameWithClassName(it)%>"<%if (it != alloc_last) {%>,<%} %> +<% } %>\ + ]<% + s = util2.jsonConstractorOtherThan(it, 3, Arrays.asList("class", "name", "loserType", "contentGroup", "allocatable", "states")); + if (s.size() > 1) {%><%=s%><%}%> + }<%if (it != cont_last) {%>,<%} %> +<% } + } %>\ +<% if(util.displays.size) { %>\ + ], + "displays":[ +<% disp_last = util.displays.get(util.displays.size - 1); + util.displays.each { + disp = it; %>\ + { + "name":"<%=it.name%>", + "size":{ + "name":"<%=util.getDisplaySize(disp).name%>", + "width":<%=util.getDisplaySize(disp).getWidth()%>, + "height":<%=util.getDisplaySize(disp).getHeight()%> + }, + "PositionContainer":[ +<% pos_last = it.root.layout.subAreaPosition.get(it.root.layout.subAreaPosition.size - 1) + it.root.layout.subAreaPosition.each { %>\ + { + "x":<%=it.getX()%>, + "y":<%=it.getY()%>, + "basePoint":"<%=it.getBasePoint()%>", + "areaReference":"<%=it.getArea().name%>"<% + if (it.getOffset().size > 0) { %>, + "Offset":[ +<% offset_last = it.getOffset().get(it.getOffset().size -1); + it.getOffset().each { %>\ + { + "x":<%=it.getX()%>, + "y":<%=it.getY()%>, + "sizeReference":"<%=it.getSize().getSize().name%>" + }<% if (it != offset_last) {%>,<%} %>\ +<% } %> + ]<% + } %> + }<%if (it != pos_last) {%>,<%} %> +<% } %>\ + ] + }<%if (it != disp_last) {%>,<%} %> +<% } + } %>\ +<% if(util.getAreaSets().size) { %>\ + ], + "areasets":[ +<% set_last = util.getAreaSets().get(util.getAreaSets().size - 1); + util.getAreaSets().each { %>\ + { + "name":"<%=it.name%>", + "target":[ +<% tar_last = it.collectLeafAllocatable().get(it.collectLeafAllocatable().size - 1); + it.collectLeafAllocatable().each { %>\ + "<%=it.name%>"<%if (it != tar_last) {%>,<%} %> +<% } %>\ + ] + }<% if (it != set_last) {%>,<%} %> +<% } + } %>\ +<% if(util.getZoneSets().size) { %>\ + ], + "zonesets":[ +<% set_last = util.getZoneSets().get(util.getZoneSets().size - 1); + util.getZoneSets().each { %>\ + { + "name":"<%=it.name%>", + "target":[ +<% tar_last = it.collectLeafAllocatable().get(it.collectLeafAllocatable().size - 1); + it.collectLeafAllocatable().each { %>\ + "<%=it.name%>"<%if (it != tar_last) {%>,<%} %> +<% } %>\ + ] + }<% if (it != set_last) {%>,<%} %> +<% } + } %>\ +<% if(util.getViewContentSets().size) { %>\ + ], + "viewcontentsets":[ +<% set_last = util.getViewContentSets().get(util.getViewContentSets().size - 1); + util.getViewContentSets().each { %>\ + { + "name":"<%=it.name%>", + "target":[ +<% isFirst = true; + util2.getLeafContentList(it).each { + if (!isFirst) { %>, +<% } else { + isFirst = false; + } %>\ + "<%=it.name%>"<% + } %> + ] + }<% if (it != set_last) {%>,<%} %> +<% } + } %>\ +<% if(util.getSoundContentSets().size) { %>\ + ], + "soundcontentsets":[ +<% set_last = util.getSoundContentSets().get(util.getSoundContentSets().size - 1); + util.getSoundContentSets().each { %>\ + { + "name":"<%=it.name%>", + "target":[ +<% isFirst = true; + util2.getLeafContentList(it).each { + if (!isFirst) {%>, +<% } else { + isFirst = false; + } %>\ + "<%=it.name%>"<% + } %> + ] + }<% if (it != set_last) {%>,<%} %> +<% } + } %>\ +<% if(util.scenes.size) { %>\ + ], + "scenes":[ +<% scene_last = util.scenes.get(util.scenes.size - 1); + util.scenes.each { %>\ + { + "name":"<%=it.name%>", + "global":"<%=it.isGlobal()%>"<% + if (it.isGlobal() && (it.getProperties().size > 0)) { %>, + "property":[ +<% prop_last = it.getProperties().get(it.getProperties().size - 1); + it.getProperties().each { %>\ + { + "name":"<%=it.name%>", + "value":<%=it.getValue().getValue()%> + }<% if (it != prop_last) {%>,<%} %> +<% }%>\ + ]<% + s = util2.jsonConstractorOtherThan(it, 3, Arrays.asList("class", "name", "global", "properties")); + if (s.size() > 1) {%><%=s%><%}%><% + }%> + }<%if (it != scene_last) {%>,<%} %> +<% } + } %>\ +<% if(util.constraints.size) { %>\ + ], + "constraints":[<% + exp_last = util.constraints.get(util.constraints.size - 1); + nest = 2; + util.constraints.each { + %><%=util2.jsonConstractor(it, nest)%><%if (it != exp_last) {%>,<%} %>\ +<% } %> +<% } %>\ +<% + util2.setAll(util.areas, util.zones, util.viewContents, util.soundContents); + ConstraintVisitor.setAll(util.areas, util.zones, util.viewContents, util.soundContents); + Map alloc_constraint_map = new HashMap(); + if(util.areas.size > 0) {%>\ + ], + "area_constraint_map":[<% + util.areas.each { + if (it != util.areas.get(0)) {%>,<%} + area = it; + alloc_constraint_map.put(area, new HashSet()); + allocateVisitor.setTarget(area); %> + {"<%=area.name%>":[<% + isFirst = true; + util.constraints.each { + try { + if (it.runtime) { + checkResult = allocateVisitor.visitBool(it.expression); + if ( + (checkResult == ConstraintVisitResult.ALWAYS_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE) || + (checkResult == ConstraintVisitResult.POSSIBLE_TRUE) + ) { + alloc_constraint_map.get(area).add(it); + constraint_alloc_map.addRelationship(it,area); + if (!isFirst) { + %>,<%} else { + isFirst = false; + } + %>"<%=it.name%>"<% + } + } + } catch (e) { + %> + Exception @ <%=it.name%> + <%=e%> + <% + } + } + %>]}<% + } %> + ], + "area_hidden_true_check_constraint_map":[<% + util.areas.each { + if (it != util.areas.get(0)) {%>,<%} + area = it; + trueHiddenVisitor.setTarget(area); %> + {"<%=area.name%>":[<% + isFirst = true; + util.constraints.each { + try { + if (it.runtime) { + checkResult = trueHiddenVisitor.visitBool(it.expression); + if ( + (checkResult == ConstraintVisitResult.ALWAYS_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE) || + (checkResult == ConstraintVisitResult.POSSIBLE_TRUE) + ) { + constraint_alloc_map.addRelationship(it,area); + if (!isFirst) { + %>,<%} else { + isFirst = false; + } + %>"<%=it.name%>"<% + } + } + } catch (e) { + %> + Exception @ <%=it.name%> + <%=e%> + <% + } + } + %>]}<% + } %> + ], + "area_hidden_false_check_constraint_map":[<% + util.areas.each { + if (it != util.areas.get(0)) {%>,<%} + area = it; + falseHiddenVisitor.setTarget(area); %> + {"<%=area.name%>":[<% + isFirst = true; + util.constraints.each { + try { + if (it.runtime) { + checkResult = falseHiddenVisitor.visitBool(it.expression); + if ( + (checkResult == ConstraintVisitResult.ALWAYS_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE) || + (checkResult == ConstraintVisitResult.POSSIBLE_TRUE) + ) { + constraint_alloc_map.addRelationship(it,area); + if (!isFirst) { + %>,<%} else { + isFirst = false; + } + %>"<%=it.name%>"<% + } + } + } catch (e) { + %> + Exception @ <%=it.name%> + <%=e%> + <% + } + } + %>]}<% + } %> +<% }%>\ +<% if(util.zones.size > 0) { %>\ + ], + "zone_constraint_map":[<% + util.zones.each { + if (it != util.zones.get(0)) {%>,<%} + zone = it; + alloc_constraint_map.put(zone, new HashSet()); + allocateVisitor.setTarget(zone); %> + {"<%=zone.name%>":[<% + isFirst = true; + util.constraints.each { + try { + if (it.runtime) { + checkResult = allocateVisitor.visitBool(it.expression); + if ( + (checkResult == ConstraintVisitResult.ALWAYS_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE) || + (checkResult == ConstraintVisitResult.POSSIBLE_TRUE) + ) { + constraint_alloc_map.addRelationship(it,zone); + alloc_constraint_map.get(zone).add(it); + if (!isFirst) { + %>,<%} else { + isFirst = false; + } + %>"<%=it.name%>"<% + } + } + } catch (e) { + %> + Exception @ <%=it.name%> + <%=e%> + <% + } + } + %>]}<% + } %> + ], + "zone_mute_true_check_constraint_map":[<% + util.zones.each { + if (it != util.zones.get(0)) {%>,<%} + zone = it; + trueHiddenVisitor.setTarget(zone); %> + {"<%=zone.name%>":[<% + isFirst = true; + util.constraints.each { + try { + if (it.runtime) { + checkResult = trueHiddenVisitor.visitBool(it.expression); + if ( + (checkResult == ConstraintVisitResult.ALWAYS_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE) || + (checkResult == ConstraintVisitResult.POSSIBLE_TRUE) + ) { + constraint_alloc_map.addRelationship(it,zone); + if (!isFirst) { + %>,<%} else { + isFirst = false; + } + %>"<%=it.name%>"<% + } + } + } catch (e) { + %> + Exception @ <%=it.name%> + <%=e%> + <% + } + } + %>]}<% + } %> + ], + "zone_mute_false_check_constraint_map":[<% + util.zones.each { + if (it != util.zones.get(0)) {%>,<%} + zone = it; + falseHiddenVisitor.setTarget(zone); %> + {"<%=zone.name%>":[<% + isFirst = true; + util.constraints.each { + try { + if (it.runtime) { + checkResult = falseHiddenVisitor.visitBool(it.expression); + if ( + (checkResult == ConstraintVisitResult.ALWAYS_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE) || + (checkResult == ConstraintVisitResult.POSSIBLE_TRUE) + ) { + constraint_alloc_map.addRelationship(it,zone); + if (!isFirst) { + %>,<%} else { + isFirst = false; + } + %>"<%=it.name%>"<% + } + } + } catch (e) { + %> + Exception @ <%=it.name%> + <%=e%> + <% + } + } + %>]}<% + } %> + ], + "zone_attenuate_true_check_constraint_map":[<% + util.zones.each { + if (it != util.zones.get(0)) {%>,<%} + zone = it; + trueAttenuateVisitor.setTarget(zone); %> + {"<%=zone.name%>":[<% + isFirst = true; + util.constraints.each { + try { + if (it.runtime) { + checkResult = trueAttenuateVisitor.visitBool(it.expression); + if ( + (checkResult == ConstraintVisitResult.ALWAYS_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE) || + (checkResult == ConstraintVisitResult.POSSIBLE_TRUE) + ) { + constraint_alloc_map.addRelationship(it,zone); + if (!isFirst) { + %>,<%} else { + isFirst = false; + } + %>"<%=it.name%>"<% + } + } + } catch (e) { + %> + Exception @ <%=it.name%> + <%=e%> + <% + } + } + %>]}<% + } %> + ], + "zone_attenuate_false_check_constraint_map":[<% + util.zones.each { + if (it != util.zones.get(0)) {%>,<%} + zone = it; + falseAttenuateVisitor.setTarget(zone); %> + {"<%=zone.name%>":[<% + isFirst = true; + util.constraints.each { + try { + if (it.runtime) { + checkResult = falseAttenuateVisitor.visitBool(it.expression); + if ( + (checkResult == ConstraintVisitResult.ALWAYS_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE_FALSE) || + (checkResult == ConstraintVisitResult.POSSIBLE) || + (checkResult == ConstraintVisitResult.POSSIBLE_TRUE) + ) { + constraint_alloc_map.addRelationship(it,zone); + if (!isFirst) { + %>,<%} else { + isFirst = false; + } + %>"<%=it.name%>"<% + } + } + } catch (e) { + %> + Exception @ <%=it.name%> + <%=e%> + <% + } + } + %>]}<% + } + }%>\ + ] + } +} \ No newline at end of file -- cgit 1.2.3-korg