コード例 #1
0
 public List<SkillContext> getEmployeeContexts(int employeeId) {
   open();
   Cursor c =
       myDatabase.rawQuery(
           "SELECT * FROM "
               + EMPLOYEE_CONTEXT_TABLE
               + " LEFT JOIN "
               + CONTEXT_TABLE
               + " USING ("
               + CONTEXT_ID
               + ") WHERE "
               + EMPLOYEE_ID
               + " = ? ORDER BY "
               + CONTEXT_NAME
               + " ASC",
           new String[] {Integer.toString(employeeId)});
   List<SkillContext> skillsContexts = new ArrayList<SkillContext>();
   int rId = c.getColumnIndex(CONTEXT_ID);
   int rName = c.getColumnIndex(CONTEXT_NAME);
   int rSkillGroup = c.getColumnIndex(CONTEXT_GROUP_ID);
   if (c != null) {
     for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext()) {
       SkillContext s = new SkillContext();
       s.setId(c.getInt(rId));
       s.setName(c.getString(rName));
       s.setContextGroupId(c.getInt(rSkillGroup));
       skillsContexts.add(s);
     }
   }
   close();
   return skillsContexts;
 }
コード例 #2
0
 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();
 }
コード例 #3
0
 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();
 }