use of com.opensymphony.xwork2.Action in project dhis2-core by dhis2.
the class LoginInterceptor method intercept.
@Override
public String intercept(ActionInvocation invocation) throws Exception {
Boolean jli = (Boolean) ServletActionContext.getRequest().getSession().getAttribute(LoginInterceptor.JLI_SESSION_VARIABLE);
if (jli != null) {
log.debug("JLI marker is present. Running " + actions.size() + " JLI actions.");
for (Action a : actions) {
a.execute();
}
ServletActionContext.getRequest().getSession().removeAttribute(LoginInterceptor.JLI_SESSION_VARIABLE);
}
return invocation.invoke();
}
use of com.opensymphony.xwork2.Action in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionAddDays.
@Test
public void testProcessActionAddDays() throws Exception {
DefaultAtlasSession session = mock(DefaultAtlasSession.class);
Field field = new SimpleField();
field.setFieldType(FieldType.DATE_TIME);
field.setPath("/date");
ZonedDateTime now = ZonedDateTime.now();
field.setValue(now);
field.setActions(new ArrayList<Action>());
AddDays action = new AddDays();
action.setDays(32);
field.getActions().add(action);
Field answer = fieldActionsService.processActions(session, field);
ZonedDateTime expected = now.plusDays(32);
assertEquals(ZonedDateTime.class, answer.getValue().getClass());
ZonedDateTime actual = (ZonedDateTime) answer.getValue();
assertEquals(expected.getYear(), actual.getYear());
assertEquals(expected.getMonth(), actual.getMonth());
assertEquals(expected.getDayOfMonth(), actual.getDayOfMonth());
}
use of com.opensymphony.xwork2.Action in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionForEachCollectionItem.
@Test
public void testProcessActionForEachCollectionItem() throws Exception {
DefaultAtlasSession session = mock(DefaultAtlasSession.class);
FieldGroup fieldGroup = new FieldGroup();
Field field1 = new SimpleField();
field1.setPath("/fields<0>");
field1.setValue("one");
fieldGroup.getField().add(field1);
Field field2 = new SimpleField();
field2.setPath("/fields<1>");
field2.setValue("two");
fieldGroup.getField().add(field2);
Field field4 = new SimpleField();
field4.setPath("/fields<3>");
field4.setValue("four");
fieldGroup.getField().add(field4);
Action action = new Uppercase();
fieldGroup.setActions(new ArrayList<Action>());
fieldGroup.getActions().add(action);
Field answer = fieldActionsService.processActions(session, fieldGroup);
assertEquals(FieldGroup.class, answer.getClass());
FieldGroup answerGroup = (FieldGroup) answer;
assertEquals(3, answerGroup.getField().size());
Field f = answerGroup.getField().get(0);
assertEquals("/fields<0>", f.getPath());
assertEquals("ONE", f.getValue());
f = answerGroup.getField().get(1);
assertEquals("/fields<1>", f.getPath());
assertEquals("TWO", f.getValue());
f = answerGroup.getField().get(2);
assertEquals("/fields<3>", f.getPath());
assertEquals("FOUR", f.getValue());
}
use of com.opensymphony.xwork2.Action in project atlasmap by atlasmap.
the class DefaultAtlasFieldActionsServiceTest method testProcessActionWithActionActionDetailObject.
@Test
public void testProcessActionWithActionActionDetailObject() throws AtlasException {
ActionProcessor processor = null;
Object sourceObject = "String";
Action action = new Trim();
processor = fieldActionsService.findActionProcessor(action, FieldType.STRING);
assertEquals(sourceObject, processor.process(action, sourceObject));
action = new GenerateUUID();
processor = fieldActionsService.findActionProcessor(action, FieldType.NONE);
assertNotNull(processor.process(action, sourceObject));
}
use of com.opensymphony.xwork2.Action in project atlasmap by atlasmap.
the class BaseMarshallerTest method generateAtlasMapping.
protected AtlasMapping generateAtlasMapping() {
AtlasMapping atlasMapping = AtlasModelFactory.createAtlasMapping();
atlasMapping.setName("junit");
generateXmlDataSource(atlasMapping);
generateLookupTables(atlasMapping);
ArrayList<Action> actions = generateactions();
StringList stringList = new StringList();
stringList.getString().add("XmlAccessorType");
stringList.getString().add("XmlType");
Restrictions restrictions = new Restrictions();
Restriction restriction = new Restriction();
restriction.setType(RestrictionType.LENGTH);
restriction.setValue("100");
restrictions.getRestriction().add(restriction);
Mapping mapping = AtlasModelFactory.createMapping(MappingType.MAP);
XmlField inputField = generateXmlField(actions, stringList, restrictions);
mapping.getInputField().add(inputField);
XmlField outputField = generateXmlField(actions, stringList, restrictions);
mapping.getOutputField().add(outputField);
mapping.setMappingType(MappingType.MAP);
mapping.setDelimiterString(",");
mapping.setAlias("MapPropertyFieldAlias");
mapping.setDelimiter(",");
mapping.setDescription("description");
mapping.setId("id");
mapping.setLookupTableName("lookupTableName");
mapping.setStrategy("strategy");
mapping.setStrategyClassName("strategyClassName");
atlasMapping.getMappings().getMapping().add(mapping);
generateProperties(atlasMapping);
return atlasMapping;
}
Aggregations