use of org.mifos.application.master.business.StateEntity in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleAccountStateObjectsForLoan.
private List<AccountStateEntity> retrieveNextPossibleAccountStateObjectsForLoan(StateEntity accountStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleAccountStateObjectsForLoan()");
List<AccountStateEntity> stateEntityList = new ArrayList<AccountStateEntity>();
try {
List<StateEntity> stateList = statesMapForLoan.get(accountStateEntityObj);
if (null != stateList) {
for (StateEntity accountStateEntity : stateList) {
for (AccountStateEntity accountStateEnty : accountStateEntityListForLoan) {
if (accountStateEntity.sameId(accountStateEnty)) {
stateEntityList.add(accountStateEnty);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
use of org.mifos.application.master.business.StateEntity in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleCustomerStateForClient.
private List<CustomerStatusEntity> retrieveNextPossibleCustomerStateForClient(StateEntity customerStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleCustomerStateForClient()");
List<CustomerStatusEntity> stateEntityList = new ArrayList<CustomerStatusEntity>();
try {
List<StateEntity> stateList = statesMapForClient.get(customerStateEntityObj);
if (null != stateList) {
for (StateEntity customerStateEntity : stateList) {
for (CustomerStatusEntity customerStatusEntry : customerStatusListForClient) {
if (customerStatusEntry.sameId(customerStateEntity)) {
stateEntityList.add(customerStatusEntry);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
use of org.mifos.application.master.business.StateEntity in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleCustomerStateForGroup.
private List<CustomerStatusEntity> retrieveNextPossibleCustomerStateForGroup(StateEntity customerStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleCustomerStateForGroup()");
List<CustomerStatusEntity> stateEntityList = new ArrayList<CustomerStatusEntity>();
try {
List<StateEntity> stateList = statesMapForGroup.get(customerStateEntityObj);
if (null != stateList) {
for (StateEntity customerStateEntity : stateList) {
for (CustomerStatusEntity customerStatusEntry : customerStatusListForGroup) {
if (customerStatusEntry.sameId(customerStateEntity)) {
stateEntityList.add(customerStatusEntry);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
use of org.mifos.application.master.business.StateEntity in project head by mifos.
the class StateXMLParser method loadMapFromXml.
public Map<StateEntity, List<StateEntity>> loadMapFromXml(String filename, String configurationName) {
Map<StateEntity, List<StateEntity>> transitionMap = new HashMap<StateEntity, List<StateEntity>>();
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
factory.setValidating(true);
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
// Specify our own schema - this overrides the schemaLocation in the
// xml file
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "StateMachine.xsd");
DocumentBuilder builder = factory.newDocumentBuilder();
builder.setErrorHandler(null);
Document document = builder.parse(MifosResourceUtil.getClassPathResourceAsStream(filename));
Node mapToprocess = null;
/*
* String configurationName = ""; if
* (stateConfiguration=="configuration1") configurationName = "1";
* else configurationName = "2";
*/
NodeList configMaps = document.getElementsByTagName("stateConfiguration");
for (int m = 0; m < configMaps.getLength(); m++) {
Node stateConfiguration = configMaps.item(m);
if (configurationName.equals(stateConfiguration.getAttributes().getNamedItem("configurationName").getNodeValue())) {
mapToprocess = stateConfiguration;
}
}
// NodeList stateList = firstChild.getChildNodes();
NodeList stateList = mapToprocess.getChildNodes();
for (int i = 0; i < stateList.getLength(); i++) {
// each state has state id and possiblestates as childern
Node state = stateList.item(i);
// iterate for each child of state
NodeList stateInfoList = state.getChildNodes();
StateEntity currentState = null;
List<StateEntity> currntPossibleStates = new ArrayList<StateEntity>();
for (int j = 0; j < stateInfoList.getLength(); j++) {
Node info = stateInfoList.item(j);
if ("stateid".equals(info.getLocalName())) {
Element ele = (Element) info;
currentState = new StateEntity(Short.valueOf(((Text) ele.getFirstChild()).getData()));
}
if ("possiblestates".equals(info.getLocalName())) {
// get all the childern
NodeList allStates = info.getChildNodes();
currntPossibleStates = new ArrayList<StateEntity>();
for (int k = 0; k < allStates.getLength(); k++) {
Node infoState = allStates.item(k);
NodeList eachPossiblechild = infoState.getChildNodes();
for (int l = 0; l < eachPossiblechild.getLength(); l++) {
Node eachPossiblechildelement = eachPossiblechild.item(l);
if ("stateid".equals(eachPossiblechildelement.getLocalName())) {
Element element = (Element) eachPossiblechildelement;
Short possibleTrantionId = Short.valueOf(((Text) element.getFirstChild()).getData());
currntPossibleStates.add(new StateEntity(possibleTrantionId));
}
}
}
}
}
if (currentState != null) {
transitionMap.put(currentState, currntPossibleStates);
}
}
} catch (ParserConfigurationException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (SAXParseException e) {
throw new RuntimeException(e);
} catch (SAXException e) {
throw new RuntimeException(e);
}
return transitionMap;
}
use of org.mifos.application.master.business.StateEntity in project head by mifos.
the class AccountStateMachines method retrieveNextPossibleAccountStateObjectsForSavings.
private List<AccountStateEntity> retrieveNextPossibleAccountStateObjectsForSavings(StateEntity accountStateEntityObj) throws ApplicationException {
logger.debug("In AccountStateMachines::retrieveNextPossibleAccountStateObjectsForSavings()");
List<AccountStateEntity> stateEntityList = new ArrayList<AccountStateEntity>();
try {
List<StateEntity> stateList = statesMapForSavings.get(accountStateEntityObj);
if (null != stateList) {
for (StateEntity accountStateEntity : stateList) {
for (AccountStateEntity accountStateEnty : accountStateEntityListForSavings) {
if (accountStateEntity.sameId(accountStateEnty)) {
stateEntityList.add(accountStateEnty);
break;
}
}
}
}
return stateEntityList;
} catch (Exception e) {
throw new StatesInitializationException(SavingsConstants.STATEINITIALIZATION_EXCEPTION, e);
}
}
Aggregations