use of org.jaffa.soa.services.configdomain.SoaEventInfo in project jaffa-framework by jaffa-projects.
the class SOAEventHandler method injectDomainFacts.
private void injectDomainFacts(UOW uow, ServiceRulesInterceptor interceptor, SOAEventQueueMessage message) throws FrameworkException, ApplicationExceptions {
SoaEventInfo soaEventInfo = ConfigurationService.getInstance().getSoaEventInfo(message.getEventName());
if (soaEventInfo != null) {
for (InjectDomainFact injectDomainFact : soaEventInfo.getInjectDomainFact()) {
Object[] domainKeyValues = new Object[injectDomainFact.getDomainKey().size() + 1];
try {
// Create an array of key-fields to be used for retrieving the domain object
// NOTE: If support for non-String key-fields is needed, the following logic can be further enhanced
// to take the datatype of each parameter into consideration when creating the domainKeyValues array
domainKeyValues[0] = uow;
int counter = 0;
for (String domainKeyName : injectDomainFact.getDomainKey()) {
if (domainKeyName.length() > PREFIX_PARAMS.length() && domainKeyName.startsWith(PREFIX_PARAMS)) {
domainKeyName = domainKeyName.substring(domainKeyName.length());
}
domainKeyValues[++counter] = message.getHeaderParam(domainKeyName) != null ? message.getHeaderParam(domainKeyName).getValue() : null;
}
// Invoke the findByPK method to obtain the domain object
Object domainObject = findDomainObject(injectDomainFact.getDomainClass(), domainKeyValues);
if (domainObject != null)
interceptor.addFact(domainObject);
else {
if (log.isDebugEnabled())
log.debug("Instance of domain class " + injectDomainFact.getDomainClass() + " not found with the arguments " + Arrays.toString(domainKeyValues));
}
} catch (Exception e) {
throw ExceptionHelper.throwAFR(e);
} finally {
domainKeyValues = null;
}
}
}
}
use of org.jaffa.soa.services.configdomain.SoaEventInfo in project jaffa-framework by jaffa-projects.
the class SOAEventParam method validate.
// .//GEN-END:performPreDeleteReferentialIntegrity_1_be
// .//GEN-BEGIN:3_be
/**
* @clientCardinality 0..*
* @supplierCardinality 1
* @clientQualifier eventId
* @supplierQualifier eventId
* @link association
*/
/*#SOAEvent lnkSOAEvent;*/
// .//GEN-END:3_be
// All the custom code goes here//GEN-FIRST:custom
/**
* {@inheritDoc}
*/
@Override
public void validate() throws ApplicationExceptions, FrameworkException {
// Ensure that the eventId is specified
if (getEventId() == null)
throw new ApplicationExceptions(new MandatoryFieldException(SOAEventParamMeta.META_EVENT_ID.getLabelToken()));
// Log a WARNing message if the paramter is not documented in soa-events.xml
if (getName() != null && isModified(SOAEventParamMeta.NAME)) {
try {
SOAEvent soaEvent = getSOAEventObject();
SoaEventInfo soaEventInfo = ConfigurationService.getInstance().getSoaEventInfo(soaEvent.getEventName());
if (soaEventInfo != null) {
boolean foundParam = false;
for (Param param : soaEventInfo.getParam()) {
if (getName().equals(param.getName())) {
foundParam = true;
break;
}
}
if (!foundParam)
log.warn("SOA Event Parameter'" + soaEvent.getEventName() + ": " + getName() + "' should be documented in soa-events.xml");
}
} catch (ValidationException e) {
throw new ApplicationExceptions(e);
}
}
super.validate();
}
use of org.jaffa.soa.services.configdomain.SoaEventInfo in project jaffa-framework by jaffa-projects.
the class SoaEventManager method registerResource.
/**
* {@inheritDoc}
*/
@Override
public void registerResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
SoaEvents soaEvents = JAXBHelper.unmarshalConfigFile(SoaEvents.class, resource, CONFIGURATION_SCHEMA_FILE);
if (soaEvents != null) {
for (SoaEventInfo soaEventInfo : soaEvents.getSoaEvent()) {
ContextKey contextKey = new ContextKey(soaEventInfo.getName(), resource.getURI().toString(), variation, context);
registerSoaEventInfo(contextKey, soaEventInfo);
}
}
}
use of org.jaffa.soa.services.configdomain.SoaEventInfo in project jaffa-framework by jaffa-projects.
the class SOAEventMetaDataService method createTree.
/**
* @return JSONArray.
*/
private JSONArray createTree() throws JAXBException, MalformedURLException {
JSONArray array = new JSONArray();
// get all of the SOA events
List<SoaEventInfo> soaEvents = getSoaEventInfo();
// create a root node for the tree
TreeNode globalRoot = new TreeNode("SOA Events");
globalRoot.setLeaf(false);
globalRoot.setUniqueName("SOA_EVENTS");
// get the default event state and the list of all events that are not in the default state
final boolean areEventsEnabledByDefault = SOAEventEnabledConfigurationFactory.instance().areEventsEnabledByDefault();
final List<String> eventsInNonDefaultState = SOAEventEnabledConfigurationFactory.instance().getEventsInNonDefaultState();
// create a tree node for each SOA event
for (SoaEventInfo soaEvent : soaEvents) {
String[] chain = null;
if (soaEvent.getName().indexOf("_") > 0) {
chain = soaEvent.getName().split("_");
} else {
chain = soaEvent.getName().split("\\.");
}
TreeNode currentNode = null;
// create a tree node for each level of chaining in the event's name
for (int j = 0; j < chain.length; j++) {
TreeNode wantedNode = new TreeNode(chain[j]);
wantedNode.setSoaEventName(soaEvent.getName());
wantedNode.setLabel(soaEvent.getLabel());
wantedNode.setDescription(soaEvent.getDescription());
wantedNode.setSoaEventParams(getParams(soaEvent));
// set the unique name of this tree node, this is the chain of parent node names and this node's name
StringBuilder sb = new StringBuilder();
for (int k = 0; k <= j; k++) {
// add an underscore after the first node name in the chain
if (k > 0) {
sb.append("_");
}
// append the node name from the chain of node names
sb.append(chain[k]);
}
wantedNode.setUniqueName(sb.toString());
// set the isEnabled value on the tree node so we can use it to filter visibility
if (areEventsEnabledByDefault && eventsInNonDefaultState.contains(soaEvent.getName())) {
wantedNode.setIsEnabled(false);
} else if (!areEventsEnabledByDefault && !eventsInNonDefaultState.contains(soaEvent.getName())) {
wantedNode.setIsEnabled(false);
} else {
wantedNode.setIsEnabled(true);
}
// else, set the icon based on the isEnabled flag of the event
if (j < (chain.length - 1)) {
wantedNode.setIconCls("copy");
wantedNode.setIsSelectable(false);
} else if (wantedNode.getIsEnabled()) {
wantedNode.setIconCls("icon-filter-enabled");
wantedNode.setIsSelectable(true);
} else {
wantedNode.setIconCls("icon-filter-disabled");
wantedNode.setIsSelectable(true);
}
if (j == 0) {
for (int k = 0; k < globalRoot.getChild().size(); k++) {
if (wantedNode.getText().equals(globalRoot.getChild().get(k).getText())) {
currentNode = globalRoot.getChild().get(k);
break;
} else {
if (k == globalRoot.getChild().size() - 1) {
globalRoot.addChild(wantedNode);
currentNode = wantedNode;
}
}
}
if (globalRoot.getChild().isEmpty()) {
globalRoot.addChild(wantedNode);
currentNode = wantedNode;
}
} else {
if (currentNode.getChild() == null || currentNode.getChild().isEmpty()) {
currentNode.addChild(wantedNode);
currentNode = wantedNode;
}
for (int k = 0; k < currentNode.getChild().size(); k++) {
if (wantedNode.getText().equals(currentNode.getChild().get(k).getText())) {
currentNode = currentNode.getChild().get(k);
break;
} else {
if (k == currentNode.getChild().size() - 1) {
currentNode.addChild(wantedNode);
currentNode = wantedNode;
}
}
}
}
}
}
array.add(globalRoot.toJson());
return array;
}
use of org.jaffa.soa.services.configdomain.SoaEventInfo in project jaffa-framework by jaffa-projects.
the class SoaEventManager method unregisterResource.
/**
* {@inheritDoc}
*/
@Override
public void unregisterResource(Resource resource, String context, String variation) throws JAXBException, SAXException, IOException {
SoaEvents soaEvents = JAXBHelper.unmarshalConfigFile(SoaEvents.class, resource, CONFIGURATION_SCHEMA_FILE);
if (soaEvents != null) {
for (SoaEventInfo soaEventInfo : soaEvents.getSoaEvent()) {
ContextKey contextKey = new ContextKey(soaEventInfo.getName(), resource.getURI().toString(), variation, context);
unregisterSoaEventInfo(contextKey);
}
}
}
Aggregations