Skip to content

Commit fabae3f

Browse files
authored
Merge pull request #482 from spidasoftware/downconvert-warning-1520973
resolve wire-mounted equipment downconversion warning [AB#1520973]
2 parents dcae3b8 + 38a03f8 commit fabae3f

File tree

5 files changed

+67
-5
lines changed

5 files changed

+67
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ apply plugin: 'com.spidasoftware.releaseNotes'
1010
apply plugin: 'org.owasp.dependencycheck'
1111

1212
group = 'com.spidasoftware'
13-
version = '11.0.1' // If you're changing the major version also change the currentVersion in ConverterUtils.
13+
version = '11.0.2' // If you're changing the major version also change the currentVersion in ConverterUtils.
1414

1515
def schemaReleaseVersion = System.getenv("SCHEMA_RELEASE_VERSION")
1616
if(schemaReleaseVersion){

src/main/groovy/com/spidasoftware/schema/conversion/changeset/ConverterUtils.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class ConverterUtils {
103103
converter.addChangeSet(11, new MomentAtHeightChangeSet())
104104
converter.addChangeSet(11, new UpdateTempOverridesChangeSet())
105105
converter.addChangeSet(11, new WireStateLabelChangeSet())
106+
converter.addChangeSet(11, new WireMountedEquipmentChangeSet())
106107
converter.addChangeSet(11, new TrussChangeSet())
107108
// add client data changesets above here
108109

@@ -121,7 +122,11 @@ class ConverterUtils {
121122
converter.addChangeSet(10, new LoadCaseChangeSet())
122123
converter.addChangeSet(10, new LoadCaseNameChangeSet())
123124
converter.addChangeSet(10, new DecimalDirectionsChangeset())
125+
converter.addChangeSet(11, new ClientPoleSettingTypeChangeSet())
124126
converter.addChangeSet(11, new PoleCutTopChangeSet())
127+
converter.addChangeSet(11, new MomentAtHeightChangeSet())
128+
converter.addChangeSet(11, new WireStateLabelChangeSet())
129+
converter.addChangeSet(11, new WireMountedEquipmentChangeSet())
125130
converter.addChangeSet(11, new TrussChangeSet())
126131
// add result changesets above here
127132

src/main/groovy/com/spidasoftware/schema/conversion/changeset/v11/WireMountedEquipmentChangeSet.groovy

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,27 @@
44
package com.spidasoftware.schema.conversion.changeset.v11
55

66
import com.spidasoftware.schema.conversion.changeset.ConversionException
7-
import com.spidasoftware.schema.conversion.changeset.calc.AbstractCalcDesignChangeset
7+
import com.spidasoftware.schema.conversion.changeset.client.AbstractClientDataChangeSet
88
import groovy.transform.CompileStatic
99

1010
@CompileStatic
11-
class WireMountedEquipmentChangeSet extends AbstractCalcDesignChangeset {
11+
class WireMountedEquipmentChangeSet extends AbstractClientDataChangeSet {
12+
13+
@Override
14+
boolean applyToClientData(Map clientDataJSON) throws ConversionException {
15+
// do nothing
16+
return false
17+
}
18+
19+
@Override
20+
boolean revertClientData(Map clientDataJSON) throws ConversionException {
21+
boolean anyChanged = clientDataJSON.remove("wireMountedEquipments") != null
22+
23+
clientDataJSON.assemblies?.each { Map assembly ->
24+
anyChanged |= revertStructure(assembly.assemblyStructure as Map)
25+
}
26+
return anyChanged
27+
}
1228

1329
@Override
1430
void applyToDesign(Map designJSON) throws ConversionException {
@@ -17,7 +33,31 @@ class WireMountedEquipmentChangeSet extends AbstractCalcDesignChangeset {
1733

1834
@Override
1935
void revertDesign(Map designJSON) throws ConversionException {
20-
Map structure = designJSON.structure as Map
21-
structure?.remove("wireMountedEquipments")
36+
super.revertDesign(designJSON)
37+
38+
if (designJSON.structure != null) {
39+
revertStructure(designJSON.structure as Map)
40+
}
41+
}
42+
43+
@Override
44+
boolean applyToResults(Map resultsJSON) {
45+
// do nothing
46+
return false
47+
}
48+
49+
@Override
50+
boolean revertResults(Map resultsJSON) throws ConversionException {
51+
boolean anyChanged = super.revertResults(resultsJSON)
52+
53+
if (resultsJSON.analyzedStructure != null) {
54+
anyChanged |= revertStructure(resultsJSON.analyzedStructure as Map)
55+
}
56+
57+
return anyChanged
58+
}
59+
60+
protected boolean revertStructure(Map structureJSON) {
61+
return structureJSON.remove("wireMountedEquipments") != null
2262
}
2363
}

src/test/groovy/com/spidasoftware/schema/conversion/changeset/v11/WireMountedEquipmentChangeSetTest.groovy

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*/
44
package com.spidasoftware.schema.conversion.changeset.v11
55

6+
import groovy.json.JsonOutput
67
import groovy.json.JsonSlurper
78
import spock.lang.Specification
89

@@ -27,6 +28,21 @@ class WireMountedEquipmentChangeSetTest extends Specification {
2728
!json.leads[0].locations[1].designs[0].structure
2829
}
2930

31+
def "revert a project containing an assembly"() {
32+
setup:
33+
WireMountedEquipmentChangeSet changeSet = new WireMountedEquipmentChangeSet()
34+
def stream = WireMountedEquipmentChangeSetTest.getResourceAsStream("/conversions/v11/project-with-assembly-v11.json")
35+
String jsonStr = stream.text
36+
stream.close()
37+
Map json = (new JsonSlurper()).parseText(jsonStr)
38+
expect:
39+
jsonStr.contains("wireMountedEquipments")
40+
when:
41+
changeSet.revertProject(json)
42+
then:
43+
!JsonOutput.toJson(json).contains("wireMountedEquipments")
44+
}
45+
3046
}
3147

3248

src/test/resources/conversions/v11/project-with-assembly-v11.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)