Fix: Provide header flag for timetracking entries

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2019-08-25 11:43:17 +02:00
parent 8852a2b3ba
commit f4fa8b71dd
4 changed files with 18 additions and 3 deletions

View file

@ -32,3 +32,4 @@ libimagerror = { version = "0.10.0", path = "../../../lib/core/libimager
libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" } libimagstore = { version = "0.10.0", path = "../../../lib/core/libimagstore" }
libimagentrydatetime = { version = "0.10.0", path = "../../../lib/entry/libimagentrydatetime" } libimagentrydatetime = { version = "0.10.0", path = "../../../lib/entry/libimagentrydatetime" }
libimagentrytag = { version = "0.10.0", path = "../../../lib/entry/libimagentrytag" } libimagentrytag = { version = "0.10.0", path = "../../../lib/entry/libimagentrytag" }
libimagentryutil = { version = "0.10.0", path = "../../../lib/entry/libimagentryutil" }

View file

@ -47,8 +47,8 @@ extern crate lazy_static;
extern crate is_match; extern crate is_match;
#[macro_use] extern crate failure; #[macro_use] extern crate failure;
#[macro_use] #[macro_use] extern crate libimagstore;
extern crate libimagstore; #[macro_use] extern crate libimagentryutil;
extern crate libimagentrydatetime; extern crate libimagentrydatetime;
extern crate libimagentrytag; extern crate libimagentrytag;
extern crate libimagerror; extern crate libimagerror;

View file

@ -32,10 +32,11 @@ use failure::Error;
use libimagstore::store::Store; use libimagstore::store::Store;
use libimagstore::store::FileLockEntry; use libimagstore::store::FileLockEntry;
use libimagentrydatetime::datepath::compiler::DatePathCompiler; use libimagentrydatetime::datepath::compiler::DatePathCompiler;
use libimagentryutil::isa::Is;
use crate::constants::*; use crate::constants::*;
use crate::iter::get::TimeTrackingsGetIterator; use crate::iter::get::TimeTrackingsGetIterator;
use crate::timetracking::IsTimeTracking;
use crate::tag::TimeTrackingTag as TTT; use crate::tag::TimeTrackingTag as TTT;
pub trait TimeTrackStore<'a> { pub trait TimeTrackStore<'a> {
@ -93,6 +94,9 @@ impl<'a> TimeTrackStore<'a> for Store {
.map_err(Error::from) .map_err(Error::from)
.map(|_| fle) .map(|_| fle)
}) })
.and_then(|mut fle| {
fle.set_isflag::<IsTimeTracking>().map(|_| fle)
})
} }
fn create_timetracking(&'a self, start: &NDT, end: &NDT, ts: &TTT) -> Result<FileLockEntry<'a>> { fn create_timetracking(&'a self, start: &NDT, end: &NDT, ts: &TTT) -> Result<FileLockEntry<'a>> {

View file

@ -28,6 +28,8 @@ use chrono::naive::NaiveDateTime;
use libimagstore::store::Entry; use libimagstore::store::Entry;
use libimagerror::errors::ErrorMsg as EM; use libimagerror::errors::ErrorMsg as EM;
use libimagentryutil::isa::Is;
use libimagentryutil::isa::IsKindHeaderPathProvider;
use crate::tag::TimeTrackingTag as TTT; use crate::tag::TimeTrackingTag as TTT;
use crate::constants::*; use crate::constants::*;
@ -40,8 +42,12 @@ use failure::Fallible as Result;
use failure::ResultExt; use failure::ResultExt;
use failure::Error; use failure::Error;
provide_kindflag_path!(pub IsTimeTracking, "timetrack.is_timetracking");
pub trait TimeTracking { pub trait TimeTracking {
fn is_timetracking(&self) -> Result<bool>;
fn get_timetrack_tag(&self) -> Result<TTT>; fn get_timetrack_tag(&self) -> Result<TTT>;
fn set_start_datetime(&mut self, dt: NaiveDateTime) -> Result<()>; fn set_start_datetime(&mut self, dt: NaiveDateTime) -> Result<()>;
@ -62,6 +68,10 @@ pub trait TimeTracking {
impl TimeTracking for Entry { impl TimeTracking for Entry {
fn is_timetracking(&self) -> Result<bool> {
self.is::<IsTimeTracking>().map_err(From::from)
}
fn get_timetrack_tag(&self) -> Result<TTT> { fn get_timetrack_tag(&self) -> Result<TTT> {
self.get_header() self.get_header()
.read_string(DATE_TIME_TAG_HEADER_PATH) .read_string(DATE_TIME_TAG_HEADER_PATH)