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;
}
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;
});
}
Aggregations