use of org.openkilda.persistence.ferma.frames.SwitchFrame in project open-kilda by telstra.
the class FermaSwitchConnectRepository method doAdd.
@Override
protected SwitchConnectFrame doAdd(SwitchConnectData data) {
Switch owner = data.getOwner();
if (owner == null || owner.getSwitchId() == null) {
throw new IllegalArgumentException("Owner or owner switchId field is null");
}
SwitchFrame ownerFrame = SwitchFrame.load(framedGraph(), SwitchIdConverter.INSTANCE.toGraphProperty(owner.getSwitchId())).orElseThrow(() -> new IllegalArgumentException(String.format("Unable to locate the switch %s", owner.getSwitchId())));
Speaker speaker = data.getSpeaker();
if (speaker == null || speaker.getName() == null) {
throw new IllegalArgumentException("Speaker or speaker name is null");
}
SpeakerFrame speakerFrame = SpeakerFrame.load(framedGraph(), speaker.getName()).orElseThrow(() -> new IllegalArgumentException("Unable to locate speaker " + speaker.getName()));
SwitchConnectFrame frame = KildaBaseEdgeFrame.addNewFramedEdge(framedGraph(), ownerFrame, speakerFrame, SwitchConnectFrame.FRAME_LABEL, SwitchConnectFrame.class);
SwitchConnectCloner.INSTANCE.copyWithoutRelations(data, frame);
return frame;
}
use of org.openkilda.persistence.ferma.frames.SwitchFrame in project open-kilda by telstra.
the class FermaSwitchRepository method doAdd.
@Override
protected SwitchFrame doAdd(SwitchData data) {
SwitchFrame frame = KildaBaseVertexFrame.addNewFramedVertex(framedGraph(), SwitchFrame.FRAME_LABEL, SwitchFrame.class);
Switch.SwitchCloner.INSTANCE.copy(data, frame);
return frame;
}
use of org.openkilda.persistence.ferma.frames.SwitchFrame in project open-kilda by telstra.
the class FermaIslRepository method doAdd.
@Override
protected IslFrame doAdd(IslData data) {
String srcSwitchId = SwitchIdConverter.INSTANCE.toGraphProperty(data.getSrcSwitchId());
SwitchFrame source = SwitchFrame.load(framedGraph(), srcSwitchId).orElseThrow(() -> new IllegalArgumentException("Unable to locate the switch " + srcSwitchId));
String dstSwitchId = SwitchIdConverter.INSTANCE.toGraphProperty(data.getDestSwitchId());
SwitchFrame destination = SwitchFrame.load(framedGraph(), dstSwitchId).orElseThrow(() -> new IllegalArgumentException("Unable to locate the switch " + dstSwitchId));
IslFrame frame = KildaBaseEdgeFrame.addNewFramedEdge(framedGraph(), source, destination, IslFrame.FRAME_LABEL, IslFrame.class);
frame.setProperty(IslFrame.SRC_SWITCH_ID_PROPERTY, srcSwitchId);
frame.setProperty(IslFrame.DST_SWITCH_ID_PROPERTY, dstSwitchId);
Isl.IslCloner.INSTANCE.copyWithoutSwitches(data, frame);
return frame;
}
Aggregations