Search in sources :

Example 1 with Speaker

use of org.openkilda.model.Speaker 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 Speaker

use of org.openkilda.model.Speaker in project open-kilda by telstra.

the class SwitchFsm method lookupSpeakerCreateIfMissing.

private Speaker lookupSpeakerCreateIfMissing(String name) {
    return speakerRepository.findByName(name).orElseGet(() -> {
        Speaker speaker = Speaker.builder().name(name).build();
        speakerRepository.add(speaker);
        return speaker;
    });
}
Also used : Speaker(org.openkilda.model.Speaker)

Aggregations

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