use of org.jaffa.transaction.services.configdomain.TypeInfo in project jaffa-framework by jaffa-projects.
the class TransactionManager method unregisterXML.
/**
* unregisters all the transactions and typeInfo in the xml from the repository
* @param uri for the xml location
*/
public void unregisterXML(String uri, String context, String variation) throws JAXBException, SAXException, IOException {
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
Config config = JAXBHelper.unmarshalConfigFile(Config.class, resolver.getResource(uri), CONFIGURATION_SCHEMA_FILE);
if (config.getTransactionOrType() != null) {
for (final Object o : config.getTransactionOrType()) {
if (o.getClass() == TransactionInfo.class) {
final TransactionInfo transactionInfo = (TransactionInfo) o;
ContextKey contextKey = new ContextKey(transactionInfo.getDataBean(), uri, variation, context);
unregisterTransactionInfo(contextKey);
} else if (o.getClass() == TypeInfo.class) {
final TypeInfo typeInfo = (TypeInfo) o;
ContextKey contextKey = new ContextKey(typeInfo.getName(), uri, variation, context);
unregisterTypeInfo(contextKey);
}
}
}
}
use of org.jaffa.transaction.services.configdomain.TypeInfo in project jaffa-framework by jaffa-projects.
the class TransactionAdmin method createMessageGraph.
/**
* Molds the input Transaction into a MessageGraph.
*/
private static MessageGraph createMessageGraph(Transaction transaction, PropertyFilter pf) throws FrameworkException {
MessageGraph graph = new MessageGraph();
graph.setQueueMetaData(createQueueMetaData(transaction.getSubType(), pf));
if (pf.isFieldIncluded("type")) {
graph.setType(transaction.getType());
}
if (pf.isFieldIncluded("subType")) {
graph.setSubType(transaction.getSubType());
}
if (pf.isFieldIncluded("messageId")) {
graph.setMessageId(transaction.getId());
}
if (pf.isFieldIncluded("direction")) {
graph.setDirection(transaction.getDirection());
}
if (pf.isFieldIncluded("status")) {
graph.setStatus(transactionToMessageStatus(transaction.getStatus()));
}
if (pf.isFieldIncluded("createdOn")) {
graph.setCreatedOn(transaction.getCreatedOn());
}
if (pf.isFieldIncluded("createdBy")) {
graph.setCreatedBy(transaction.getCreatedBy());
}
if (pf.isFieldIncluded("lastChangedOn")) {
graph.setLastChangedOn(transaction.getLastChangedOn());
}
if (pf.isFieldIncluded("lastChangedBy")) {
graph.setLastChangedBy(transaction.getLastChangedBy());
}
if (pf.isFieldIncluded("errorMessage")) {
graph.setErrorMessage(transaction.getErrorMessage());
}
if (pf.isFieldIncluded("payload")) {
graph.setPayload(transaction.getTransactionPayloadObject() != null ? transaction.getTransactionPayloadObject().returnInternalPayload() : null);
}
if (pf.isFieldIncluded("hasAdminAccess")) {
graph.setHasAdminAccess(TransactionEngine.getInstance().hasAdminAccess(transaction.getType()));
}
if (pf.isFieldIncluded("applicationFields")) {
Map<String, MessageField> applicationFields = new LinkedHashMap<String, MessageField>();
TransactionField[] transactionFields = transaction.getTransactionFieldArray();
if (transactionFields != null && transactionFields.length > 0) {
for (int i = 0; i < transactionFields.length; i++) {
TransactionField transactionField = transactionFields[i];
MessageField applicationField = new MessageField();
applicationField.setName(transactionField.getFieldName());
applicationField.setValue(transactionField.getValue());
applicationFields.put(applicationField.getName(), applicationField);
}
}
// Add labels to the application-fields from the configuration-file
TypeInfo typeInfo = ConfigurationService.getInstance().getTypeInfo(transaction.getType());
if (typeInfo != null && typeInfo.getDisplayParam() != null) {
for (DisplayParam displayParam : typeInfo.getDisplayParam()) {
if (displayParam.getLabel() != null && applicationFields.containsKey(displayParam.getName())) {
applicationFields.get(displayParam.getName()).setLabel(MessageHelper.replaceTokens(displayParam.getLabel()));
}
}
}
if (!applicationFields.isEmpty()) {
graph.setApplicationFields(applicationFields.values().toArray(new MessageField[applicationFields.size()]));
}
}
if (pf.isFieldIncluded("messageDependencies")) {
TransactionDependency[] transactionDependencies = transaction.getTransactionDependencyArray();
if (transactionDependencies != null && transactionDependencies.length > 0) {
MessageDependency[] messageDependencies = new MessageDependency[transactionDependencies.length];
for (int i = 0; i < transactionDependencies.length; i++) {
TransactionDependency transactionDependency = transactionDependencies[i];
MessageDependency messageDependency = new MessageDependency();
messageDependency.setDependsOnId(transactionDependency.getDependsOnId());
if (transactionDependency.getStatus() != null) {
MessageDependency.Status messageDependencyStatus = null;
TransactionDependency.Status transactionDependencyStatus = TransactionDependency.Status.valueOf(transactionDependency.getStatus());
switch(transactionDependencyStatus) {
case O:
messageDependencyStatus = MessageDependency.Status.OPEN;
break;
case S:
messageDependencyStatus = MessageDependency.Status.SUCCESS;
break;
}
messageDependency.setStatus(messageDependencyStatus);
}
messageDependencies[i] = messageDependency;
}
graph.setMessageDependencies(messageDependencies);
}
}
return graph;
}
use of org.jaffa.transaction.services.configdomain.TypeInfo in project jaffa-framework by jaffa-projects.
the class TransactionEngine method getAccessibleTypeNamesWithLabels.
/**
* Returns an array of Transaction Types with Labels, as defined in the configuration file.
* The array will contain the accessible Types only.
*
* @return an array of Transaction Type names, as defined in the configuration file.
*/
public String[] getAccessibleTypeNamesWithLabels() {
String[] typeNames = ConfigurationService.getInstance().getTypeNames();
if (typeNames != null && typeNames.length > 0) {
List<String> accessibleTypeNames = new LinkedList<String>();
for (String typeName : typeNames) {
TypeInfo typeInfo = ConfigurationService.getInstance().getTypeInfo(typeName);
if (hasBrowseAccess(typeInfo)) {
accessibleTypeNames.add(typeInfo.getLabel() + "=" + typeName);
} else {
if (log.isDebugEnabled()) {
log.debug("No browse access to " + typeName);
}
}
}
typeNames = accessibleTypeNames.toArray(new String[accessibleTypeNames.size()]);
}
return typeNames;
}
use of org.jaffa.transaction.services.configdomain.TypeInfo in project jaffa-framework by jaffa-projects.
the class TransactionEngine method getAccessibleTypeNames.
/**
* Returns an array of Transaction Type names, as defined in the configuration file.
* The array will contain the accessible Types only.
*
* @return an array of Transaction Type names, as defined in the configuration file.
*/
public String[] getAccessibleTypeNames() {
String[] typeNames = ConfigurationService.getInstance().getTypeNames();
if (typeNames != null && typeNames.length > 0) {
List<String> accessibleTypeNames = new LinkedList<String>();
for (String typeName : typeNames) {
TypeInfo typeInfo = ConfigurationService.getInstance().getTypeInfo(typeName);
if (hasBrowseAccess(typeInfo)) {
accessibleTypeNames.add(typeName);
} else {
if (log.isDebugEnabled()) {
log.debug("No browse access to " + typeName);
}
}
}
typeNames = accessibleTypeNames.toArray(new String[accessibleTypeNames.size()]);
}
return typeNames;
}
use of org.jaffa.transaction.services.configdomain.TypeInfo in project jaffa-framework by jaffa-projects.
the class TransactionManagerTest method testUnRegisterTypeInfo.
/**
* tests the unregisterTypeInfo
*/
@Test
public void testUnRegisterTypeInfo() {
// initialize
TypeInfo typeInfo = new TypeInfo();
typeInfo.setName("typeInfoName");
ContextKey key = new ContextKey("typeInfoName", null, "DEF", "cust-code");
// test
transactionManager.unregisterTypeInfo(key);
// verify
verify(typeInfoRepoMock).unregister(eq(key));
}
Aggregations