Search in sources :

Example 1 with SwitchFrame

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;
}
Also used : Switch(org.openkilda.model.Switch) SwitchConnectFrame(org.openkilda.persistence.ferma.frames.SwitchConnectFrame) SpeakerFrame(org.openkilda.persistence.ferma.frames.SpeakerFrame) SwitchFrame(org.openkilda.persistence.ferma.frames.SwitchFrame) Speaker(org.openkilda.model.Speaker)

Example 2 with SwitchFrame

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;
}
Also used : SwitchFrame(org.openkilda.persistence.ferma.frames.SwitchFrame)

Example 3 with SwitchFrame

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;
}
Also used : IslFrame(org.openkilda.persistence.ferma.frames.IslFrame) SwitchFrame(org.openkilda.persistence.ferma.frames.SwitchFrame)

Aggregations

SwitchFrame (org.openkilda.persistence.ferma.frames.SwitchFrame)3 Speaker (org.openkilda.model.Speaker)1 Switch (org.openkilda.model.Switch)1 IslFrame (org.openkilda.persistence.ferma.frames.IslFrame)1 SpeakerFrame (org.openkilda.persistence.ferma.frames.SpeakerFrame)1 SwitchConnectFrame (org.openkilda.persistence.ferma.frames.SwitchConnectFrame)1