Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that mrid are used when importing GLSK CIM and not rdfid #34

Merged
merged 1 commit into from
Jun 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,24 @@ public class CimGlskRegisteredResource extends AbstractGlskRegisteredResource {

public CimGlskRegisteredResource(Element element) {
Objects.requireNonNull(element);
this.mRID = element.getElementsByTagName("mRID").item(0).getTextContent();
this.mRID = removeRdfPrefix(element.getElementsByTagName("mRID").item(0).getTextContent());
this.name = element.getElementsByTagName("name").item(0).getTextContent();
this.participationFactor = getContentAsDoubleOrNull(element, "sK_ResourceCapacity.defaultCapacity");
this.maximumCapacity = getContentAsDoubleOrNull(element, "resourceCapacity.maximumCapacity");
this.minimumCapacity = getContentAsDoubleOrNull(element, "resourceCapacity.minimumCapacity");
}

private Double getContentAsDoubleOrNull(Element baseElement, String tag) {
private static String removeRdfPrefix(String s) {
String s1 = s;
// rdf:ID is the mRID plus an underscore added at the beginning of the string
// We may decide if we want to preserve or not the underscore
if (s1.length() > 0 && s1.charAt(0) == '_') {
s1 = s1.substring(1);
}
return s1;
}

private static Double getContentAsDoubleOrNull(Element baseElement, String tag) {
return baseElement.getElementsByTagName(tag).getLength() == 0 ? null :
Double.parseDouble(baseElement.getElementsByTagName(tag).item(0).getTextContent());
}
Expand Down