text:
use std::ptr;
use std::sync::atomic;
use std::sync::atomic::Ordering;

use ::state::{AtomicState, SlotState};
use ::key::{HashKey, djb2_hash, hashkey_to_string};

/// `IncrResult` is used to tell the caller if we need to retry the incr. This
/// should only happen if a resize begins in the middle of an increment
/// operation.
pub enum IncrResult {
    Current(usize),
    Outdated,
}

#[derive(Default)]
pub struct Slot {
    pub state: AtomicState<SlotState>,
    pub key: atomic::AtomicPtr<HashKey>,
    pub value: atomic::AtomicUsize,
}

impl Drop for Slot {
    fn drop(&mut self) {
        let key = self.key.load(Ordering::Relaxed);
        if !key.is_null() {
            let _: Box<HashKey> = unsafe { Box::from_raw(key) };
        }
    }
}

pub struct VectorTable {
    slots: Vec<Slot>,
    used: atomic::AtomicUsize,
    active_threads: atomic::AtomicUsize,
}

impl VectorTable {
    pub fn new(size: usize) -> Self {
        let mut slots = Vec::with_capacity(size);
        for _ in 0..size {
            slots.push(Slot::default())
        }
        VectorTable{
            slots: slots,
            used: atomic::AtomicUsize::new(0),
            active_threads: atomic::AtomicUsize::new(0),
        }
    }

    pub fn add_thread(&self) {
        self.active_threads.fetch_add(1, Ordering::Relaxed);
    }

    pub fn remove_thread(&self) {
        self.active_threads.fetch_sub(1, Ordering::Relaxed);
    }

    pub fn active_threads(&self) -> usize {
        self.active_threads.load(Ordering::Relaxed)
    }

    pub fn used(&self) -> usize {
        self.used.load(Ordering::Relaxed)
    }

    pub fn cap(&self) -> usize {
        self.slots.len()
    }

    fn find_index(&self, key: HashKey) -> Option<usize> {
        let size = self.slots.len();
        let hash = djb2_hash(&key) % size;
        let mut index = hash;
        loop {
            let slot = &self.slots[index];
            let slot_key = slot.key.load(Ordering::Relaxed);
            if slot_key.is_null() || unsafe { *slot_key == key }{
                break
            }
            index = (index + 1) % size;
            if index == hash {
                return None;
            }
        }
        Some(index)
    }

    pub fn get_index(&self, index: usize) -> Option<&Slot> {
        self.slots.get(index)
    }

    fn get_slot(&self, key: HashKey) -> Option<&Slot> {
        self.find_index(key).and_then(|i|{self.get_index(i)})
    }

    pub fn get(&self, key: HashKey) -> Option<usize> {
        let size = self.slots.len();
        let hash = djb2_hash(&key) % size;
        let mut index = hash;
        loop {
            let slot = &self.slots[index];
            let slot_key = slot.key.load(Ordering::Relaxed);
            if !slot_key.is_null() && unsafe { *slot_key == key }{
                let ret = Some(slot.value.load(Ordering::Relaxed));
                return ret
            }
            index = (index + 1) % size;
            if index == hash {
                return None
            }
        }
    }

    /// incr attempts to find the given key in the table and increment its value
    /// by the provided amount. If the key is not present in the table it will
    /// attempt to add it. We have two CAS operations that ensure we safely fill
    /// the slot. First we attempt to CAS the state from `SlotState::Dead` to
    /// `SlotState::Allocating`. This gives us exclusive access to it until we
    /// finish allocating the key. The transition to `SlotState::Alive` releases
    /// that "lock" and we increment the value as normal. If a slot was copied
    /// out from under us, we return an error
    pub fn incr(&self, key: HashKey, val: usize) -> IncrResult {
        loop {
            match self.get_slot(key) {
                Some(slot) => match slot.state.get() {
                    SlotState::Dead => {
                        let acquired = slot.state.set_cas(SlotState::Dead, SlotState::Allocating);
                        if acquired {
                            let res = slot.key.compare_and_swap(
                                ptr::null_mut(),
                                Box::into_raw(Box::new(key)),
                                Ordering::Relaxed,
                            );
                            if !res.is_null() {
                                panic!(
                                    "Acquired slot, key was not null: key:{}, slot.key:{}",
                                    hashkey_to_string(&key),
                                    unsafe{ hashkey_to_string(&(*res)) },
                                );
                            }
                            self.used.fetch_add(1, Ordering::Relaxed);
                            slot.state.set(SlotState::Alive);
                            let ret = slot.value.fetch_add(val, Ordering::Relaxed);
                            return IncrResult::Current(ret)
                        }
                    },
                    SlotState::Alive => {
                        let slot_key = slot.key.load(Ordering::Relaxed);
                        if unsafe{ *slot_key == key }{
                            let ret = slot.value.fetch_add(val, Ordering::Relaxed);
                            return IncrResult::Current(ret)
                        }
                    },
                    SlotState::Allocating => {},
                    SlotState::Copying | SlotState::Copied => return IncrResult::Outdated,
                },
                None => panic!("VectorTable is out of space"),
            }
        }
    }

    pub fn copy_index_to(&self, index: usize, table: &VectorTable) -> bool {
        match self.slots.get(index) {
            Some(slot) => match slot.state.get() {
                SlotState::Dead | SlotState::Copying | SlotState::Copied => false,
                SlotState::Allocating => panic!("Tried to copy a slot in state Allocating"),
                SlotState::Alive => {
                    let acquired = slot.state.set_cas(SlotState::Alive, SlotState::Copying);
                    if acquired {
                        let slot_key = slot.key.load(Ordering::Relaxed);
                        if slot_key.is_null() {
                            panic!("Slot in Alive state has null key");
                        }
                        unsafe {
                            if let IncrResult::Outdated = table.incr(*slot_key, slot.value.load(Ordering::Relaxed)) {
                                panic!("copy_index_to destination contains outdated data");
                            }
                        }
                        slot.state.set(SlotState::Copied);
                        true
                    } else {
                        false
                    }
                },
            },
            None => false,
        }
    }

    pub fn copy_key_to(&self, key: HashKey, table: &VectorTable) -> bool {
        match self.get_slot(key) {
            Some(slot) => match slot.state.get() {
                SlotState::Dead | SlotState::Copying | SlotState::Copied => false,
                SlotState::Allocating => panic!("Tried to copy a slot in state Allocating"),
                SlotState::Alive => {
                    let acquired = slot.state.set_cas(SlotState::Alive, SlotState::Copying);
                    if acquired {
                        let slot_key = slot.key.load(Ordering::Relaxed);
                        if slot_key.is_null() {
                            panic!("Slot in Alive state has null key");
                        }
                        if unsafe{ *slot_key != key } {
                            panic!("Slot found doesn't have correct key");
                        }
                        if let IncrResult::Outdated = table.incr(key, slot.value.load(Ordering::Relaxed)) {
                            panic!("The table we are copying to is outdated");
                        }
                        slot.state.set(SlotState::Copied);
                        true
                    } else {
                        false
                    }
                },
            },
            None => false,
        }
    }
}

#[cfg(test)]
mod tests {
    use std::thread;
    use std::sync::Arc;
    use test::Bencher;
    use super::*;
    use rand;
    use rand::Rng;
    use ::key::clean_key;

    const INITIAL_SIZE: usize = 128;

    #[test]
    fn increment() {
        let table = VectorTable::new(INITIAL_SIZE);
        let res = match table.incr(clean_key("foo"), 1) {
            IncrResult::Current(v) => v,
            IncrResult::Outdated => panic!("Increment test returned Outdated"),
        };
        assert_eq!(res, 0);
        let slot = table.get_slot(clean_key("foo")).unwrap();
        assert_eq!(slot.value.load(Ordering::Relaxed), 1);
        assert_eq!(table.cap(), INITIAL_SIZE);
        assert_eq!(table.used(), 1);
    }

    #[test]
    fn sequential_increment() {
        let table = VectorTable::new(INITIAL_SIZE);

        for _ in 0..100000 {
            table.incr(clean_key("foo"), 1);
        }
        let slot = table.get_slot(clean_key("foo")).unwrap();
        assert_eq!(slot.value.load(Ordering::Relaxed), 100000);
        assert_eq!(table.cap(), INITIAL_SIZE);
        assert_eq!(table.used(), 1);
    }

    #[test]
    fn concurrent_multikey_increment() {
        let table = VectorTable::new(INITIAL_SIZE);
        let shared = Arc::new(table);
        let nthreads = 8;
        let nkeys = INITIAL_SIZE;
        let nincr = 10000;
        let mut children = vec![];
        for _ in 0..nthreads {
            let c = shared.clone();
            children.push(thread::Builder::new().name("table-cmki".to_string()).spawn(move|| {
                let mut rng = rand::thread_rng();
                for _ in 0..nincr {
                    let mut keys: Vec<usize> = (0..nkeys).collect();
                    rng.shuffle(keys.as_mut_slice());
                    for i in keys {
                        c.incr(clean_key(&format!("foo_{}", i)), 1);
                    }
                }
            }).unwrap());
        }
        for t in children {
            let _ = t.join();
        }
        for i in 0..INITIAL_SIZE {
            let slot = shared.get_slot(clean_key(&format!("foo_{}", i))).unwrap();
            assert_eq!(slot.value.load(Ordering::Relaxed), nincr * nthreads);
            assert_eq!(slot.state.get(), SlotState::Alive);
        }
        assert_eq!(shared.cap(), INITIAL_SIZE);
        assert_eq!(shared.used(), INITIAL_SIZE);
    }

    #[test]
    fn concurrent_increment() {
        let table = VectorTable::new(INITIAL_SIZE);
        let shared = Arc::new(table);
        let nthreads = 8;
        let nincr = 10000;
        let mut children = vec![];
        for _ in 0..nthreads {
            let c = shared.clone();
            children.push(thread::Builder::new().name("table-ci".to_string()).spawn(move|| {
                for _ in 0..nincr {
                    c.incr(clean_key("foo"), 1);
                }
            }).unwrap());
        }
        for t in children {
            let _ = t.join();
        }
        assert_eq!(shared.get_slot(clean_key("foo")).unwrap().value.load(Ordering::Relaxed), nincr * nthreads);
        assert_eq!(shared.get_slot(clean_key("foo")).unwrap().state.get(), SlotState::Alive);
    }

    #[test]
    fn fill_table() {
        let table = VectorTable::new(INITIAL_SIZE);

        for i in 0..INITIAL_SIZE {
            table.incr(clean_key(&format!("foo_{}", i)), i);
        }

        for i in 0..INITIAL_SIZE {
            let slot = table.get_slot(clean_key(&format!("foo_{}", i))).unwrap();
            assert_eq!(slot.value.load(Ordering::Relaxed), i);
            assert_eq!(slot.state.get(), SlotState::Alive);
        }
        assert_eq!(table.cap(), INITIAL_SIZE);
        assert_eq!(table.used(), INITIAL_SIZE);
    }

    #[test]
    #[should_panic]
    fn over_fill_table() {
        let table = VectorTable::new(INITIAL_SIZE);

        for i in 0..INITIAL_SIZE+1 {
            table.incr(clean_key(&format!("foo_{}", i)), i);
        }
    }

    #[test]
    fn copy_key() {
        let table = VectorTable::new(INITIAL_SIZE);
        let new_table = VectorTable::new(INITIAL_SIZE*3);
        table.incr(clean_key("foobar"), 100);

        let res = table.copy_key_to(clean_key("foobar"), &new_table);
        assert_eq!(res, true);

        let old_slot = table.get_slot(clean_key("foobar")).unwrap();
        let new_slot = new_table.get_slot(clean_key("foobar")).unwrap();

        assert_eq!(old_slot.state.get(), SlotState::Copied);
        assert_eq!(new_slot.state.get(), SlotState::Alive);
        assert_eq!(new_slot.value.load(Ordering::Relaxed), 100);
        assert_eq!(unsafe{*(new_slot.key.load(Ordering::Relaxed))}, clean_key("foobar"))
    }

    #[test]
    fn concurrent_copy_key() {
        let table = VectorTable::new(INITIAL_SIZE);
        let shared = Arc::new(table);
        let new_table = VectorTable::new(INITIAL_SIZE*3);
        let new_shared = Arc::new(new_table);
        let nthreads = 8;

        for i in 0..INITIAL_SIZE {
            shared.incr(clean_key(&format!("foobar_{}", i)), i);
        }

        let mut children = vec![];
        for _ in 0..nthreads {
            let c = shared.clone();
            let nc = new_shared.clone();

            children.push(thread::Builder::new().name("table-cck".to_string()).spawn(move|| {
                let mut rng = rand::thread_rng();
                let mut keys: Vec<usize> = (0..INITIAL_SIZE).collect();
                rng.shuffle(keys.as_mut_slice());
                for k in keys {
                    c.copy_key_to(clean_key(&format!("foobar_{}", k)), &nc);
                }
            }).unwrap());
        }
        for t in children {
            let _ = t.join();
        }
        for i in 0..INITIAL_SIZE {
            let slot = new_shared.get_slot(clean_key(&format!("foobar_{}", i))).unwrap();
            assert_eq!(slot.value.load(Ordering::Relaxed), i);
        }

    }

    #[bench]
    fn bench_incr(b: &mut Bencher) {
        let table = VectorTable::new(INITIAL_SIZE);
        let key = clean_key("foo");
        b.iter(|| table.incr(key, 1))
    }

    #[bench]
    fn bench_existing_incr(b: &mut Bencher) {
        let table = VectorTable::new(INITIAL_SIZE);
        let key = clean_key("foo");
        table.incr(key, 1);
        b.iter(|| table.incr(key, 1));
    }

    #[bench]
    fn bench_get_slot(b: &mut Bencher) {
        let table = VectorTable::new(INITIAL_SIZE);
        let key = clean_key("foo");
        table.incr(key, 100);
        b.iter(|| table.get_slot(key))
    }
}


text:
ALTER TABLE `repository_rss_feed`
ADD COLUMN `number_of_items` INT(11) NOT NULL DEFAULT 0 COMMENT '' AFTER `url`;

INSERT IGNORE INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Repository\\ContentObject\\File\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\Assignment','Chamilo\\Core\\Repository\\ContentObject\\File\\Integration',NULL,'assignment_integration',1,'5.0.0');
INSERT IGNORE INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Repository\\ContentObject\\Page\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\Assignment','Chamilo\\Core\\Repository\\ContentObject\\Page\\Integration',NULL,'assignment_integration',1,'5.0.0');
INSERT IGNORE INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Repository\\ContentObject\\Webpage\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\Assignment','Chamilo\\Core\\Repository\\ContentObject\\Webpage\\Integration',NULL,'assignment_integration',1,'5.0.0');
INSERT IGNORE INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Repository\\ContentObject\\Link\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\Assignment','Chamilo\\Core\\Repository\\ContentObject\\Link\\Integration',NULL,'assignment_integration',1,'5.0.0');
INSERT IGNORE INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Repository\\ContentObject\\Youtube\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\Assignment','Chamilo\\Core\\Repository\\ContentObject\\Youtube\\Integration',NULL,'assignment_integration',1,'5.0.0');
INSERT IGNORE INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Repository\\ContentObject\\Vimeo\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\Assignment','Chamilo\\Core\\Repository\\ContentObject\\Vimeo\\Integration',NULL,'assignment_integration',1,'5.0.0');
INSERT IGNORE INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Repository\\ContentObject\\Slideshare\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\Assignment','Chamilo\\Core\\Repository\\ContentObject\\Slideshare\\Integration',NULL,'assignment_integration',1,'5.0.0');
INSERT IGNORE INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Repository\\ContentObject\\Soundcloud\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\Assignment','Chamilo\\Core\\Repository\\ContentObject\\Soundcloud\\Integration',NULL,'assignment_integration',1,'5.0.0');

CREATE TABLE `portfolio_user_favourite` (
  `id` INT NOT NULL AUTO_INCREMENT,
  `source_user_id` INT NOT NULL DEFAULT 0,
  `favourite_user_id` INT NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`),
  UNIQUE INDEX `user_favourite` (`source_user_id` ASC, `favourite_user_id` ASC));

INSERT IGNORE INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`) VALUES(NULL, 'Chamilo\\Application\\Portfolio\\Integration\\Chamilo\\Core\\Home', 'Chamilo\\Application\\Portfolio\\Integration', NULL, 'Home', 1, '5.0.0');

ALTER TABLE `weblcms_course_group_user_relation`
ADD COLUMN `subscription_time` INT(10) UNSIGNED NOT NULL DEFAULT 0 AFTER `user_id`;

ALTER TABLE `repository_workspace_content_object_relation` CHANGE COLUMN `content_object_id` `content_object_id` VARCHAR(36) NOT NULL COMMENT '' ;

UPDATE `repository_workspace_content_object_relation` SET content_object_id = (SELECT object_number FROM `repository_content_object` WHERE `repository_content_object`.id = `repository_workspace_content_object_relation`.content_object_id)

CREATE TABLE `home_element_target_entity` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `element_id` INT(10) UNSIGNED NOT NULL,
  `entity_type` INT(10) UNSIGNED NOT NULL,
  `entity_id` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `element_id` (`element_id` ASC),
  INDEX `entity` (`entity_type` ASC, `entity_id` ASC));

CREATE TABLE `home_block_type_target_entity` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `block_type` VARCHAR(255) NOT NULL,
  `entity_type` INT(10) UNSIGNED NOT NULL,
  `entity_id` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `block_type` (`block_type` ASC),
  INDEX `entity` (`entity_type` ASC, `entity_id` ASC));

INSERT INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\Assignment\\Integration\\Chamilo\\Application\\Calendar','Chamilo\\Application\\Weblcms\\Tool\\Implementation\\Assignment\\Integration','core','Calendar',1,'5.0.0');
INSERT INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\Calendar\\Integration\\Chamilo\\Application\\Calendar','Chamilo\\Application\\Weblcms\\Tool\\Implementation\\Calendar\\Integration','core','Calendar',1,'5.0.0');
INSERT INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Home\\Integration\\Chamilo\\Core\\Admin','Chamilo\\Core\\Home\\Integration',NULL,'Admin',1,'5.0.0');

CREATE TABLE `home_content_object_publication` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `element_id` INT(10) UNSIGNED NOT NULL,
  `content_object_id` INT(10) UNSIGNED NOT NULL,
  PRIMARY KEY (`id`),
  INDEX `element_id` (`element_id` ASC),
  INDEX `content_object_id` (`content_object_id` ASC));

INSERT INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Core\\Home\\Integration\\Chamilo\\Core\\Repository','Chamilo\\Core\\Home\\Integration',NULL,'Repository',1,'5.0.0');
INSERT INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Libraries\\Mail\\Mailer\\Platform','Chamilo\\Libraries\\Mail\\Mailer',NULL,'Mailer',1,'5.0.0');
INSERT INTO `configuration_registration` (`id`,`context`,`type`,`category`,`name`,`status`,`version`) VALUES (NULL,'Chamilo\\Libraries\\Mail\\Mailer\\PhpMailer','Chamilo\\Libraries\\Mail\\Mailer',NULL,'Mailer',1,'5.0.0');

INSERT INTO `configuration_setting` (`context`, `variable`, `value`, `user_setting`) VALUES ('Chamilo\\Core\\Admin', 'mailer', 'Chamilo\\Libraries\\Mail\\Mailer\\PhpMailer\\Mailer', '0');

CREATE TABLE `repository_wiki_page_feedback` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `wiki_page_id` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `creation_date` int(10) unsigned NOT NULL,
  `modification_date` int(10) unsigned NOT NULL,
  `comment` longtext COLLATE utf8_unicode_ci,
  PRIMARY KEY (`id`),
  KEY `rwpf_wiki_page_id` (`wiki_page_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `menu_application_item`
  ADD COLUMN `component` VARCHAR(255) NULL DEFAULT NULL AFTER `application`,
  ADD COLUMN `extra_parameters` VARCHAR(255) NULL DEFAULT NULL AFTER `component`;

/* HoGent */
/* Perspectief */

INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES(NULL, 'Chamilo\\Core\\Admin', 'google_analytics_tracking_id', '', 0);
INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES(NULL, 'Chamilo\\Core\\Menu', 'brand_image', '', 0);

ALTER TABLE `repository_file`
  ADD COLUMN `show_inline` INT(3) NOT NULL DEFAULT 1 AFTER `hash`;

CREATE TABLE `rights_structure_location` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `context` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `action` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `rsl_location` (`context`,`action`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `rights_structure_location_role` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `structure_location_id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `rslr_structure_location_role` (`structure_location_id`,`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `user_role` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `role` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `ur_role` (`role`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `user_role_relation` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` int(11) NOT NULL,
  `role_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `urr_user_role` (`user_id`,`role_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT INTO `configuration_registration` VALUES (NULL, 'Chamilo\\Core\\Rights\\Structure', 'Chamilo\\Core\\Rights', 'Core', 'StructureRights', '1', '5.0.0');
INSERT INTO `configuration_registration` VALUES (NULL, 'Chamilo\\Core\\User\\Roles', 'Chamilo\\Core\\User', 'Core', 'UserRoles', '1', '5.0.0');
INSERT INTO `configuration_registration` VALUES (NULL, 'Chamilo\\Application\\Weblcms\\Course\\OpenCourse', 'Chamilo\\Application\\Weblcms\\Course', 'Application', 'OpenCourses', '1', '5.0.0');
INSERT INTO `configuration_setting` VALUES (NULL, 'Chamilo\\Core\\Admin', 'enableAnonymousAuthentication', '0', '0');
INSERT INTO `configuration_setting` VALUES (NULL, 'Chamilo\\Core\\Admin', 'anonymous_authentication_url', '', '0');
INSERT INTO `configuration_setting` VALUES (NULL, 'Chamilo\\Core\\Admin', 'recaptcha_site_key', '', '0');
INSERT INTO `configuration_setting` VALUES (NULL, 'Chamilo\\Core\\Admin', 'recaptcha_secret_key', '', '0');
INSERT INTO `configuration_setting` VALUES (NULL, 'Chamilo\\Core\\Admin', 'page_after_anonymous_access', '', '0');
INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES (NULL, 'Chamilo\\Core\\Repository\\Form', 'omit_content_object_title_check', '0', '0');

INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES (NULL, 'Chamilo\\Core\\Admin', 'cas_version', 'SAML_VERSION_1_1', '0');
INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES (NULL, 'Chamilo\\Core\\Admin', 'cas_check_certificate', '1', '0');
INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES (NULL, 'Chamilo\\Core\\Admin', 'cas_user_login', 'login', '0');
INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES (NULL, 'Chamilo\\Core\\Admin', 'cas_validation_string', 'EXT', '0');

INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (120,'Chamilo\\Core\\Reporting','paper_orientation','Portrait',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (121,'Chamilo\\Core\\Reporting','template_header_text_color','0, 0, 0',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (122,'Chamilo\\Core\\Reporting','template_header_font_family','Arial',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (123,'Chamilo\\Core\\Reporting','template_header_font_style','B',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (124,'Chamilo\\Core\\Reporting','template_header_font_size','11',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (125,'Chamilo\\Core\\Reporting','template_header_line_color','0, 0, 0',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (126,'Chamilo\\Core\\Reporting','template_footer_text_color','0, 0, 0',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (127,'Chamilo\\Core\\Reporting','template_footer_font_family','Arial',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (128,'Chamilo\\Core\\Reporting','template_footer_font_style','B',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (129,'Chamilo\\Core\\Reporting','template_footer_font_size','10',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (130,'Chamilo\\Core\\Reporting','block_title_text_color','0, 0, 0',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (131,'Chamilo\\Core\\Reporting','block_title_font_family','Arial',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (132,'Chamilo\\Core\\Reporting','block_title_font_style','B',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (133,'Chamilo\\Core\\Reporting','block_title_font_size','11',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (134,'Chamilo\\Core\\Reporting','min_relative_width','0.1',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (135,'Chamilo\\Core\\Reporting','heading_cell_alignment','Left',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (136,'Chamilo\\Core\\Reporting','heading_cell_text_color','255, 255, 255',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (137,'Chamilo\\Core\\Reporting','heading_cell_background_color','150, 150, 150',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (138,'Chamilo\\Core\\Reporting','heading_cell_border_color','0, 0, 0',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (139,'Chamilo\\Core\\Reporting','heading_cell_font_family','Arial',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (140,'Chamilo\\Core\\Reporting','heading_cell_font_style','',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (141,'Chamilo\\Core\\Reporting','heading_cell_font_size','10',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (142,'Chamilo\\Core\\Reporting','data_cell_alignment','Left',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (143,'Chamilo\\Core\\Reporting','data_cell_text_color','0, 0, 0',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (144,'Chamilo\\Core\\Reporting','data_cell_background_color','255, 255, 255',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (145,'Chamilo\\Core\\Reporting','data_cell_border_color','0, 0, 0',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (146,'Chamilo\\Core\\Reporting','data_cell_font_family','Arial',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (147,'Chamilo\\Core\\Reporting','data_cell_font_style','',0);
INSERT IGNORE INTO `configuration_setting` (`id`,`context`,`variable`,`value`,`user_setting`) VALUES (148,'Chamilo\\Core\\Reporting','data_cell_font_size','10',0);

/* Learning Path Refactoring */

CREATE TABLE IF NOT EXISTS `repository_learning_path_tree_node_data` (
  `id` int(10) unsigned NOT NULL,
  `learning_path_id` int(10) unsigned NOT NULL,
  `parent_tree_node_data_id` int(10) unsigned NOT NULL,
  `content_object_id` int(10) unsigned NOT NULL,
  `max_attempts` int(10) unsigned NOT NULL DEFAULT '0',
  `mastery_score` int(10) unsigned NOT NULL DEFAULT '0',
  `allow_hints` tinyint(1) NOT NULL DEFAULT '1',
  `show_score` tinyint(1) NOT NULL DEFAULT '1',
  `show_correction` tinyint(1) NOT NULL DEFAULT '1',
  `show_solution` tinyint(1) NOT NULL DEFAULT '1',
  `show_answer_feedback` int(10) unsigned NOT NULL DEFAULT '7',
  `feedback_location` int(10) unsigned NOT NULL DEFAULT '3',
  `blocked` tinyint(1) NOT NULL DEFAULT '0',
  `display_order` int(10) unsigned NOT NULL,
  `user_id` int(10) unsigned NOT NULL,
  `added_date` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `repository_learning_path_tree_node_data`
  ADD PRIMARY KEY (`id`),
  ADD KEY `learning_path_id` (`learning_path_id`),
  ADD KEY `content_object_id` (`content_object_id`) USING BTREE,
  ADD KEY `section_content_object_id` (`parent_tree_node_data_id`),
  ADD KEY `user_id` (`user_id`);

ALTER TABLE `repository_learning_path_tree_node_data` CHANGE `id` `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT;

DELETE FROM configuration_registration WHERE context = 'Chamilo\\Core\\Repository\\ContentObject\\Note\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\LearningPath';
DELETE FROM configuration_registration WHERE context = 'Chamilo\\Core\\Repository\\ContentObject\\Description\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\LearningPath';
DELETE FROM configuration_registration WHERE context = 'Chamilo\\Core\\Repository\\ContentObject\\Blog\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\LearningPath';
DELETE FROM configuration_registration WHERE context = 'Chamilo\\Core\\Repository\\ContentObject\\Webpage\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\LearningPath';
DELETE FROM configuration_registration WHERE context = 'Chamilo\\Core\\Repository\\ContentObject\\Announcement\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\LearningPath';

ALTER TABLE `tracking_weblcms_learning_path_item_attempt` RENAME `tracking_weblcms_learning_path_tree_node_attempt`;
ALTER TABLE `tracking_weblcms_learning_path_question_attempt` RENAME `tracking_weblcms_learning_path_tree_node_question_attempt`;

ALTER TABLE `tracking_weblcms_learning_path_tree_node_attempt`
  ADD `user_id` INT(10) UNSIGNED NOT NULL AFTER `id`,
  ADD `learning_path_id` INT(10) UNSIGNED NOT NULL AFTER `user_id`,
  ADD `publication_id` INT(10) UNSIGNED NOT NULL AFTER `learning_path_id`,
  DROP `lesson_location`,
  DROP `suspend_data`,
  DROP `min_score`,
  DROP `max_score`;

ALTER TABLE `tracking_weblcms_learning_path_tree_node_attempt` CHANGE `learning_path_item_id` `tree_node_data_id` INT(10) UNSIGNED NOT NULL;
ALTER TABLE `tracking_weblcms_learning_path_tree_node_question_attempt` CHANGE `item_attempt_id` `tree_node_attempt_id` INT(10) UNSIGNED NOT NULL;

ALTER TABLE `tracking_weblcms_learning_path_tree_node_attempt`
  ADD INDEX(`user_id`),
  ADD INDEX(`learning_path_id`),
  ADD INDEX(`publication_id`);

# ALTER TABLE `tracking_weblcms_learning_path_attempt` ADD `publication_id` INT(10) UNSIGNED NOT NULL AFTER `learning_path_id`;
# UPDATE `tracking_weblcms_learning_path_attempt` SET publication_id = learning_path_id;

UPDATE `tracking_weblcms_learning_path_tree_node_attempt` TN_ATT
  JOIN tracking_weblcms_learning_path_attempt LP_ATT on TN_ATT.learning_path_attempt_id = LP_ATT.id
SET TN_ATT.user_id = LP_ATT.user_id, TN_ATT.learning_path_id = LP_ATT.learning_path_id;

UPDATE `tracking_weblcms_learning_path_tree_node_attempt` SET publication_id = learning_path_id;

UPDATE `tracking_weblcms_learning_path_tree_node_attempt` AS ATT
JOIN weblcms_content_object_publication PUB on PUB.id = ATT.publication_id
SET ATT.learning_path_id = PUB.content_object_id;

DROP TABLE tracking_weblcms_learning_path_attempt;
ALTER TABLE `tracking_weblcms_learning_path_tree_node_attempt` DROP `learning_path_attempt_id`;

UPDATE `tracking_weblcms_learning_path_tree_node_attempt`
SET status = 1 WHERE status IN ('passed', 'failed', 'completed');

UPDATE `tracking_weblcms_learning_path_tree_node_attempt`
SET status = 0 WHERE status IN ('not attempted');

ALTER TABLE `tracking_weblcms_learning_path_tree_node_attempt` CHANGE `status` `completed` TINYINT(1) NOT NULL DEFAULT '0';

ALTER TABLE `repository_learning_path`
  DROP `control_mode`,
  DROP `version`,
  DROP `path`;

ALTER TABLE `repository_learning_path` ADD `automatic_numbering` VARCHAR(15) NOT NULL DEFAULT 'none' AFTER `id`, ADD `enforce_default_traversing_order` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `automatic_numbering`;

DELETE FROM `configuration_registration` WHERE `context` LIKE '%LearningPathItem%';
DELETE FROM `configuration_registration` WHERE `context` LIKE 'Chamilo\\\\Core\\\\Repository\\\\ContentObject\\\\LearningPath\\\\Integration\\\\Chamilo\\\\Core\\\\Repository\\\\ContentObject\\\\LearningPath';

ALTER TABLE `configuration_registration` ADD `priority` INT(3) UNSIGNED NOT NULL DEFAULT '1';
UPDATE configuration_registration SET priority = 20 WHERE `context` LIKE 'Chamilo\\\\Core\\\\Repository\\\\ContentObject\\\\Assessment\\\\Integration\\\\Chamilo\\\\Core\\\\Repository\\\\ContentObject\\\\LearningPath';
UPDATE configuration_registration SET priority = 50 WHERE `context` LIKE 'Chamilo\\\\Core\\\\Repository\\\\ContentObject\\\\Page\\\\Integration\\\\Chamilo\\\\Core\\\\Repository\\\\ContentObject\\\\LearningPath';

INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Core\\Repository\\ContentObject\\File\\Integration\\Chamilo\\Core\\Repository\\HtmlEditor', 'Chamilo\\Core\\Repository\\ContentObject\\File\\Integration', NULL, 'Repository', '1', '5.0.0', '1');
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Core\\Repository\\ContentObject\\LearningPath\\Integration\\Chamilo\\Core\\Repository', 'Chamilo\\Core\\Repository\\ContentObject\\earningPath\\Integration', NULL, 'Repository', '1', '5.0.0', '1');

/**
Section content object install! (lynx package manager)
 */

/** Migratie uitvoeren via code
 * Post migratie SQL
**/

DELETE FROM `repository_complex_content_object_item` WHERE parent_id IN
(SELECT id FROM repository_content_object CO WHERE CO.type = 'Chamilo\\Core\\Repository\\ContentObject\\LearningPath\\Storage\\DataClass\\LearningPath');

DELETE FROM `repository_complex_learning_path_item`;
DELETE FROM `repository_content_object` WHERE `type` LIKE '%LearningPathItem%';

/** NEW **/

INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES (NULL, 'Chamilo\\Core\\Admin', 'maintenance_warning_show', '0', '0'),
  (NULL, 'Chamilo\\Core\\Admin', 'maintenance_warning_message', NULL, '0'),
  (NULL, 'Chamilo\\Core\\Admin', 'maintenance_block_access', 0, '0');

DELETE FROM `configuration_setting` WHERE `variable` LIKE 'maintenance_mode' AND context LIKE 'Chamilo\\\\Core\\\\Admin';

ALTER TABLE `repository_learning_path_tree_node_data` ADD `enforce_default_traversing_order` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `added_date`;

/** 16 OCT 2017 **/
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\CourseGroup\\Extension\\Office365', 'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\CourseGroup\\Extension', 'Extension', 'Office365', '1', '1.0.0', '1');
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\CourseGroup\\Extension\\Office365\\Integration\\Chamilo\\Application\\Weblcms\\Tool\\Implementation\\CourseGroup', 'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\CourseGroup\\Extension\\Office365\\Integration', 'Integration', 'Office365', '1', '1.0.0', '1');

INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\Document\\Integration\\Chamilo\\Application\\Weblcms\\Tool\\Implementation\\CourseGroup', 'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\Document\\Integration', 'Integration', 'Document', '1', '1.0.0', '1');
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\Forum\\Integration\\Chamilo\\Application\\Weblcms\\Tool\\Implementation\\CourseGroup', 'Chamilo\\Application\\Weblcms\\Tool\\Implementation\\Forum\\Integration', 'Integration', 'Forum', '1', '1.0.0', '1');
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'Chamilo\\Libraries', NULL, 'MicrosoftGraph', '1', '1.0.0', '1');

CREATE TABLE `weblcms_course_group_publication_category` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `course_group_id` int(10) UNSIGNED NOT NULL,
  `publication_category_id` int(10) UNSIGNED NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `weblcms_course_group_office365_reference` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `course_group_id` int(10) UNSIGNED NOT NULL,
  `office365_group_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `office365_plan_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `linked` TINYINT(1) NOT NULL,
  PRIMARY KEY (id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT INTO `configuration_setting` (`id`, `context`, `variable`, `value`, `user_setting`) VALUES
  (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'client_id', NULL, '0'),
  (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'client_secret', NULL, '0'),
  (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'access_token', NULL, '1'),
  (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'external_user_id', NULL, '1'),
  (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'tenant_id', NULL, '0'),
  (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'cosnics_prefix', NULL, 'cosnics_'),
  (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'planner_base_uri', 'https://tasks.office.com/tenantName.onmicrosoft.com/nl-NL/Home/Planner', '0'),
  (NULL, 'Chamilo\\Libraries\\Protocol\\Microsoft\\Graph', 'group_base_uri', 'https://outlook.office.com/owa/?realm=realm&exsvurl=1&ll-cc=1043&modurl=0&path=/group/{GROUP_ID}@tenant.onmicrosoft.com/people', '0');

INSERT INTO weblcms_course_group_publication_category
    SELECT NULL, CG.id, CG.document_category_id FROM weblcms_course_group CG WHERE CG.document_category_id > 0;

INSERT INTO weblcms_course_group_publication_category
  SELECT NULL, CG.id, CG.forum_category_id FROM weblcms_course_group CG WHERE CG.forum_category_id > 0;

/** Learning Path Assigments **/

INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Core\\Repository\\ContentObject\\Assignment\\Integration\\Chamilo\\Core\\Repository\\ContentObject\\LearningPath', 'Chamilo\\Core\\Repository\\ContentObject\\Assignment\\Integration', NULL, 'Repository', '1', '1.0.0', '1');

CREATE TABLE `tracking_weblcms_learning_path_assignment_entry` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `tree_node_attempt_id` int(10) UNSIGNED NOT NULL,
  `tree_node_data_id` int(10) UNSIGNED NOT NULL,
  `content_object_id` int(10) UNSIGNED NOT NULL,
  `entity_id` int(10) UNSIGNED NOT NULL,
  `entity_type` tinyint(2) UNSIGNED NOT NULL,
  `submitted` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `ip_address` varchar(15) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `twlpae_tree_node_attempt_id` (`tree_node_attempt_id`),
  KEY `twlpae_tree_node_data_id` (`tree_node_data_id`),
  KEY `twlpae_content_object_id` (`content_object_id`),
  KEY `twlpae_entity` (`entity_id`, `entity_type`),
  KEY `twlpae_user_id` (`user_id`)
);

CREATE TABLE `tracking_weblcms_learning_path_assignment_feedback` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `entry_id` INT(10) UNSIGNED NOT NULL , `creation_date` INT(10) UNSIGNED NOT NULL , `modification_date` INT(10) UNSIGNED NOT NULL , `user_id` INT(10) UNSIGNED NOT NULL , `comment` TEXT NULL , PRIMARY KEY (`id`), KEY `twlpaf_entry_id` (`entry_id`)) ENGINE = InnoDB;
CREATE TABLE `tracking_weblcms_learning_path_assignment_note` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `entry_id` INT(10) UNSIGNED NOT NULL , `created` INT(10) UNSIGNED NOT NULL , `modified` INT(10) UNSIGNED NOT NULL , `user_id` INT(10) UNSIGNED NOT NULL , `note` TEXT NULL , PRIMARY KEY (`id`), KEY `twlpan_entry_id` (`entry_id`)) ENGINE = InnoDB;
CREATE TABLE `tracking_weblcms_learning_path_assignment_score` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `entry_id` INT(10) UNSIGNED NOT NULL , `created` INT(10) UNSIGNED NOT NULL , `modified` INT(10) UNSIGNED NOT NULL , `user_id` INT(10) UNSIGNED NOT NULL , `score` INT(10) UNSIGNED NOT NULL , PRIMARY KEY (`id`), KEY `twlpas_entry_id` (`entry_id`)) ENGINE = InnoDB;

CREATE TABLE `tracking_weblcms_assignment_entry` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `content_object_publication_id` int(10) UNSIGNED NOT NULL,
  `content_object_id` int(10) UNSIGNED NOT NULL,
  `entity_id` int(10) UNSIGNED NOT NULL,
  `entity_type` tinyint(2) UNSIGNED NOT NULL,
  `submitted` int(10) UNSIGNED NOT NULL,
  `user_id` int(10) UNSIGNED NOT NULL,
  `ip_address` varchar(15) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `twae_content_object_publication_id` (`content_object_publication_id`),
  KEY `twae_content_object_id` (`content_object_id`),
  KEY `twae_entity` (`entity_id`, `entity_type`),
  KEY `twae_user_id` (`user_id`)
);

CREATE TABLE `tracking_weblcms_assignment_feedback` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `entry_id` INT(10) UNSIGNED NOT NULL , `creation_date` INT(10) UNSIGNED NOT NULL , `modification_date` INT(10) UNSIGNED NOT NULL , `user_id` INT(10) UNSIGNED NOT NULL , `comment` TEXT NULL , PRIMARY KEY (`id`), KEY `twaf_entry_id` (`entry_id`)) ENGINE = InnoDB;
CREATE TABLE `tracking_weblcms_assignment_note` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `entry_id` INT(10) UNSIGNED NOT NULL , `created` INT(10) UNSIGNED NOT NULL , `modified` INT(10) UNSIGNED NOT NULL , `user_id` INT(10) UNSIGNED NOT NULL , `note` TEXT NULL , PRIMARY KEY (`id`), KEY `twan_entry_id` (`entry_id`)) ENGINE = InnoDB;
CREATE TABLE `tracking_weblcms_assignment_score` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `entry_id` INT(10) UNSIGNED NOT NULL , `created` INT(10) UNSIGNED NOT NULL , `modified` INT(10) UNSIGNED NOT NULL , `user_id` INT(10) UNSIGNED NOT NULL , `score` INT(10) UNSIGNED NOT NULL , PRIMARY KEY (`id`), KEY `twas_entry_id` (`entry_id`)) ENGINE = InnoDB;

/** Assignment tool refactoring **/

/** EXECUTE WHEN THE INDEXES OF ASSIGNMENT HAS NOT BEEN SET **/

/**ALTER TABLE `tracking_weblcms_assignment_entry` ADD INDEX( `entity_id`, `entity_type`);
ALTER TABLE `tracking_weblcms_assignment_entry` ADD INDEX( `content_object_publication_id`);
ALTER TABLE `tracking_weblcms_assignment_entry` ADD INDEX( `content_object_id`);
ALTER TABLE `tracking_weblcms_assignment_entry` ADD INDEX( `user_id`);

ALTER TABLE `tracking_weblcms_assignment_feedback` ADD INDEX( `user_id`);
ALTER TABLE `tracking_weblcms_assignment_note` ADD INDEX( `user_id`);
ALTER TABLE `tracking_weblcms_assignment_score` ADD INDEX( `user_id`);

ALTER TABLE `tracking_weblcms_assignment_feedback` ADD INDEX( `entry_id`);
ALTER TABLE `tracking_weblcms_assignment_note` ADD INDEX( `entry_id`);
ALTER TABLE `tracking_weblcms_assignment_score` ADD INDEX( `entry_id`);**/

CREATE TABLE `weblcms_assignment_publication` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `publication_id` int(10) UNSIGNED NOT NULL,
  `entity_type` int(3) UNSIGNED NOT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `wap_publication_id` (`publication_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

INSERT IGNORE INTO weblcms_assignment_publication
SELECT NULL, COP.id, 0 FROM weblcms_content_object_publication COP
JOIN repository_content_object RCO on RCO.id = COP.content_object_id
WHERE COP.tool = 'Assignment' AND RCO.type LIKE '%Assignment%';

UPDATE weblcms_assignment_publication WAP
JOIN weblcms_content_object_publication COP on WAP.publication_id = COP.id
JOIN repository_assignment COA on COP.content_object_id = COA.id
SET WAP.entity_type = 1 WHERE COA.allow_group_submissions = 1;

ALTER TABLE `repository_assignment` DROP `allow_group_submissions`;

CREATE TABLE `tracking_weblcms_assignment_entry_attachment` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `entry_id` INT(10) UNSIGNED NOT NULL , `attachment_id` INT(10) UNSIGNED NOT NULL , PRIMARY KEY (`id`), KEY `twaea_attachment_id` (`attachment_id`), KEY `twaea_entry_id` (`entry_id`)) ENGINE = InnoDB;
CREATE TABLE `tracking_weblcms_learning_path_assignment_entry_attachment` ( `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT , `entry_id` INT(10) UNSIGNED NOT NULL , `attachment_id` INT(10) UNSIGNED NOT NULL , PRIMARY KEY (`id`), KEY `twlpaea_attachment_id` (`attachment_id`), KEY `twlpaea_entry_id` (`entry_id`)) ENGINE = InnoDB;

INSERT INTO tracking_weblcms_assignment_entry
    SELECT id, publication_id, content_object_id, submitter_id, submitter_type, date_submitted, user_id, ip_address
    FROM tracking_weblcms_assignment_submission;

INSERT INTO tracking_weblcms_assignment_feedback
    SELECT NULL, SF.submission_id, SF.created, SF.modified, SF.user_id, CO.description
    FROM tracking_weblcms_submission_feedback SF
    JOIN repository_content_object CO on CO.id = SF.content_object_id
    WHERE CO.type NOT IN (
      'Chamilo\\Core\\Repository\\ContentObject\\File\\Storage\\DataClass\\File'
    );

INSERT INTO tracking_weblcms_assignment_entry_attachment
    SELECT NULL, SF.submission_id, SF.content_object_id
    FROM tracking_weblcms_submission_feedback SF
      JOIN repository_content_object CO on CO.id = SF.content_object_id
    WHERE CO.type IN (
      'Chamilo\\Core\\Repository\\ContentObject\\File\\Storage\\DataClass\\File'
    );

INSERT INTO tracking_weblcms_assignment_score
    SELECT NULL, submission_id, created, modified, user_id, score
    FROM tracking_weblcms_submission_score;

# INSERT INTO tracking_weblcms_assignment_feedback
#     SELECT NULL, submission_id, created, modified, user_id, note
#     FROM tracking_weblcms_submission_note;

DROP TABLE tracking_weblcms_assignment_note;
DROP TABLE tracking_weblcms_learning_path_assignment_note;

# DROP TABLE tracking_weblcms_assignment_submission;
# DROP TABLE tracking_weblcms_submission_feedback;
# DROP TABLE tracking_weblcms_submission_score;
# DROP TABLE tracking_weblcms_submission_note;

/** AUGUST 2018 **/

INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Core\\Repository\\Workspace\\Extension\\Office365', 'Chamilo\\Core\\Repository\\Workspace\\Extension', 'Extension', 'Office365', '1', '1.0.0', '1');

CREATE TABLE `repository_workspace_office365_reference` (
  `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  `workspace_id` int(10) UNSIGNED NOT NULL,
  `office365_group_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
  `office365_plan_id` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci DEFAULT NULL,
  `linked` TINYINT(1) NOT NULL,
  PRIMARY KEY (id),
  KEY `rwor.workspace_id` (`workspace_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `menu_item` ADD `icon_class` VARCHAR(255) NULL AFTER `type`;

INSERT INTO `configuration_setting` (`context`, `variable`, `value`, `user_setting`) VALUES ('Chamilo\\Core\\Repository\\ContentObject\\Assignment', 'show_compact_feedback', '1', '0');

INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Libraries\\Authentication\\Anonymous', 'Chamilo\\Libraries\\Authentication', 'Authentication', 'AnonymousAuthentication', '1', '1.0.0', '1');
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Libraries\\Authentication\\Cas', 'Chamilo\\Libraries\\Authentication', 'Authentication', 'CasAuthentication', '1', '1.0.0', '1');
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Libraries\\Authentication\\Ldap', 'Chamilo\\Libraries\\Authentication', 'Authentication', 'LdapAuthentication', '1', '1.0.0', '1');
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Libraries\\Authentication\\Platform', 'Chamilo\\Libraries\\Authentication', 'Authentication', 'PlatformAuthentication', '1', '1.0.0', '1');
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES (NULL, 'Chamilo\\Libraries\\Authentication\\SecurityToken', 'Chamilo\\Libraries\\Authentication', 'Authentication', 'SecurityTokenAuthentication', '1', '1.0.0', '1');

/** Notifications **/
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES
(null, 'Chamilo\\Core\\Notification', 'Chamilo\\Core', NULL, 'Notification', 1, '1.0.0', 1);
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES
(null, 'Chamilo\\Core\\Queue', 'Chamilo\\Core', NULL, 'Notification', 1, '1.0.0', 1);
INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES
(NULL, 'Chamilo\\Application\\Weblcms\\Bridge\\LearningPath\\Assignment', 'Chamilo\\Application\\Weblcms\\Bridge\\LearningPath', 'LearningPathBridge', 'AssignmentLearningPathBridge', '1', '1.0.0', '1');

INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES
  (NULL, 'Chamilo\\Application\\Weblcms\\Bridge\\Assignment', 'Chamilo\\Application\\Weblcms\\Bridge', 'WeblcmsBridge', 'AssignmentBridge', '1', '1.0.0', '1');

CREATE TABLE `queue_job` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `date` datetime NOT NULL,
  `status` int(11) NOT NULL,
  `processor_class` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `qn_date` (`date`),
  KEY `qn_status` (`status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `queue_job_parameter` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `job_id` int(11) DEFAULT NULL,
  `name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
  `value` varchar(20) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_98B774A3BE04EA9` (`job_id`),
  KEY `qjp_name` (`name`),
  KEY `qjp_value` (`value`),
  KEY `qjp_name_value` (`name`,`value`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `queue_queue` (
  `id` char(36) COLLATE utf8_unicode_ci NOT NULL COMMENT '(DC2Type:guid)',
  `published_at` bigint(20) NOT NULL,
  `body` longtext COLLATE utf8_unicode_ci,
  `headers` longtext COLLATE utf8_unicode_ci,
  `properties` longtext COLLATE utf8_unicode_ci,
  `redelivered` tinyint(1) DEFAULT NULL,
  `queue` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `priority` smallint(6) NOT NULL,
  `delayed_until` int(11) DEFAULT NULL,
  `time_to_live` int(11) DEFAULT NULL,
  PRIMARY KEY (`id`),
  KEY `qq_published_at` (`published_at`),
  KEY `qq_queue` (`queue`),
  KEY `qq_priority` (`priority`),
  KEY `qq_delayed_until` (`delayed_until`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `queue_job_parameter`
  ADD CONSTRAINT `FK_98B774A3BE04EA9` FOREIGN KEY (`job_id`) REFERENCES `queue_job` (`id`);

CREATE TABLE `notification_context` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `path` varchar(512) COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `nc_path` (`path`(255))
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `notification_filter` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `description_context` longtext COLLATE utf8_unicode_ci NOT NULL,
  `notification_context` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_BB63A140F7430FC9` (`notification_context`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `notification_filter_relation` (
  `notification_id` int(11) NOT NULL ,
  `filter_id` int(11) NOT NULL,
  PRIMARY KEY (`notification_id`,`filter_id`),
  KEY `IDX_3E6F53F2EF1A9D84` (`notification_id`),
  KEY `IDX_3E6F53F2D395B25E` (`filter_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `notification_notification` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `url` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `date` datetime NOT NULL,
  `description_context` longtext COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`),
  KEY `nn_date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `notification_user_filter` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `filter_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_CF0D7761D395B25E` (`filter_id`),
  KEY `nuf_user_id` (`user_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE `notification_user_notification` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `notification_id` int(11) NOT NULL,
  `user_id` int(11) NOT NULL,
  `is_read` tinyint(1) NOT NULL,
  `notification_context` int(11) NOT NULL,
  `is_viewed` tinyint(1) NOT NULL,
  `date` datetime NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_FC1E8029EF1A9D84` (`notification_id`),
  KEY `nun_read` (`is_read`),
  KEY `nun_user_id` (`user_id`),
  KEY `nun_user_read` (`user_id`,`is_read`),
  KEY `IDX_FC1E8029F7430FC9` (`notification_context`),
  KEY `nun_viewed` (`is_viewed`),
  KEY `nun_date` (`date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

ALTER TABLE `notification_filter`
  ADD CONSTRAINT `FK_BB63A140F7430FC9` FOREIGN KEY (`notification_context`) REFERENCES `notification_context` (`id`);

ALTER TABLE `notification_filter_relation`
  ADD CONSTRAINT `FK_3E6F53F2D395B25E` FOREIGN KEY (`filter_id`) REFERENCES `notification_filter` (`id`),
  ADD CONSTRAINT `FK_3E6F53F2EF1A9D84` FOREIGN KEY (`notification_id`) REFERENCES `notification_notification` (`id`);

ALTER TABLE `notification_user_filter`
  ADD CONSTRAINT `FK_CF0D7761D395B25E` FOREIGN KEY (`filter_id`) REFERENCES `notification_filter` (`id`);

ALTER TABLE `notification_user_notification`
  ADD CONSTRAINT `FK_FC1E8029EF1A9D84` FOREIGN KEY (`notification_id`) REFERENCES `notification_notification` (`id`),
  ADD CONSTRAINT `FK_FC1E8029F7430FC9` FOREIGN KEY (`notification_context`) REFERENCES `notification_context` (`id`);

ALTER TABLE tracking_weblcms_assignment_entry_attachment
    ADD COLUMN `created` int(11) NOT NULL;

ALTER TABLE tracking_weblcms_learning_path_assignment_entry_attachment
  ADD COLUMN `created` int(11) NOT NULL;

/** Teams */
ALTER TABLE `weblcms_course_group_office365_reference` ADD `office365_has_team` TINYINT(1) NOT NULL AFTER `linked`;

ALTER TABLE tracking_weblcms_learning_path_assignment_entry
    ADD `content_object_publication_id` int(11) NOT NULL AFTER ID,
    ADD INDEX `twlpae_content_object_publication_id` (`content_object_publication_id`);

UPDATE tracking_weblcms_learning_path_assignment_entry LPAE
JOIN tracking_weblcms_learning_path_tree_node_attempt TNA on LPAE.tree_node_attempt_id = TNA.id
    SET LPAE.content_object_publication_id = TNA.publication_id;

INSERT INTO `configuration_registration` (`id`, `context`, `type`, `category`, `name`, `status`, `version`, `priority`) VALUES
  (null, 'Chamilo\\Core\\Queue\\Integration\\Chamilo\\Core\\Admin', 'Chamilo\\Core\\Queue\\Integration', NULL, 'AdminIntegration', 1, '1.0.0', 1);

  ALTER TABLE `repository_learning_path_tree_node_data` ADD `configuration` TEXT NOT NULL AFTER `added_date`;
ALTER TABLE `repository_learning_path_tree_node_data` ADD `configuration_class` VARCHAR(255) NOT NULL AFTER `configuration`;

/** PLAGIARISM **/
/** INSTALL PLAGIARISM APP **/
CREATE TABLE `tracking_weblcms_assignment_entry_plagiarism_result` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `entry_id` INT(10) UNSIGNED NOT NULL ,
  `external_id` VARCHAR(255) NOT NULL ,
  `status` INT(10) UNSIGNED NOT NULL ,
  `result` INT(10) UNSIGNED NULL ,
  `error_code` VARCHAR(255) NULL ,
  PRIMARY KEY (`id`),
  INDEX (`entry_id`),
  INDEX (`external_id`)) ENGINE = InnoDB;

CREATE TABLE `tracking_weblcms_learning_path_assignment_entry_plagiarism` (
  `id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT ,
  `entry_id` INT(10) UNSIGNED NOT NULL ,
  `external_id` VARCHAR(255) NOT NULL ,
  `status` INT(10) UNSIGNED NOT NULL ,
  `result` INT(10) UNSIGNED NULL ,
  `error_code` VARCHAR(255) NULL ,
  PRIMARY KEY (`id`),
  INDEX (`entry_id`),
  INDEX (`external_id`)) ENGINE = InnoDB;

redpajama_set_name: RedPajamaGithub


text:
layout: post
title: components.templates.v2.template1.insurers
author: David Ballesteros
tags:
  - templates
  - v2
  - template1

categories:
  - components
  - templates
  - v2
  - template1
  - insurers

script: templates.v2.template1.insurers
componentsversion: 5.5.36
---
# insurers

*Namespace: templates.v2.template1*

## Extra Info available

| Name | Type | Description |
| --- | --- | --- |
| hideMobile | bool | Hide on mobile |


text:
package org.apache.any23.vocab;

import org.eclipse.rdf4j.model.IRI;

/**
 *

 * An implementation of the lkif-core vocabulary which is a
 * library of ontologies relevant for the legal domain. The library consists of 15 modules, each of which describes a
 * set of closely related concepts from both legal and commonsense domains.
 *

 *
 *

 * The modification module is both an extension of the time module and the legal action module. The time module is
 * extended with numerous intervals and moments describing the efficacy and being in force of legal documents. The
 * action module is extended with a typology of modifications. These concepts are described in further detail in
 * Deliverable 3.2 of the ESTRELLA project.
 *

 *
 * @author lewismc
 *
 */
public class LKIFCoreTimeModification extends Vocabulary {

    /**
     * The namespace of the vocabulary as a string.
     */
    public static final String NS = "http://www.estrellaproject.org/lkif-core/time-modification.owl#";

    private static LKIFCoreTimeModification instance;

    public static LKIFCoreTimeModification getInstance() {
        if (instance == null) {
            instance = new LKIFCoreTimeModification();
        }
        return instance;
    }

    ////////////////////////////////////////////////////////////////////
    /* http://www.estrellaproject.org/lkif-core/time-modification.owl */
    ////////////////////////////////////////////////////////////////////
    // CLASSES
    public final IRI Semantic_Annotation = createClass(NS, "Semantic_Annotation");
    public final IRI Modification = createClass(NS, "Modification");
    public final IRI Transposition = createClass(NS, "Transposition");
    public final IRI Ultractivity = createClass(NS, "Ultractivity");
    public final IRI Annulment = createClass(NS, "Annulment");
    public final IRI End_efficacy = createClass(NS, "End_efficacy");
    public final IRI Efficacy_Modification = createClass(NS, "Efficacy_Modification ");
    public final IRI Modification_of_System = createClass(NS, "Modification_of_System ");
    public final IRI Dynamic_Temporal_Entity = createClass(NS, "Dynamic_Temporal_Entity ");
    public final IRI Remaking = createClass(NS, "Remaking ");
    public final IRI Application = createClass(NS, "Application ");
    public final IRI Ratification = createClass(NS, "Ratification ");
    public final IRI Textual_Modification = createClass(NS, "Textual_Modification ");
    public final IRI Prorogation_in_Force = createClass(NS, "Prorogation_in_Force ");
    public final IRI Application_Date = createClass(NS, "Application_Date ");
    public final IRI Retroactivity = createClass(NS, "Retroactivity ");
    public final IRI Modification_of_Term = createClass(NS, "Modification_of_Term ");
    public final IRI Efficacy_Interval = createClass(NS, "Efficacy_Interval ");
    public final IRI Start_Efficacy = createClass(NS, "Start_Efficacy ");
    public final IRI Substitution = createClass(NS, "Substitution ");
    public final IRI Temporal_Modification = createClass(NS, "Temporal_Modification ");
    public final IRI Suspension = createClass(NS, "Suspension ");
    public final IRI In_Force_Modification = createClass(NS, "In_Force_Modification ");
    public final IRI Publication_Date = createClass(NS, "Publication_Date ");
    public final IRI Exception = createClass(NS, "Exception ");
    public final IRI Modification_of_Meaning = createClass(NS, "Modification_of_Meaning ");
    public final IRI Static_Temporal_Entity = createClass(NS, "Static_Temporal_Entity ");
    public final IRI End_in_Force = createClass(NS, "End_in_Force ");
    public final IRI Start_in_Force = createClass(NS, "Start_in_Force ");
    public final IRI Integration = createClass(NS, "Integration ");
    public final IRI Application_Interval = createClass(NS, "Application_Interval ");
    public final IRI Interpretation = createClass(NS, "Interpretation ");
    public final IRI Deregulation = createClass(NS, "Deregulation ");
    public final IRI In_Force_Interval = createClass(NS, "In_Force_Interval ");
    public final IRI Repeal = createClass(NS, "Repeal ");
    public final IRI Modification_of_Scope = createClass(NS, "Modification_of_Scope ");
    public final IRI Delivery_Date = createClass(NS, "Delivery_Date ");
    public final IRI Enter_in_Force_Date = createClass(NS, "Enter_in_Force_Date ");
    public final IRI Variation = createClass(NS, "Variation ");
    public final IRI Existence_Date = createClass(NS, "Existence_Date ");
    public final IRI Relocation = createClass(NS, "Relocation ");
    public final IRI Prorogation_Efficacy = createClass(NS, "Prorogation_Efficacy ");
    public final IRI Extension = createClass(NS, "Extension ");
    public final IRI Renewal = createClass(NS, "Renewal ");

    // RESOURCES

    // PROPERTIES
    public final IRI initial_date = createProperty(NS, "initial_date");
    public final IRI in_force = createProperty(NS, "in_force");
    public final IRI final_date_of = createProperty(NS, "final_date_of");
    public final IRI efficacy = createProperty(NS, "efficacy");
    public final IRI initial_date_of = createProperty(NS, "initial_date_of");
    public final IRI produce_efficacy_modification = createProperty(NS, "produce_efficacy_modification");
    public final IRI duration = createProperty(NS, "duration");
    public final IRI final_date = createProperty(NS, "final_date");
    public final IRI application = createProperty(NS, "application");
    public final IRI date = createProperty(NS, "date");
    public final IRI produce_textual_modification = createProperty(NS, "produce_textual_modification");
    public final IRI produce_inforce_modification = createProperty(NS, "produce_inforce_modification");

    private LKIFCoreTimeModification() {
        super(NS);
    }

}


text:
// ==========================================================================
//                 SeqAn - The Library for Sequence Analysis
// ==========================================================================
// Copyright (c) 2006-2013, Knut Reinert, FU Berlin
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//     * Neither the name of Knut Reinert or the FU Berlin nor the names of
//       its contributors may be used to endorse or promote products derived
//       from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
// ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
// OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
// DAMAGE.
//
// ==========================================================================
// Author: Andreas Gogol-Doering <andreas.doering@mdc-berlin.de>
// Author: David Weese <david.weese@fu-berlin.de>
// ==========================================================================
// Adaptions for STL strings to SeqAn strings.
// ==========================================================================

#ifndef SEQAN_SEQUENCE_ADAPT_STD_STRING_H_
#define SEQAN_SEQUENCE_ADAPT_STD_STRING_H_

namespace seqan {

// ===========================================================================
// Enums, Tags, Classes, Specializations
// ===========================================================================

/**
.Adaption."std::basic_string"
..summary:Adaption for STL strings.
 */

// ===========================================================================
// Metafunctions
// ===========================================================================

///.Metafunction.StdContainerIterator.param.T.type:Adaption."std::basic_string"
///.Metafunction.StdContainerIterator.class:Adaption."std::basic_string"

template <typename TChar, typename TCharTraits, typename TAlloc>
struct StdContainerIterator< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef std::basic_string<TChar, TCharTraits, TAlloc> TContainer;
    typedef typename TContainer::iterator Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct StdContainerIterator< std::basic_string<TChar, TCharTraits, TAlloc> const>
{
    typedef std::basic_string<TChar, TCharTraits, TAlloc> TContainer;
    typedef typename TContainer::const_iterator Type;
};

///.Metafunction.IsContiguous.param.T.type:Adaption.std::basic_string
///.Metafunction.IsContiguous.class:Adaption."std::basic_string"

template <typename TChar, typename TCharTraits, typename TAlloc>
struct IsContiguous< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    enum { VALUE = false };
};

template <typename  TChar, typename TCharTraits, typename TAlloc>
struct IsContiguous< std::basic_string<TChar, TCharTraits, TAlloc> const>
        : IsContiguous< std::basic_string<TChar, TCharTraits, TAlloc> > {};

///.Metafunction.Value.param.T.type:Adaption.std::basic_string
///.Metafunction.Value.class:Adaption."std::basic_string"

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Value< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::value_type Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Value< std::basic_string<TChar, TCharTraits, TAlloc> const>
        : Value< std::basic_string<TChar, TCharTraits, TAlloc> > {};

///.Metafunction.GetValue.param.T.type:Adaption.std::basic_string
///.Metafunction.GetValue.class:Adaption."std::basic_string"
// TODO(holtgrew): GetValue is a reference?! I thought the reverse was true in respect to Value<>.

template <typename TChar, typename TCharTraits, typename TAlloc>
struct GetValue< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::reference Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct GetValue< std::basic_string<TChar, TCharTraits, TAlloc> const>
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::const_reference Type;
};

///.Metafunction.Reference.param.T.type:Adaption.std::basic_string
///.Metafunction.Reference.class:Adaption."std::basic_string"

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Reference< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::reference Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Reference< std::basic_string<TChar, TCharTraits, TAlloc> const>
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::const_reference Type;
};

///.Metafunction.Iterator.param.T.type:Adaption.std::basic_string
///.Metafunction.Iterator.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>
{
    typedef std::basic_string<TChar, TCharTraits, TAlloc> TString_;
    typedef Iter<TString_, StdIteratorAdaptor> TIterator_;
    typedef Iter<TString_, AdaptorIterator<TIterator_> > Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Rooted>
{
    typedef std::basic_string<TChar, TCharTraits, TAlloc> const TString_;
    typedef Iter<TString_, StdIteratorAdaptor> TIterator_;
    typedef Iter<TString_, AdaptorIterator<TIterator_> > Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Standard >
{
    typedef Iter< std::basic_string<TChar, TCharTraits, TAlloc>, StdIteratorAdaptor > Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Standard>
{
    typedef Iter< std::basic_string<TChar, TCharTraits, TAlloc> const, StdIteratorAdaptor > Type;
};

///.Metafunction.Position.param.T.type:Adaption.std::basic_string
///.Metafunction.Position.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Position< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::size_type Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Position< std::basic_string<TChar, TCharTraits, TAlloc> const>
        : Position< std::basic_string<TChar, TCharTraits, TAlloc> > {};

///.Metafunction.Size.param.T.type:Adaption.std::basic_string
///.Metafunction.Size.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Size< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef typename std::basic_string<TChar, TCharTraits, TAlloc>::size_type Type;
};

template <typename TChar, typename TCharTraits, typename TAlloc>
struct Size< std::basic_string<TChar, TCharTraits, TAlloc> const>
        : Size< std::basic_string<TChar, TCharTraits, TAlloc> > {};

///.Metafunction.Size.param.T.type:Adaption.std::basic_string
///.Metafunction.Size.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
struct DefaultOverflowImplicit< std::basic_string<TChar, TCharTraits, TAlloc> >
{
    typedef Generous Type;
};

// ===========================================================================
// Functions
// ===========================================================================

///.Function.getObjectId.param.object.type:Adaption.std::basic_string
///.Function.getObjectId.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
inline void const *
getObjectId(std::basic_string<TChar, TCharTraits, TAlloc> const & me)
{
    SEQAN_CHECKPOINT;
    if (me.empty())
        return NULL;
    else
        return (& *(me.end() - 1)) + 1;
}

///.Function.begin.param.object.type:Adaption.std::basic_string
///.Function.begin.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Standard>::Type
begin(std::basic_string<TChar, TCharTraits, TAlloc> & me,
      Standard)
{
    SEQAN_CHECKPOINT;
    return typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Standard>::Type(me.begin());
}
template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Standard>::Type
begin(std::basic_string<TChar, TCharTraits, TAlloc> const & me,
      Standard)
{
    SEQAN_CHECKPOINT;
    return typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Standard>::Type(me.begin());
}

///.Function.end.param.object.type:Adaption.std::basic_string
///.Function.end.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Standard>::Type
end(std::basic_string<TChar, TCharTraits, TAlloc> & me,
    Standard)
{
    SEQAN_CHECKPOINT;
    return typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Standard>::Type(me.end());
}
template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Standard>::Type
end(std::basic_string<TChar, TCharTraits, TAlloc> const & me,
    Standard)
{
    SEQAN_CHECKPOINT;
    return typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc> const, Standard>::Type(me.end());
}

///.Function.value.param.container.type:Adaption.std::basic_string
///.Function.value.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TPos>
inline typename GetValue< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
value(std::basic_string<TChar, TCharTraits, TAlloc> & me,
      TPos pos)
{
    SEQAN_CHECKPOINT;
    return me[pos];
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TPos>
inline typename GetValue< std::basic_string<TChar, TCharTraits, TAlloc> const>::Type
value(std::basic_string<TChar, TCharTraits, TAlloc> const & me,
      TPos pos)
{
    SEQAN_CHECKPOINT;
    return me[pos];
}

///.Function.length.param.object.type:Adaption.std::basic_string
///.Function.length.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
length(std::basic_string<TChar, TCharTraits, TAlloc> const & me)
{
    SEQAN_CHECKPOINT;
    return me.length();
}

///.Function.capacity.param.object.type:Adaption.std::basic_string
///.Function.capacity.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
capacity(std::basic_string<TChar, TCharTraits, TAlloc> const & me)
{
    SEQAN_CHECKPOINT;
    return me.capacity();
}

///.Function.empty.param.object.type:Adaption.std::basic_string
///.Function.empty.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
inline bool
empty(std::basic_string<TChar, TCharTraits, TAlloc> const & me)
{
    SEQAN_CHECKPOINT;
    return me.empty();
}

///.Function.clear.param.object.type:Adaption.std::basic_string
///.Function.clear.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc>
inline void
clear(std::basic_string<TChar, TCharTraits, TAlloc> & me)
{
    SEQAN_CHECKPOINT;
    me.clear();
}

//////////////////////////////////////////////////////////////////////////////
//assign to std::basic_string

///.Function.assign.param.target.type:Adaption.std::basic_string
///.Function.assign.param.source.type:Adaption.std::basic_string
///.Function.assign.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source)
{
    SEQAN_CHECKPOINT;
    assign(target, source, Generous());
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source)
{
    SEQAN_CHECKPOINT;
    assign(target, source, Generous());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource, typename TSize>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       TSize limit)
{
    SEQAN_CHECKPOINT;
    assign(target, source, limit, Generous());
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource, typename TSize>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       TSize limit)
{
    SEQAN_CHECKPOINT;
    assign(target, source, limit, Generous());
}

//____________________________________________________________________________

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       Generous)
{
    SEQAN_CHECKPOINT;
    target.assign(begin(source, Standard()), end(source, Standard()));
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       Generous)
{
    SEQAN_CHECKPOINT;
    target.assign(begin(source, Standard()), end(source, Standard()));
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign_std_string_Generous_impl(std::basic_string<TChar, TCharTraits, TAlloc> & target,
                                TSource & source,
                                typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit)
{
    SEQAN_CHECKPOINT;
    typename Iterator<TSource const, Standard>::Type source_begin = begin(source, Standard());
    typename Size<TSource const>::Type source_length = length(source);
    if (source_length > limit)
    {
        source_length = limit;
    }
    target.assign(source_begin, source_begin + source_length);
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Generous)
{
    SEQAN_CHECKPOINT;
    assign_std_string_Generous_impl(target, source, limit);
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Generous)
{
    SEQAN_CHECKPOINT;
    assign_std_string_Generous_impl(target, source, limit);
}

//____________________________________________________________________________

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       Limit)
{
    SEQAN_CHECKPOINT;
    assign(target, source, target.capacity(), Generous());
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       Limit)
{
    SEQAN_CHECKPOINT;
    assign(target, source, target.capacity(), Generous());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Limit)
{
    SEQAN_CHECKPOINT;
    if (limit > target.capacity())
    {
        limit = target.capacity();
    }

    assign(target, source, limit, Generous());
}
template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
assign(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Limit)
{
    SEQAN_CHECKPOINT;
    if (limit > target.capacity())
    {
        limit = target.capacity();
    }

    assign(target, source, limit, Generous());
}

//////////////////////////////////////////////////////////////////////////////
//append to std::basic_string

///.Function.append.param.target.type:Adaption.std::basic_string
///.Function.append.param.source.type:Adaption.std::basic_string
///.Function.append.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
append(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       Generous)
{
    SEQAN_CHECKPOINT;
    target.append(begin(source, Standard()), end(source, Standard()));
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
append(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Generous)
{
    SEQAN_CHECKPOINT;
    typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type target_length = target.length();
    if (target_length > limit)
    {
        target.resize(limit);
    }
    else
    {
        limit -= target_length;
        typename Iterator<TSource const, Standard>::Type source_begin = begin(source, Standard());
        typename Size<TSource const>::Type source_length = length(source);
        if (source_length > limit)
        {
            source_length = limit;
        }
        target.append(source_begin, source_begin + source_length);
    }
}

//____________________________________________________________________________

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
append(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       Limit)
{
    SEQAN_CHECKPOINT;
    append(target, source, target.capacity(), Generous());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
append(std::basic_string<TChar, TCharTraits, TAlloc> & target,
       TSource const & source,
       typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
       Limit)
{
    SEQAN_CHECKPOINT;
    if (limit > target.capacity())
    {
        limit = target.capacity();
    }

    append(target, source, limit, Generous());
}

//////////////////////////////////////////////////////////////////////////////
///.Function.appendValue.param.target.type:Adaption.std::basic_string
///.Function.appendValue.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TValue, typename TTag>
inline void
appendValue(std::basic_string<TChar, TCharTraits, TAlloc> & me,
            TValue const & _value,
            TTag)
{
    SEQAN_CHECKPOINT;
    me.push_back(_value);
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TValue>
inline void
appendValue(std::basic_string<TChar, TCharTraits, TAlloc> & me,
            TValue const & _value,
            Limit)
{
    SEQAN_CHECKPOINT;
    if (capacity(me) > length(me)) me.push_back(_value);
}

//////////////////////////////////////////////////////////////////////////////
//replace to std::basic_string

///.Function.replace.param.target.type:Adaption.std::basic_string
///.Function.replace.param.source.type:Adaption.std::basic_string
///.Function.replace.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_begin,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_end,
        TSource const & source,
        Generous)
{
    SEQAN_CHECKPOINT;
    target.replace(target.begin() + pos_begin, target.begin() + pos_end, begin(source, Standard()), end(source, Standard()));
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_begin,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_end,
        TSource const & source,
        typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
        Generous)
{
    SEQAN_CHECKPOINT;
    if (pos_begin >= limit)
    {
        target.resize(limit);
    }
    else
    {
        typename Iterator<TSource const, Standard>::Type source_begin = begin(source, Standard());
        typename Size<TSource const>::Type source_length = length(source);
        typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_mid = pos_begin + source_length;
        if (pos_mid > limit)
        {
            target.replace(target.begin() + pos_begin, target.begin() + limit, source_begin, source_begin + limit - pos_begin);
            target.resize(limit);
        }
        else
        {
            target.replace(target.begin() + pos_begin, target.begin() + pos_end, source_begin, end(source, Standard()));
            if (target.length() > limit)
            {
                target.resize(limit);
            }
        }
    }
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_begin,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_end,
        TSource const & source,
        Limit)
{
    SEQAN_CHECKPOINT;
    replace(target, pos_begin, pos_end, source, target.capacity(), Generous());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSource>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_begin,
        typename Position< std::basic_string<TChar, TCharTraits, TAlloc> >::Type pos_end,
        TSource const & source,
        typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
        Limit)
{
    SEQAN_CHECKPOINT;
    if (limit > target.capacity())
    {
        limit = target.capacity();
    }

    replace(target, pos_begin, pos_end, source, limit, Generous());
}

//////////////////////////////////////////////////////////////////////////////
// handling of iterators as begin and end

/*
template<typename TChar, typename TCharTraits, typename TAlloc, typename TSource, typename TExpand>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>::Type pos_begin,
        typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>::Type pos_end,
        TSource & source,
        Tag<TExpand> tag)
{
    replace(target, position(pos_begin), position(pos_end), source, tag);
}

template<typename TChar, typename TCharTraits, typename TAlloc, typename TSource, typename TExpand>
inline void
replace(std::basic_string<TChar, TCharTraits, TAlloc> & target,
        typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>::Type pos_begin,
        typename Iterator< std::basic_string<TChar, TCharTraits, TAlloc>, Rooted>::Type pos_end,
        TSource & source,
        typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type limit,
        Tag<TExpand> tag)
{
    replace(target,  position(pos_begin),  position(pos_end), source, tag);
}
*/

///.Function.reserve.param.object.type:Adaption.std::basic_string
///.Function.reserve.remarks:For @Adaption.std::basic_string|STL Adaptions@, $reserve$ is only guaranteed to have the specified behaviour with $Insist$ and $Generous$.
///.Function.reserve.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize, typename TExpand>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
reserve(
    std::basic_string<TChar, TCharTraits, TAlloc> & seq,
    TSize new_capacity,
    Tag<TExpand> tag)
{
    SEQAN_CHECKPOINT;
    seq.reserve(new_capacity);
    return _capacityReturned(seq, new_capacity, tag);
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
reserve(
    std::basic_string<TChar, TCharTraits, TAlloc> & seq,
    TSize new_capacity,
    Insist const &)
{
    SEQAN_CHECKPOINT;
    // do nothing
    return _capacityReturned(seq, new_capacity, Insist());
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
reserve(
    std::basic_string<TChar, TCharTraits, TAlloc> & seq,
    TSize new_capacity,
    Limit const &)
{
    SEQAN_CHECKPOINT;
    // do nothing
    return _capacityReturned(seq, new_capacity, Limit());
}

///.Function.resize.param.object.type:Adaption.std::basic_string
///.Function.resize.class:Adaption.std::basic_string

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize, typename TExpand>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
resize(
    std::basic_string<TChar, TCharTraits, TAlloc> & me,
    TSize new_length,
    Tag<TExpand>)
{
    SEQAN_CHECKPOINT;
    me.resize(new_length);
    return me.length();
}

template <typename TChar, typename TCharTraits, typename TAlloc, typename TSize, typename TExpand>
inline typename Size< std::basic_string<TChar, TCharTraits, TAlloc> >::Type
resize(
    std::basic_string<TChar, TCharTraits, TAlloc> & me,
    TSize new_length,
    TChar const & val,
    Tag<TExpand>)
{
    SEQAN_CHECKPOINT;
    me.resize(new_length, val);
    return me.length();
}

}  // namespace seqan

#endif  // #ifndef SEQAN_SEQUENCE_ADAPT_STD_STRING_H_


text:
import os
import json

class ModuleManifest(object):
    def __init__(self, module_path):
        filename = os.path.join(module_path, 'module.manifest')

        try:
            with open(filename, 'r') as f:
                manifest = json.load(f)
        except StandardError as e:
            raise ModuleManifestError('unable to read manifest file: {}'.format(e))

        for key in ('type',):
            if key not in manifest:
                raise ModuleManifestError('manifest missing "{}" key'.format(key))
        self.type = manifest['type']

        if self.type not in ('system', 'unix'):
            raise ModuleManifestError('unknown module type: {}'.format(self.type))

        if self.type == 'system':
            raise NotImplementedError()

        if self.type == 'unix':
            for key in ('command',):
                if key not in manifest:
                    raise ModuleManifestError('manifest missing "{}" key'.format(key))

            self.command = manifest['command']

class ModuleManifestError(Exception):
    pass


text:
<?php
require_once 'PHPUnit/Framework/TestCase.php';
use Market\Module;

class ModuleTest extends PHPUnit_Framework_TestCase
{
	private $_module;
	public function setUp()
	{
		$this->_module = new Module();
		Zend\Loader\AutoloaderFactory::factory($this->_module->getAutoloaderConfig());
	}

	public function testModuleBootstrap()
	{
		$this->assertInstanceOf('Market\Module', $this->_module);
	}

}


text:
using BikeShare.Models;
using System.Linq;
using System.Web.Mvc;

namespace BikeShare.Controllers
{
    /// <summary>
    /// Handles display of all of the mostly static home and info areas.
    /// </summary>
    public class HomeController : Controller
    {
        private BikesContext context;

        public HomeController()
        {
            context = new BikesContext();
        }

        /// <summary>
        /// Displays a generic homepage.
        /// </summary>
        /// <returns>View with no ViewModel.</returns>
        public ActionResult Index()
        {
            ViewBag.homeHTML = context.settings.First().homeHTML;
            return View("Index");
        }

        /// <summary>
        /// Displays a page with information about the app.
        /// </summary>
        /// <returns>View with no ViewModel.</returns>
        public ActionResult About()
        {
            ViewBag.aboutHTML = context.settings.First().aboutHTML;
            return View("About");
        }

        public ActionResult Safety()
        {
            ViewBag.safetyHTML = context.settings.First().safetyHTML;
            return View();
        }

        public ActionResult FAQ()
        {
            ViewBag.FAQHTML = context.settings.First().FAQHTML;
            return View();
        }

        public ActionResult Contact()
        {
            ViewBag.contactHTML = context.settings.First().contactHTML;
            return View();
        }

        [ChildActionOnly]
        public ActionResult FooterPartial()
        {
            ViewBag.FooterHTML = context.settings.First().footerHTML;
            ViewBag.GoogleAnalyticsId = context.settings.First().GoogleAnalyticsId;
            return PartialView();
        }

        [ChildActionOnly]
        public ActionResult HeaderPartial()
        {
            ViewBag.appName = context.settings.First().appName;

            return PartialView();
        }

        [ChildActionOnly]
        public ActionResult AnnouncementPartial()
        {
            ViewBag.announcementHTML = context.settings.First().announcementHTML;
            return PartialView();
        }

        protected override void Dispose(bool disposing)
        {
            context.Dispose();
            base.Dispose(disposing);
        }
    }
}


text:
"""Just testing Git branching.
"""


text:
<?php

use Hubzero\Content\Migration\Base;

/**
 * Migration script for adding projects tables to support filesystem connections
 **/
class Migration20151030150411ComProjects extends Base
{
	/**
	 * Up
	 **/
	public function up()
	{
		// Add connections table
		if (!$this->db->tableExists('#__projects_connections'))
		{
			$query = "CREATE TABLE `#__projects_connections` (
						`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
						`name` varchar(255) DEFAULT NULL,
						`project_id` int(11) NOT NULL,
						`provider_id` int(11) NOT NULL,
						`params` text,
						PRIMARY KEY (`id`)
						) ENGINE=MyISAM DEFAULT CHARSET=utf8";
			$this->db->setQuery($query);
			$this->db->query();
		}

		// Add providers table
		if (!$this->db->tableExists('#__projects_connection_providers'))
		{
			$query = "CREATE TABLE `#__projects_connection_providers` (
						`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
						`alias` varchar(255) NOT NULL DEFAULT '',
						`name` varchar(255) NOT NULL DEFAULT '',
						PRIMARY KEY (`id`)
						) ENGINE=MyISAM DEFAULT CHARSET=utf8";
			$this->db->setQuery($query);
			$this->db->query();
		}
	}

	/**
	 * Down
	 **/
	public function down()
	{
		// Drop connections table
		if ($this->db->tableExists('#__projects_connections'))
		{
			$query = "DROP TABLE `#__projects_connections`";
			$this->db->setQuery($query);
			$this->db->query();
		}

		// Drop providers table
		if ($this->db->tableExists('#__projects_connection_providers'))
		{
			$query = "DROP TABLE `#__projects_connection_providers`";
			$this->db->setQuery($query);
			$this->db->query();
		}
	}
}