public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{\"name\" : \"").append(name).append("\", \"displayName\" : \"").append(displayName).append("\""); sb.append(", \"description\" : \"").append(description).append("\", \"attributes\" : ["); boolean first = true; for (EventAttribute attribute : attributes) { if (!first) { sb.append(", "); } else { first = false; } sb.append("{\"name\" : \"").append(attribute.getName()).append("\", \"required\" : ").append(attribute.isRequired()).append("}"); } sb.append("]}"); return sb.toString(); } }
@Override public Map<String, Attribute> getAttributes(String eventName, String catalogId) { Event event = getEvent(eventName, catalogId); if (event == null) { logger.warn("The event named {} could not be found in catalog {}", eventName, catalogId); return null; } List<EventAttribute> eventAttributes = event.getAttributes() == null ? emptyList() : event.getAttributes(); Map<String, Attribute> attributes = new HashMap<>(eventAttributes.size()); for (EventAttribute eventAttribute : eventAttributes) { Attribute attr = getAttribute(eventAttribute.getName(), event.getCatalogId()); if (attr != null) { attributes.put(attr.getName(), attr); } } return attributes; }
if (event.getAttributes() != null) { for (EventAttribute eventAttribute : event.getAttributes()) { String name = eventAttribute.getName(); Attribute attribute = getAttribute(name, event.getCatalogId()); if (attribute != null) {
Attribute attr = catalogManager.getAttribute(eventAttribute.getName(), event.getCatalogId()); if ((!attr.isRequestContext() && (attr.isRequired()) || (eventAttribute.isRequired() != null && eventAttribute.isRequired()))) {
if (eventAttributes != null) { for (EventAttribute eventAttribute : eventAttributes) { Attribute attribute = attributes.get(eventAttribute.getName()); if (attribute == null) { LOGGER.error("Unable to locate attribute name {}", eventAttribute.getName()); errors = true; continue; String name = eventAttribute.getName(); if (name.startsWith(REQCTX)) { name = name.substring(REQCTX.length()); final String attrName = name; if (event.getAttributes() != null) { Optional<EventAttribute> optional = event.getAttributes().stream().filter(a -> attrName.equals(a.getName())).findFirst(); if (optional.isPresent()) { isRequired = optional.get().isRequired();
if (event.getAttributes() != null) { for (EventAttribute eventAttribute : eventAttributes) { EventAttributeModel eventAttributeModel = model.getAttribute(eventAttribute.getName()); if (eventAttributeModel != null) { eventAttributeModel.setRequired(eventAttribute != null ? eventAttribute.isRequired() : null); } else { Optional<AttributeModel> optional = getAttribute(event.getCatalogId(), eventAttribute.getName()); if (optional.isPresent()) { eventAttributeModel = new EventAttributeModel(); eventAttributeModels.add(eventAttributeModel); } else { throw new CatalogModificationException("No catalog entry for " + eventAttribute.getName()); eventAttributeModels.removeIf(a -> eventAttributes.stream().noneMatch(b -> b.getName().equals(a.getAttribute().getName()))); model.setAttributes(eventAttributeModels); return LOGGER.traceExit(model);