forked from InseeFr/Eno
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from laurentC35/multi-model
Multi model
- Loading branch information
Showing
33 changed files
with
22,307 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: Upload Release Asset | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
- name: Build with Maven | ||
run: mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Djar.finalName="eno-core" -B -V --file pom.xml | ||
- name: Test with Maven | ||
run: mvn test -B --file pom.xml | ||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Release ${{ github.ref }} | ||
draft: false | ||
prerelease: false | ||
- name: Upload Release Asset | ||
id: upload-release-asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps | ||
asset_path: target/eno-core.jar | ||
asset_name: eno-core.jar | ||
asset_content_type: application/java-archive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
src/main/java/fr/insee/eno/preprocessing/DDISplittingPreprocessor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
package fr.insee.eno.preprocessing; | ||
|
||
import java.io.File; | ||
import java.io.FilenameFilter; | ||
import java.io.InputStream; | ||
import java.io.OutputStream; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import fr.insee.eno.Constants; | ||
import fr.insee.eno.exception.EnoGenerationException; | ||
import fr.insee.eno.transform.xsl.XslTransformation; | ||
|
||
/** | ||
* A DDI specific preprocessor. | ||
*/ | ||
public class DDISplittingPreprocessor { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(DDISplittingPreprocessor.class); | ||
|
||
private XslTransformation saxonService = new XslTransformation(); | ||
|
||
public List<File> splitDDI(File inputFile, String survey) throws Exception { | ||
LOGGER.info("DDI splitting preprocessing Target : START"); | ||
|
||
String sUB_TEMP_FOLDER = Constants.sUB_TEMP_FOLDER(survey); | ||
// ----- Dereferencing | ||
LOGGER.debug("Dereferencing : -Input : " + inputFile + " -Output : " + Constants.tEMP_NULL_TMP(sUB_TEMP_FOLDER) | ||
+ " -Stylesheet : " + Constants.UTIL_DDI_SPLITTING_XSL + " -Parameters : " + sUB_TEMP_FOLDER); | ||
|
||
InputStream isDDI_DEREFERENCING_XSL = Constants.getInputStreamFromPath(Constants.UTIL_DDI_SPLITTING_XSL); | ||
InputStream isInputFile = FileUtils.openInputStream(inputFile); | ||
OutputStream osTEMP_NULL_TMP = FileUtils.openOutputStream(Constants.tEMP_NULL_TMP(sUB_TEMP_FOLDER)); | ||
|
||
try { | ||
saxonService.transformDereferencing(isInputFile, isDDI_DEREFERENCING_XSL, osTEMP_NULL_TMP, | ||
Constants.sUB_TEMP_FOLDER_FILE(survey)); | ||
}catch(Exception e) { | ||
throw new EnoGenerationException("An error was occured during the " + toString() + " transformation. "+e.getMessage()); | ||
} | ||
|
||
isInputFile.close(); | ||
isDDI_DEREFERENCING_XSL.close(); | ||
osTEMP_NULL_TMP.close(); | ||
// ----- Cleaning | ||
LOGGER.debug("Cleaning target"); | ||
File f = Constants.sUB_TEMP_FOLDER_FILE(survey); | ||
File[] matchCleaningInput = f.listFiles(new FilenameFilter() { | ||
|
||
@Override | ||
public boolean accept(File dir, String name) { | ||
return !name.startsWith("null"); | ||
} | ||
}); | ||
|
||
List<File> outputFiles = new ArrayList<File>(); | ||
|
||
LOGGER.debug("Searching matching files in : " + sUB_TEMP_FOLDER); | ||
for (File file : matchCleaningInput) { | ||
if(!file.isDirectory()) { | ||
LOGGER.debug("Found : " + file.getAbsolutePath()); | ||
outputFiles.add(file); | ||
} | ||
} | ||
if(outputFiles.size()==0) { | ||
throw new EnoGenerationException("DDI Splitting produced no file."); | ||
} | ||
|
||
LOGGER.debug("DDI splitting preprocessing : END"); | ||
return outputFiles; | ||
} | ||
|
||
public String toString() { | ||
return "DDI splitting preprocessor"; | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.