Search in sources :

Example 1 with MessageID

use of com.mercedesbenz.sechub.sharedkernel.messaging.MessageID in project sechub by mercedes-benz.

the class UserRoleAdministrationMessageHandler method receiveAsyncMessage.

@Override
public void receiveAsyncMessage(DomainMessage request) {
    MessageID messageId = request.getMessageId();
    LOG.debug("received domain request: {}", request);
    switch(messageId) {
        case REQUEST_USER_ROLE_RECALCULATION:
            handleRoleRecalculationRequest(request);
            break;
        default:
            throw new IllegalStateException("unhandled message id:" + messageId);
    }
}
Also used : MessageID(com.mercedesbenz.sechub.sharedkernel.messaging.MessageID)

Example 2 with MessageID

use of com.mercedesbenz.sechub.sharedkernel.messaging.MessageID in project sechub by mercedes-benz.

the class SchedulerAdministrationMessageHandler method receiveAsyncMessage.

@Override
public void receiveAsyncMessage(DomainMessage request) {
    MessageID messageId = request.getMessageId();
    LOG.debug("received domain request: {}", request);
    switch(messageId) {
        case SCHEDULER_STATUS_UPDATE:
            handleSchedulerStatusChange(request);
            break;
        case SCHEDULER_JOB_PROCESSING_DISABLED:
            handleSchedulerJobProcessingDisabled(request);
            break;
        case SCHEDULER_JOB_PROCESSING_ENABLED:
            handleSchedulerJobProcessingEnabled(request);
            break;
        default:
            throw new IllegalStateException("unhandled message id:" + messageId);
    }
}
Also used : MessageID(com.mercedesbenz.sechub.sharedkernel.messaging.MessageID)

Example 3 with MessageID

use of com.mercedesbenz.sechub.sharedkernel.messaging.MessageID in project sechub by mercedes-benz.

the class DomainMessagingModel method updateGivenDomainPartMessageInfoList.

private <T extends Annotation> void updateGivenDomainPartMessageInfoList(Class<T> clazz, MessageID messageId, List<DomainPartMessageInfo<T>> list, Domain domain, DomainPart domainPart) {
    List<T> receiverClazzList = domainPart.fetchList(clazz);
    if (DEBUG) {
        LOG.info(" >enter:{},{}, found:{}", domain, domainPart, list);
    }
    for (T receiverClazz : receiverClazzList) {
        MessageID foundMessageId = getMessageIdToSearchFor(receiverClazz);
        boolean sameMessageId = foundMessageId == messageId;
        if (sameMessageId) {
            DomainPartMessageInfo<T> info = new DomainPartMessageInfo<>();
            info.messageInfo = receiverClazz;
            info.part = domainPart;
            if (receiverClazz instanceof IsSendingSyncMessageAnswer) {
                IsSendingSyncMessageAnswer answer = (IsSendingSyncMessageAnswer) receiverClazz;
                info.messageId = answer.value();
                info.answeringTo = answer.answeringTo();
                info.branchName = answer.branchName();
            } else {
                info.messageId = messageId;
            }
            list.add(info);
        }
    }
}
Also used : IsSendingSyncMessageAnswer(com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingSyncMessageAnswer) MessageID(com.mercedesbenz.sechub.sharedkernel.messaging.MessageID)

Example 4 with MessageID

use of com.mercedesbenz.sechub.sharedkernel.messaging.MessageID in project sechub by mercedes-benz.

the class DomainMessagingModelPlantUMLGenerator method generate.

public String generate(DomainMessagingModel model, String title, MessageID[] messageIDs, boolean onlyWithGivenMessageIds) {
    Context context = new Context();
    context.model = model;
    context.addLine("@startuml");
    context.addLine("\n");
    context.addLine("title " + title);
    context.addLine("skinparam style strictuml");
    context.addLine("\n");
    context.addLine("control " + EVENT_BUS_ID);
    boolean alternate = false;
    for (Domain domain : model.domains) {
        alternate = !alternate;
        String data = "box \"" + domain.name + "\" ";
        // see https://www.w3schools.com/colors/colors_names.asp
        if (alternate) {
            data += "#C8C8CF";
        } else {
            // #Ghostwhite
            data += "#F8F8FF";
        }
        // #LightBlue
        context.addLine(data);
        for (DomainPart part : domain.domainParts) {
            if (onlyWithGivenMessageIds && !part.isHandlingAtLeastOneOf(messageIDs)) {
                continue;
            }
            context.addLine("   participant " + part.name);
        }
        context.addLine("end box");
    }
    for (MessageID messageId : messageIDs) {
        context.messageId = messageId;
        debug("INSPECT:" + messageId);
        generateMessage(context);
    }
    context.addLine("\n");
    context.addLine("@enduml");
    return context.sb.toString();
}
Also used : Domain(com.mercedesbenz.sechub.docgen.messaging.DomainMessagingModel.Domain) DomainPart(com.mercedesbenz.sechub.docgen.messaging.DomainMessagingModel.DomainPart) MessageID(com.mercedesbenz.sechub.sharedkernel.messaging.MessageID)

Example 5 with MessageID

use of com.mercedesbenz.sechub.sharedkernel.messaging.MessageID in project sechub by mercedes-benz.

the class DomainMessagingFilesGenerator method generateMessagingFiles.

public void generateMessagingFiles(File messagingFile, File diagramsGenFolder, DomainMessagingModel model) throws IOException {
    String overviewName = "gen_domain_messaging_overview.plantuml";
    DomainMessagingModel reducedModelForOverview = createReducedClone(model);
    generateMessagingPlantumlFile(diagramsGenFolder, reducedModelForOverview, "__Overview__ of domain **messaging** ", overviewName, MessageID.values());
    for (MessageID messageId : MessageID.values()) {
        String messagePlantUmlFileName = createGeneratedPlantUmlFileName(messageId);
        generateMessagingPlantumlFile(diagramsGenFolder, model, "__Communication details __ of **message " + messageId.getId() + "**", messagePlantUmlFileName, new MessageID[] { messageId });
    }
    StringBuilder sb = new StringBuilder();
    sb.append("[[section-gen-messaging-overview]]\n");
    sb.append("===== Overview\n");
    sb.append("====== Diagram\n");
    sb.append("plantuml::diagrams/gen/" + overviewName + "[format=svg, alt=\"Sequence diagram of messaging overview\"]\n");
    sb.append("\n");
    SortedSet<String> idsSorted = new TreeSet<>();
    for (MessageID messageId : MessageID.values()) {
        idsSorted.add(messageId.getId());
    }
    sb.append("[[section-gen-messaging-overview-linklist]]\n");
    sb.append("====== List of all messages\n");
    for (String id : idsSorted) {
        sb.append("- <<" + createMessagingLinkId(id) + "," + id + ">>\n");
    }
    sb.append("\n\n");
    for (String id : idsSorted) {
        String messagePlantUmlFileName = createGeneratedPlantUmlFileName(MessageID.valueOf(id));
        sb.append("[[" + createMessagingLinkId(id) + "]]\n");
        sb.append("===== Message " + id + "\n");
        sb.append("plantuml::diagrams/gen/" + messagePlantUmlFileName + "[format=svg, alt=\"Sequence diagram of messaging " + id + "\"]\n");
        sb.append("\n");
        sb.append("include::message2usecases_" + createMessagingLinkId(id) + ".adoc[]\n");
    }
    writer.save(messagingFile, sb.toString());
}
Also used : TreeSet(java.util.TreeSet) MessageID(com.mercedesbenz.sechub.sharedkernel.messaging.MessageID)

Aggregations

MessageID (com.mercedesbenz.sechub.sharedkernel.messaging.MessageID)14 HashSet (java.util.HashSet)2 Test (org.junit.jupiter.api.Test)2 Domain (com.mercedesbenz.sechub.docgen.messaging.DomainMessagingModel.Domain)1 DomainPart (com.mercedesbenz.sechub.docgen.messaging.DomainMessagingModel.DomainPart)1 IsSendingSyncMessageAnswer (com.mercedesbenz.sechub.sharedkernel.messaging.IsSendingSyncMessageAnswer)1 TreeSet (java.util.TreeSet)1