Skip to content

Commit

Permalink
Merge branch 'master' into xml_config_optional
Browse files Browse the repository at this point in the history
  • Loading branch information
geofjamg committed Nov 7, 2016
2 parents c55737c + 0d4e728 commit b178b49
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 33 deletions.
29 changes: 11 additions & 18 deletions iidm-ddb/iidm-ddb-ejb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,50 +102,43 @@
<version>2.0.0</version>
<scope>provided</scope>
</dependency>


<dependency>
<groupId>org.apache.ws.security</groupId>
<artifactId>wss4j</artifactId>
<version>1.6.5</version>
<scope>provided</scope>
</dependency>

<dependency>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.4.6</version>
<scope>provided</scope>
</dependency>
<dependency>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.4.6</version>
<scope>provided</scope>
</dependency>

<dependency>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
<version>2.4.6</version>
<scope>provided</scope>
</dependency>
<dependency>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-ws-security</artifactId>
<version>2.4.6</version>
<scope>provided</scope>
</dependency>

<dependency>
</dependency>
<dependency>
<groupId>org.jboss.spec.javax.annotation</groupId>
<artifactId>jboss-annotations-api_1.2_spec</artifactId>
<version>1.0.0.Final</version>
<scope>provided</scope>
</dependency>

</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public static void writeCurrentLimits(Integer index, CurrentLimits limits, XMLSt
}
XmlUtil.writeFloat("permanentLimit", limits.getPermanentLimit(), writer);
for (CurrentLimits.TemporaryLimit tl : limits.getTemporaryLimits()) {
writer.writeStartElement(IIDM_URI, "temporaryLimit");
writer.writeEmptyElement(IIDM_URI, "temporaryLimit");
writer.writeAttribute("name", tl.getName());
if (tl.getAcceptableDuration() != Integer.MAX_VALUE) {
writer.writeAttribute("acceptableDuration", Integer.toString(tl.getAcceptableDuration()));
Expand All @@ -168,7 +168,6 @@ public static void writeCurrentLimits(Integer index, CurrentLimits limits, XMLSt
if (tl.isFictitious()) {
writer.writeAttribute("fictitious", Boolean.toString(tl.isFictitious()));
}
writer.writeEndElement();
}
if (!limits.getTemporaryLimits().isEmpty()) {
writer.writeEndElement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,10 @@ public static Anonymizer write(Network n, XMLExportOptions options, OutputStream
writer.writeStartElement(IIDM_URI, NETWORK_ROOT_ELEMENT_NAME);
writer.writeNamespace(IIDM_PREFIX, IIDM_URI);

// add additional extension namespaces and check there is no collision between extensions
writeExtensionNamespaces(n, writer);
if (!options.isSkipExtensions()) {
// add additional extension namespaces and check there is no collision between extensions
writeExtensionNamespaces(n, writer);
}

writer.writeAttribute("id", n.getId());
writer.writeAttribute("caseDate", n.getCaseDate().toString());
Expand All @@ -201,8 +203,10 @@ public static Anonymizer write(Network n, XMLExportOptions options, OutputStream
}
}

// write extensions
writeExtensions(n, context);
if (!options.isSkipExtensions()) {
// write extensions
writeExtensions(n, context);
}

writer.writeEndElement();
writer.writeEndDocument();
Expand All @@ -213,25 +217,26 @@ public static Anonymizer write(Network n, XMLExportOptions options, OutputStream
}
}

public static void write(Network n, OutputStream os) {
write(n, new XMLExportOptions(), os);
public static Anonymizer write(Network n, OutputStream os) {
return write(n, new XMLExportOptions(), os);
}

public static void write(Network n, XMLExportOptions options, Path xmlFile) {
public static Anonymizer write(Network n, XMLExportOptions options, Path xmlFile) {
try (OutputStream os = Files.newOutputStream(xmlFile)) {
write(n, options, os);
return write(n, options, os);
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public static void write(Network n, Path xmlFile) {
write(n, new XMLExportOptions(), xmlFile);
public static Anonymizer write(Network n, Path xmlFile) {
return write(n, new XMLExportOptions(), xmlFile);
}

public static void writeAndValidate(Network n, Path xmlFile) {
write(n, xmlFile);
public static Anonymizer writeAndValidate(Network n, Path xmlFile) {
Anonymizer anonymizer = write(n, xmlFile);
validateWithExtensions(xmlFile);
return anonymizer;
}

public static Network read(InputStream is) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public class XMLExportOptions {

private boolean anonymized = false;

private boolean skipExtensions = false;

public XMLExportOptions() {
}

Expand Down Expand Up @@ -76,4 +78,13 @@ public XMLExportOptions setAnonymized(boolean anonymized) {
this.anonymized = anonymized;
return this;
}

public boolean isSkipExtensions() {
return skipExtensions;
}

public XMLExportOptions setSkipExtensions(boolean skipExtensions) {
this.skipExtensions = skipExtensions;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public class XMLExporter implements Exporter, XmlConstants {

public static final String ANONYMISED_PROPERTIES = "iidm.export.xml.anonymised";

public static final String SKIP_EXTENSIONS_PROPERTIES = "iidm.export.xml.skip-extensions";

@Override
public String getFormat() {
return "XIIDM";
Expand All @@ -84,7 +86,8 @@ public void export(Network network, Properties parameters, DataSource dataSource
.setWithBranchSV("true".equals(parameters.getProperty(WITH_BRANCH_STATE_VARIABLES_PROPERTY)))
.setForceBusBranchTopo("true".equals(parameters.getProperty(FORCE_BUS_BRANCH_TOPO_PROPERTY, "false")))
.setOnlyMainCc("true".equals(parameters.getProperty(ONLY_MAIN_CC_PROPERTIES)))
.setAnonymized("true".equals(parameters.getProperty(ANONYMISED_PROPERTIES)));
.setAnonymized("true".equals(parameters.getProperty(ANONYMISED_PROPERTIES)))
.setSkipExtensions("true".equals(parameters.getProperty(SKIP_EXTENSIONS_PROPERTIES)));
}

try {
Expand Down

0 comments on commit b178b49

Please sign in to comment.