Search in sources :

Example 6 with WorkLocation

use of se.light.assembly64.model.WorkLocation in project assembly64fx by freabemania.

the class LocalDBService method getWorkLocations.

public List<WorkLocation> getWorkLocations(boolean forceUpdate) throws RuntimeException {
    if (workLocations != null && !forceUpdate) {
        return workLocations;
    }
    try {
        File file = pathService.getWorkLocationsFile();
        // bootstrap file
        if (!file.exists()) {
            storeWorkLocations(new ArrayList<>());
        }
        CollectionLikeType constructCollectionType = getObjectMapper().getTypeFactory().constructCollectionLikeType(ArrayList.class, WorkLocation.class);
        this.workLocations = getObjectMapper().readValue(FileUtils.readFileToString(file), constructCollectionType);
        return workLocations;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : CollectionLikeType(com.fasterxml.jackson.databind.type.CollectionLikeType) LocalStorageUtil.getSubdirOrFile(se.light.assembly64.util.LocalStorageUtil.getSubdirOrFile) File(java.io.File) IOException(java.io.IOException)

Aggregations

File (java.io.File)5 WorkLocation (se.light.assembly64.model.WorkLocation)5 RandomAccessFile (java.io.RandomAccessFile)3 FileChannel (java.nio.channels.FileChannel)2 FileLock (java.nio.channels.FileLock)2 ArrayList (java.util.ArrayList)2 Collections (java.util.Collections)2 List (java.util.List)2 Optional (java.util.Optional)2 Set (java.util.Set)2 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 Consumer (java.util.function.Consumer)2 Collectors (java.util.stream.Collectors)2 FadeTransition (javafx.animation.FadeTransition)2 Application (javafx.application.Application)2 Platform (javafx.application.Platform)2 ChangeListener (javafx.beans.value.ChangeListener)2 ObservableValue (javafx.beans.value.ObservableValue)2 ActionEvent (javafx.event.ActionEvent)2