public void removeEmployeeContext(Employee employee, SkillContext context) {
   open();
   ContentValues cv = new ContentValues();
   cv.put(EMPLOYEE_ID, employee.getId());
   cv.put(CONTEXT_ID, context.getId());
   myDatabase.delete(
       EMPLOYEE_CONTEXT_TABLE,
       EMPLOYEE_ID + " =? AND " + CONTEXT_ID + " =?",
       new String[] {Integer.toString(employee.getId()), Integer.toString(context.getId())});
   close();
 }
 public void removeEmployeeMaterial(Employee employee, Material material) {
   open();
   ContentValues cv = new ContentValues();
   cv.put(EMPLOYEE_ID, employee.getId());
   cv.put(MATERIAL_ID, material.getId());
   myDatabase.delete(
       EMPLOYEE_MATERIAL_TABLE,
       EMPLOYEE_ID + " =? AND " + MATERIAL_ID + " =?",
       new String[] {Integer.toString(employee.getId()), Integer.toString(material.getId())});
   close();
 }
 public void removeEmployeeSkill(Employee employee, Skill skill) {
   open();
   ContentValues cv = new ContentValues();
   cv.put(EMPLOYEE_ID, employee.getId());
   cv.put(SKILL_ID, skill.getId());
   myDatabase.delete(
       EMPLOYEE_SKILL_TABLE,
       EMPLOYEE_ID + " =? AND " + SKILL_ID + " =?",
       new String[] {Integer.toString(employee.getId()), Integer.toString(skill.getId())});
   close();
 }
 public void addEmployeeContext(Employee employee, SkillContext context) {
   open();
   ContentValues cv = new ContentValues();
   cv.put(EMPLOYEE_ID, employee.getId());
   cv.put(CONTEXT_ID, context.getId());
   myDatabase.insert(EMPLOYEE_CONTEXT_TABLE, null, cv);
   close();
 }
 public void addEmployeeMaterial(Employee employee, Material material) {
   open();
   ContentValues cv = new ContentValues();
   cv.put(EMPLOYEE_ID, employee.getId());
   cv.put(MATERIAL_ID, material.getId());
   myDatabase.insert(EMPLOYEE_MATERIAL_TABLE, null, cv);
   close();
 }
 public void addEmployeeSkill(Employee employee, Skill skill) {
   open();
   ContentValues cv = new ContentValues();
   cv.put(EMPLOYEE_ID, employee.getId());
   cv.put(SKILL_ID, skill.getId());
   myDatabase.insert(EMPLOYEE_SKILL_TABLE, null, cv);
   close();
 }
 public int createEmployee(Employee employee, List<Skill> selectedSkills) {
   open();
   employee.setId((int) createBasicEmployee(employee));
   for (Skill skill : selectedSkills) {
     addEmployeeSkill(employee, skill);
   }
   close();
   return employee.getId();
 }
 /**
  * Update the employee with a new list of selected items
  *
  * @param employee
  * @param selectedItems
  */
 public void updateEmployee(Employee employee, List<? extends DatabaseObject> selectedItems) {
   open();
   updateEmployeeName(employee);
   int employeeId = employee.getId();
   if (selectedItems.get(0) instanceof Skill) {
     List<Skill> employeeSkills = getEmployeeSkills(employeeId);
     for (Skill skill : employeeSkills) {
       if (!alreadyInList(skill, selectedItems)) {
         removeEmployeeSkill(employee, skill);
       }
     }
     for (Object skill : selectedItems) {
       if (!alreadyInList(skill, employeeSkills)) {
         addEmployeeSkill(employee, (Skill) skill);
       }
     }
   } else if (selectedItems.get(0) instanceof Material) {
     List<Material> employeeMaterials = getEmployeeMaterials(employeeId);
     for (Material material : employeeMaterials) {
       if (!alreadyInList(material, selectedItems)) {
         removeEmployeeMaterial(employee, material);
       }
     }
     for (Object material : selectedItems) {
       if (!alreadyInList(material, employeeMaterials)) {
         addEmployeeMaterial(employee, (Material) material);
       }
     }
   } else if (selectedItems.get(0) instanceof SkillContext) {
     List<SkillContext> employeeContexts = getEmployeeContexts(employeeId);
     for (SkillContext context : employeeContexts) {
       if (!alreadyInList(context, selectedItems)) {
         removeEmployeeContext(employee, context);
       }
     }
     for (Object context : selectedItems) {
       if (!alreadyInList(context, employeeContexts)) {
         addEmployeeContext(employee, (SkillContext) context);
       }
     }
   }
   close();
 }
 private void updateEmployeeName(Employee e) {
   ContentValues cv = new ContentValues();
   cv.put(EMPLOYEE_NAME, e.getName());
   myDatabase.update(
       EMPLOYEE_TABLE, cv, EMPLOYEE_ID + "= ?", new String[] {String.valueOf(e.getId())});
 }