jdplus.tramoseats.desktop.plugin.tramo.documents.TramoDocFileRepository Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdplus-tramoseats-desktop-plugin Show documentation
Show all versions of jdplus-tramoseats-desktop-plugin Show documentation
${project.parent.artifactId} - ${project.artifactId}
The newest version!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package jdplus.tramoseats.desktop.plugin.tramo.documents;
import jdplus.toolkit.base.api.DemetraVersion;
import jdplus.tramoseats.base.core.tramo.TramoDocument;
import jdplus.toolkit.desktop.plugin.workspace.AbstractFileItemRepository;
import jdplus.toolkit.desktop.plugin.workspace.WorkspaceItem;
import jdplus.toolkit.desktop.plugin.workspace.WorkspaceItemRepository;
import jdplus.toolkit.base.tsp.TsMeta;
import java.time.Clock;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import org.openide.util.lookup.ServiceProvider;
/**
*
* @author Jean Palate
*/
@ServiceProvider(service = WorkspaceItemRepository.class)
public final class TramoDocFileRepository extends AbstractFileItemRepository< TramoDocument > {
@Override
public boolean load(WorkspaceItem item) {
return loadFile(item, (TramoDocument o) -> {
o.setLocked(true);
item.setElement(o);
item.resetDirty();
});
}
@Override
public boolean save(WorkspaceItem doc, DemetraVersion version) {
TramoDocument element = doc.getElement();
Map meta=new HashMap<>(element.getMetadata());
TsMeta.TIMESTAMP.store(meta, LocalDateTime.now(Clock.systemDefaultZone()));
element.updateMetadata(meta);
return storeFile(doc, element, version, doc::resetDirty);
}
@Override
public boolean delete(WorkspaceItem doc) {
return deleteFile(doc);
}
@Override
public Class getSupportedType() {
return TramoDocument.class;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy