Search in sources :

Example 1 with FileRef

use of org.openlca.ilcd.sources.FileRef in project olca-modules by GreenDelta.

the class SourceExport method addFileRef.

private void addFileRef(DataSetInfo info, File extFile) {
    FileRef fileRef = new FileRef();
    fileRef.uri = "../external_docs/" + extFile.getName();
    info.files.add(fileRef);
}
Also used : FileRef(org.openlca.ilcd.sources.FileRef)

Example 2 with FileRef

use of org.openlca.ilcd.sources.FileRef in project olca-modules by GreenDelta.

the class SourceBag method getExternalFileURIs.

public List<String> getExternalFileURIs() {
    DataSetInfo info = getDataSetInformation();
    if (info == null)
        return Collections.emptyList();
    List<FileRef> refs = info.files;
    List<String> uris = new ArrayList<>();
    for (FileRef ref : refs) {
        if (ref.uri != null)
            uris.add(ref.uri);
    }
    return uris;
}
Also used : FileRef(org.openlca.ilcd.sources.FileRef) ArrayList(java.util.ArrayList) LangString(org.openlca.ilcd.commons.LangString) DataSetInfo(org.openlca.ilcd.sources.DataSetInfo)

Example 3 with FileRef

use of org.openlca.ilcd.sources.FileRef in project olca-modules by GreenDelta.

the class SourceWithFileTest method addFileLink.

private void addFileLink(Source source, File file) {
    FileRef ref = new FileRef();
    ref.uri = "../external_docs/" + file.getName();
    source.sourceInfo.dataSetInfo.files.add(ref);
}
Also used : FileRef(org.openlca.ilcd.sources.FileRef)

Example 4 with FileRef

use of org.openlca.ilcd.sources.FileRef in project olca-modules by GreenDelta.

the class SourcesFileNameTest method testWebPath.

@Test
public void testWebPath() {
    FileRef ref = new FileRef();
    ref.uri = "http://mysoda.com/external_docs/mydoc.pdf";
    assertEquals("mydoc.pdf", Sources.getFileName(ref));
}
Also used : FileRef(org.openlca.ilcd.sources.FileRef) Test(org.junit.Test)

Example 5 with FileRef

use of org.openlca.ilcd.sources.FileRef in project olca-modules by GreenDelta.

the class SourcesFileNameTest method testRelativePath.

@Test
public void testRelativePath() {
    FileRef ref = new FileRef();
    ref.uri = "../external_docs/mydoc.pdf";
    assertEquals("mydoc.pdf", Sources.getFileName(ref));
    ref.uri = "..\\external_docs\\mydoc.pdf";
    assertEquals("mydoc.pdf", Sources.getFileName(ref));
}
Also used : FileRef(org.openlca.ilcd.sources.FileRef) Test(org.junit.Test)

Aggregations

FileRef (org.openlca.ilcd.sources.FileRef)7 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)1 LangString (org.openlca.ilcd.commons.LangString)1 DataSetInfo (org.openlca.ilcd.sources.DataSetInfo)1