com.powsybl.sld.cgmes.dl.conversion.BusbarDiagramDataExporter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of powsybl-single-line-diagram-cgmes-dl-conversion Show documentation
Show all versions of powsybl-single-line-diagram-cgmes-dl-conversion Show documentation
A converter between CGMES-DL and IIDM
The newest version!
/**
* Copyright (c) 2019, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
package com.powsybl.sld.cgmes.dl.conversion;
import java.util.Map;
import java.util.Objects;
import java.util.UUID;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.powsybl.sld.cgmes.dl.iidm.extensions.NodeDiagramData;
import com.powsybl.iidm.network.BusbarSection;
import com.powsybl.iidm.network.TopologyKind;
import com.powsybl.triplestore.api.TripleStore;
/**
*
* @author Massimo Ferraro {@literal }
*/
public class BusbarDiagramDataExporter extends AbstractNodeDiagramDataExporter {
private static final Logger LOG = LoggerFactory.getLogger(BusbarDiagramDataExporter.class);
private Map busbarNodes;
public BusbarDiagramDataExporter(TripleStore tripleStore, ExportContext context, Map busbarNodes) {
super(tripleStore, context);
this.busbarNodes = Objects.requireNonNull(busbarNodes);
}
public void exportDiagramData(BusbarSection busbar) {
Objects.requireNonNull(busbar);
NodeDiagramData busbarDiagramData = busbar.getExtension(NodeDiagramData.class);
String diagramObjectStyleId = addDiagramObjectStyle(TopologyKind.NODE_BREAKER);
String busbarNodeId = getBusbarNodeId(busbar.getId());
addDiagramData(busbarNodeId, busbar.getNameOrId(), busbarDiagramData, diagramObjectStyleId);
}
protected String getBusbarNodeId(String busbarId) {
if (busbarNodes.containsKey(busbarId)) {
return busbarNodes.get(busbarId);
}
LOG.warn("Cannot find node id of busbar {} in triple store: creating new id", busbarId);
return "_" + UUID.randomUUID().toString();
}
}