Search in sources :

Example 1 with ActionDetails

use of io.atlasmap.v2.ActionDetails in project atlasmap by atlasmap.

the class DefaultAtlasFieldActionsServiceTest method testListActionDetails.

@Test
public void testListActionDetails() {
    assertNotNull(fieldActionsService);
    List<ActionDetail> actionDetails = fieldActionsService.listActionDetails();
    for (ActionDetail d : actionDetails) {
        if (d.getParameters() != null) {
            System.out.println("Action: " + d.getName());
            for (ActionParameter param : d.getParameters().getParameter()) {
                System.out.println("\t param: " + param.getName());
                System.out.println("\t type: " + param.getFieldType().value());
            }
        }
    }
}
Also used : ActionDetail(io.atlasmap.v2.ActionDetail) ActionParameter(io.atlasmap.v2.ActionParameter) Test(org.junit.jupiter.api.Test)

Example 2 with ActionDetails

use of io.atlasmap.v2.ActionDetails in project atlasmap by atlasmap.

the class GenerateFieldActionsMojo method generateFieldAction.

private void generateFieldAction(List<URL> urls) throws MojoFailureException, MojoExecutionException {
    DefaultAtlasFieldActionService fieldActionService = DefaultAtlasFieldActionService.getInstance();
    ClassLoader origTccl = Thread.currentThread().getContextClassLoader();
    ActionDetails answer = new ActionDetails();
    try (URLClassLoader loader = new URLClassLoader(urls.toArray(new URL[urls.size()]), origTccl)) {
        fieldActionService.init(loader);
    } catch (Exception e) {
        throw new MojoExecutionException("Could not load field actions:", e);
    }
    answer.getActionDetail().addAll(fieldActionService.listActionDetails());
    writeToJsonFile(DEFAULT_OUTPUT_FILE_PREFIX, answer);
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) URLClassLoader(java.net.URLClassLoader) URLClassLoader(java.net.URLClassLoader) ActionDetails(io.atlasmap.v2.ActionDetails) DefaultAtlasFieldActionService(io.atlasmap.core.DefaultAtlasFieldActionService) URL(java.net.URL) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Example 3 with ActionDetails

use of io.atlasmap.v2.ActionDetails in project atlasmap by atlasmap.

the class AtlasService method listFieldActions.

/**
 * Retrieves a list of available field action.
 * @param uriInfo URI info
 * @return {@link ActionDetails} serialized to JSON
 */
@GET
@Path("/fieldActions")
@Produces(MediaType.APPLICATION_JSON)
@Operation(summary = "List FieldActions", description = "Retrieves a list of available field action")
@ApiResponses(@ApiResponse(responseCode = "200", content = @Content(schema = @Schema(implementation = ActionDetails.class)), description = "Return a list of field action detail"))
public Response listFieldActions(@Context UriInfo uriInfo) {
    ActionDetails details = new ActionDetails();
    if (atlasContextFactory == null || atlasContextFactory.getFieldActionService() == null) {
        return Response.ok().entity(toJson(details)).build();
    }
    details.getActionDetail().addAll(atlasContextFactory.getFieldActionService().listActionDetails());
    byte[] serialized = toJson(details);
    if (LOG.isDebugEnabled()) {
        LOG.debug(new String(serialized));
    }
    return Response.ok().entity(serialized).build();
}
Also used : ActionDetails(io.atlasmap.v2.ActionDetails) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Operation(io.swagger.v3.oas.annotations.Operation) ApiResponses(io.swagger.v3.oas.annotations.responses.ApiResponses)

Aggregations

ActionDetails (io.atlasmap.v2.ActionDetails)2 DefaultAtlasFieldActionService (io.atlasmap.core.DefaultAtlasFieldActionService)1 ActionDetail (io.atlasmap.v2.ActionDetail)1 ActionParameter (io.atlasmap.v2.ActionParameter)1 Operation (io.swagger.v3.oas.annotations.Operation)1 ApiResponses (io.swagger.v3.oas.annotations.responses.ApiResponses)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 Test (org.junit.jupiter.api.Test)1