private void setIdEraseName(String id) { objectStore.remove(this); this.id = id; name = null; // reset the name objectStore.checkAndAdd(this); }
Identifiable get(String id) { checkId(id); return objectsById.get(id); }
/** * Merge an other object store into this one. At the end of the call the * other object store is empty. * @param other the object store to merge */ void merge(ObjectStore other) { for (Identifiable obj : other.objectsById.values()) { checkAndAdd(obj); } other.clean(); }
@Override public Collection<Identifiable<?>> getIdentifiables() { return objectStore.getAll(); }
NetworkImpl(String id, String name, String sourceFormat) { super(id, name); Objects.requireNonNull(sourceFormat, "source format is null"); this.sourceFormat = sourceFormat; variantManager = new VariantManagerImpl(objectStore); variants = new VariantArray<>(ref, VariantImpl::new); // add the network the object list as it is a multi variant object // and it needs to be notified when and extension or a reduction of // the variant array is requested objectStore.checkAndAdd(this); }
protected String checkAndGetUniqueId() { if (id == null) { throw new PowsyblException(getTypeDescription() + " id is not set"); } String uniqueId; if (ensureIdUnicity) { uniqueId = getNetwork().getObjectStore().getUniqueId(id); } else { if (getNetwork().getObjectStore().contains(id)) { Identifiable obj = getNetwork().getObjectStore().get(id); throw new PowsyblException("The network " + getNetwork().getId() + " already contains an object '" + obj.getClass().getSimpleName() + "' with the id '" + id + "'"); } uniqueId = id; } return uniqueId; }
Multimap<Class<? extends Identifiable>, String> intersection = objectStore.intersection(otherNetwork.objectStore); for (Map.Entry<Class<? extends Identifiable>, Collection<String>> entry : intersection.asMap().entrySet()) { Class<? extends Identifiable> clazz = entry.getKey(); otherNetwork.objectStore.remove(otherNetwork); objectStore.merge(otherNetwork.objectStore);
private void removeSwitch(String switchId) { Integer e = switches.remove(switchId); if (e == null) { throw new PowsyblException("Switch '" + switchId + "' not found in substation voltage level '" + id + "'"); } SwitchImpl aSwitch = graph.removeEdge(e); getNetwork().getObjectStore().remove(aSwitch); }
void addBus(ConfiguredBus bus) { getNetwork().getObjectStore().checkAndAdd(bus); int v = graph.addVertex(); graph.setVertexObject(v, bus); buses.put(bus.getId(), v); }
@Override public SubstationImpl getSubstation(String id) { return objectStore.get(id, SubstationImpl.class); }
private void removeAllSwitches() { for (SwitchImpl s : graph.getEdgesObject()) { getNetwork().getObjectStore().remove(s); } graph.removeAllEdges(); switches.clear(); }
private void addSwitch(SwitchImpl aSwitch, String busId1, String busId2) { int v1 = getVertex(busId1, true); int v2 = getVertex(busId2, true); getNetwork().getObjectStore().checkAndAdd(aSwitch); int e = graph.addEdge(v1, v2, aSwitch); switches.put(aSwitch.getId(), e); }
@Override public ThreeWindingsTransformer getThreeWindingsTransformer(String id) { return objectStore.get(id, ThreeWindingsTransformerImpl.class); }
private void removeAllSwitches() { for (SwitchImpl s : graph.getEdgesObject()) { getNetwork().getObjectStore().remove(s); } graph.removeAllEdges(); switches.clear(); }
boolean contains(String id) { checkId(id); return objectsById.containsKey(id); }
@Override public Substation add() { String id = checkAndGetUniqueId(); ValidationUtil.checkCountry(this, country); SubstationImpl substation = new SubstationImpl(id, getName(), country, tso, networkRef); if (tags != null) { for (String tag : tags) { substation.addGeographicalTag(tag); } } getNetwork().getObjectStore().checkAndAdd(substation); getNetwork().getListeners().notifyCreation(substation); return substation; }