Skip to content

Commit

Permalink
TACKLE-58: application importer (#57)
Browse files Browse the repository at this point in the history
* TACKLE-58: moved into application-inventory

* TACKLE-58: tag type and business service controls endpoint integration

* TACKLE-58: moved MultipartImportBody and added RestClient annotation in tests

* TACKLE-58: merge marco's PR

* TACKLE-58: rollback local changes

* TACKLE-58: test isvalid filter

* TACKLE-58: set default isvalid value

* TACKLE-58: tidying up imports

* TACKLE-58: added filename to import entity db table

* TACKLE-58: alter test expected numbers to tally with altered numbers on db

* TACKLE-58: fix merge conflict test error

* TACKLE-58: delete test application imports after each test method to fix cross-method data contamination

* TACKLE-58: increase test coverage

* TACKLE-58: validate tag and business service input plus test

* TACKLE-58: validation and errors

* TACKLE-58: change endpoint url to application-import

* TACKLE-58: rename flyway scripts

* TACKLE-58: alter flyway test to match altered script names

* TACKLE-58: token propagation to TagType call to controls

* TACKLE-58 add more tests

* TACKLE-58: increase limit to number of items returned by controls services

* TACKLE-58: up to 20 tags and tag types allowed

* TACKLE-58: add test coverage

* TACKLE-58: more code test coverage

* TACKLE-58: added new endpoints to USAGE.md

* TACKLE-58: adding new summary endpoint

* TACKLE-58: summary endpoint fixed data retieval

* TACKLE-58: new endpoint hal enabled

* Workaround to have a list of ImportSummaryDto wrapped in HAL response (#3)

* TACKLE-58: parent record

* TACKLE-58: summary sql use parentId group by

* TACKLE-58: new import-summary entity

* TACKLE-58: fix transaction problems with duplicates

* TACKLE-58: valid & invalid counts on import-summary

* TACKLE-58: add importTime field to importSummary

* TACKLE-58: importTime set on creation

* TACKLE-58: csv export endpoint

* TACKLE-58: filter application-import by importSummary.id

* TACKLE-58: remove sub- objects from json

* TACKLE-58: fix duplicates in file causing file status FAILED

* TACKLE-58: fix bug in lambda function which threw an exception and caused failed status incorrectly

* TACKLE-58: ensure test cleans up after itself

* TACKLE-58: increase code test coverage

* TACKLE-58: test coverage and csv export only retrieve invalid rows

* TACKLE-58: prevent csv fields alphabetical sort

* Jackson Mix-In approach for CSV export (#4)

* Jackson Mix-In approach for CSV export

* Update ApplicationImportForCsv.java

enable native reflection in quarkus for csvmapper to work with ApplicationImportForCsv

Co-authored-by: Mark Brophy <[email protected]>

* TACKLE-58 fix forgotten mport class

Co-authored-by: mrizzi <[email protected]>
Co-authored-by: Marco Rizzi <[email protected]>
  • Loading branch information
3 people authored Jun 25, 2021
1 parent 67771d4 commit a5629f3
Show file tree
Hide file tree
Showing 34 changed files with 2,243 additions and 2 deletions.
16 changes: 16 additions & 0 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,3 +123,19 @@ the payload obtained will look like this :
]
```

## `/file/upload` endpoint
This endpoint will upload a csv file of the format of this file:
`src/test/resources/sample_application_import.csv`

The upload process stores each row from the file as an ApplicationImport entity.
Each ApplicationImport is then used to attempt to create a new Application.

The endpoint expects a Multipart Form with these params:
`file`: the file to be imported, in json format.
`fileName`: A text identifier for the file to be stored under.

## `/application-import` endpoint
This endpoint can be used to retrieve ApplicationImports. The results retrieved can be filtered by
`isValid=false` or `isValid=true` to view those imports which have either failed or succeeded,
and by `filename=your_filename` to view results for a specific import attempt.

39 changes: 39 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,14 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-multipart</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-csv</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-openapi</artifactId>
Expand Down Expand Up @@ -105,6 +113,18 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-token-propagation</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-keycloak-authorization</artifactId>
Expand Down Expand Up @@ -166,6 +186,17 @@
<version>2.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.8.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5-mockito</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -199,6 +230,14 @@
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>10</source>
<target>10</target>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.tackle.applicationinventory;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

@JsonIgnoreProperties(ignoreUnknown = true)
public class BusinessService {
public String id;
public String name;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.tackle.applicationinventory;

import javax.ws.rs.FormParam;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.annotations.providers.multipart.PartType;

public class MultipartImportBody {
@FormParam("file")
@PartType(MediaType.APPLICATION_JSON)
private String file;
@FormParam("fileName")
@PartType(MediaType.TEXT_PLAIN)
private String fileName;

public MultipartImportBody() {}


public void setFile(String file)
{
this.file = file;
}

public void setFilename(String fileName)
{
this.fileName = fileName;
}

public String getFile() {
return file;
}

public String getFileName() {
return fileName;
}
}
17 changes: 17 additions & 0 deletions src/main/java/io/tackle/applicationinventory/Tag.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.tackle.applicationinventory;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
public class Tag {
public String id;
public String name;
public TagType tagType;

public static class TagType {
public String id;
public String name;
}
}
Loading

0 comments on commit a5629f3

Please sign in to comment.