Search in sources :

Example 46 with Action

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();
}
Also used : Action(com.opensymphony.xwork2.Action)

Example 47 with Action

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());
}
Also used : Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField) Action(io.atlasmap.v2.Action) AddDays(io.atlasmap.v2.AddDays) ZonedDateTime(java.time.ZonedDateTime) SimpleField(io.atlasmap.v2.SimpleField) Test(org.junit.jupiter.api.Test)

Example 48 with Action

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());
}
Also used : Field(io.atlasmap.v2.Field) SimpleField(io.atlasmap.v2.SimpleField) Action(io.atlasmap.v2.Action) FieldGroup(io.atlasmap.v2.FieldGroup) Uppercase(io.atlasmap.v2.Uppercase) SimpleField(io.atlasmap.v2.SimpleField) Test(org.junit.jupiter.api.Test)

Example 49 with Action

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));
}
Also used : Action(io.atlasmap.v2.Action) Trim(io.atlasmap.v2.Trim) GenerateUUID(io.atlasmap.v2.GenerateUUID) ActionProcessor(io.atlasmap.spi.ActionProcessor) Test(org.junit.jupiter.api.Test)

Example 50 with Action

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;
}
Also used : AtlasMapping(io.atlasmap.v2.AtlasMapping) Action(io.atlasmap.v2.Action) StringList(io.atlasmap.v2.StringList) Mapping(io.atlasmap.v2.Mapping) AtlasMapping(io.atlasmap.v2.AtlasMapping)

Aggregations

ActionSupport (com.opensymphony.xwork2.ActionSupport)61 List (java.util.List)40 Action (io.atlasmap.v2.Action)35 ArrayList (java.util.ArrayList)23 Test (org.junit.jupiter.api.Test)16 Content (com.agiletec.plugins.jacms.aps.system.services.content.model.Content)14 SimpleField (io.atlasmap.v2.SimpleField)13 Field (io.atlasmap.v2.Field)12 Mapping (io.atlasmap.v2.Mapping)11 ActionContext (com.opensymphony.xwork2.ActionContext)9 AtlasMapping (io.atlasmap.v2.AtlasMapping)9 Collections (java.util.Collections)9 HashMap (java.util.HashMap)9 SettableApiFuture (com.google.api.core.SettableApiFuture)8 ServiceOptions (com.google.cloud.ServiceOptions)8 DlpServiceClient (com.google.cloud.dlp.v2.DlpServiceClient)8 Subscriber (com.google.cloud.pubsub.v1.Subscriber)8 Action (com.google.privacy.dlp.v2.Action)8 BigQueryTable (com.google.privacy.dlp.v2.BigQueryTable)8 CreateDlpJobRequest (com.google.privacy.dlp.v2.CreateDlpJobRequest)8