Ejemplo n.º 1
0
 public Todo update(String todoId, String body) {
   Todo todo = new Gson().fromJson(body, Todo.class);
   collection.update(
       new BasicDBObject("_id", new ObjectId(todoId)),
       new BasicDBObject("$set", new BasicDBObject("done", todo.isDone())));
   return this.find(todoId);
 }
Ejemplo n.º 2
0
 public void createNewTodo(String body) {
   Todo todo = new Gson().fromJson(body, Todo.class);
   collection.insert(
       new BasicDBObject("title", todo.getTitle())
           .append("done", todo.isDone())
           .append("createdOn", new Date()));
 }
 /**
  * TODOフォーム画面を表示
  *
  * @param item TODOリストデータ
  */
 public void showTodoForm(Todo item) {
   String tag = TodoFormFragment.TAG;
   TodoFormFragment fragment;
   if (item == null) {
     // 新規作成
     fragment = TodoFormFragment.newInstance();
   } else {
     // 編集
     fragment =
         TodoFormFragment.newInstance(
             item.getId(), item.getColorLabel(), item.getValue(), item.getCreatedTime());
   }
   if (!mIsTablet) {
     // スマートフォンレイアウトの場合はcontainerに表示
     getSupportFragmentManager()
         .beginTransaction()
         .replace(R.id.container, fragment, tag)
         .addToBackStack(tag)
         .commit();
   } else {
     // タブレットレイアウトの場合はcontainer2に表示
     getSupportFragmentManager()
         .beginTransaction()
         .replace(R.id.container2, fragment, tag)
         .addToBackStack(tag)
         .commit();
   }
 }
  public List<Todo> getTodoItems() {
    ArrayList<Todo> todoItems = new ArrayList<Todo>();

    String TODO_SELECT_QUERY = "SELECT * FROM " + TABLE_TODO;

    SQLiteDatabase db = this.getReadableDatabase();
    Cursor cursor = db.rawQuery(TODO_SELECT_QUERY, null);

    try {
      if (cursor.moveToFirst()) {
        do {
          Todo todo = new Todo();
          todo.todoId = cursor.getInt(cursor.getColumnIndex(KEY_TODO_ID));
          todo.todoItem = cursor.getString(cursor.getColumnIndex(KEY_TODO_ITEM));

          // Convert ISO date string to date
          String isoDate = cursor.getString(cursor.getColumnIndex(KEY_TODO_DATE));
          SimpleDateFormat format = new SimpleDateFormat(ISO_FORMAT);
          todo.dueDate = format.parse(isoDate);

          todoItems.add(todo);
        } while (cursor.moveToNext());
      }
    } catch (Exception e) {
      Log.d(TAG, "Error while trying to get todo items from database");
    } finally {
      if (cursor != null && !cursor.isClosed()) {
        cursor.close();
      }
    }

    ToDoMainActivity.sortActivityItems(todoItems);

    return todoItems;
  }
Ejemplo n.º 5
0
 private Todo addTodoOn(int index) {
   Todo todo = new Todo(getContext());
   this.addView(todo, index);
   if (!(getChildAt(getChildCount() - 1) instanceof Text)) {
     this.addView(new Text(getContext()));
   }
   todo.focus();
   return todo;
 }
  private TodoDTO convertToDTO(Todo model) {
    TodoDTO dto = new TodoDTO();

    dto.setId(model.getId());
    dto.setTitle(model.getTitle());
    dto.setDescription(model.getDescription());

    return dto;
  }
Ejemplo n.º 7
0
  @Test
  public void testMongoTemplate() throws Exception {

    MongoOperations mongoOps = new MongoTemplate(new Mongo(), "organizer");
    Todo todo1 = new Todo();
    todo1.setId(new Random().nextLong());
    todo1.setTitle("some new todo " + UUID.randomUUID());
    mongoOps.insert(todo1);
    // mongoOps.dropCollection("person");
  }
  @Override
  public TodoDTO update(TodoDTO todo) {
    LOGGER.info("Updating todo entry with information: {}", todo);

    Todo updated = findTodoById(todo.getId());
    updated.update(todo.getTitle(), todo.getDescription());
    updated = repository.save(updated);

    LOGGER.info("Updated todo entry with information: {}", updated);

    return convertToDTO(updated);
  }
Ejemplo n.º 9
0
  public Node parse(String src) {
    init(src);

    for (Alt alt : startSymbol) {
      add(alt, start, 0, null);
    }

    while (!todo.isEmpty()) {
      Descriptor desc = todo.next();
      desc.parse(this);
    }

    return getResult();
  }
Ejemplo n.º 10
0
  @Override
  public View getGroupView(
      final int groupPosition, boolean isLastChild, View view, ViewGroup parent) {

    Todo todo = (Todo) getGroup(groupPosition);
    if (view == null) {
      LayoutInflater inf =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view = inf.inflate(R.layout.todo_list_item, null);
    }

    CheckBox cb_done = (CheckBox) view.findViewById(R.id.cb_checked);
    TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
    TextView tv_category = (TextView) view.findViewById(R.id.tv_category);
    tv_title.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Todo todo = todoList.get(groupPosition);
            expandOrCollapseListener.expandOrCollapseGroupOnClickEvent(
                groupPosition, todo.isExpanded());
            todo.setExpanded(!todo.isExpanded());
          }
        });
    tv_title.setOnLongClickListener(
        new View.OnLongClickListener() {
          @Override
          public boolean onLongClick(View v) {
            todoList.remove(groupPosition);
            notifyDataSetChanged();
            return false;
          }
        });
    cb_done.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            Log.v("EXP", "CHECKING");
            Todo todo = todoList.get(groupPosition);
            todo.setChecked(isChecked);
            notifyDataSetChanged();
          }
        });

    tv_title.setText(todo.getTitle());
    tv_category.setText(todo.getCategory().toString());
    cb_done.setChecked(todo.getChecked());
    onGroupExpanded(groupPosition);
    return view;
  }
Ejemplo n.º 11
0
    protected Enter(Context context) {
		DEBUG.P(this,"Enter(1)");
		context.put(enterKey, this);

		log = Log.instance(context);
		reader = ClassReader.instance(context);
		make = TreeMaker.instance(context);
		syms = Symtab.instance(context);
		chk = Check.instance(context);
		memberEnter = MemberEnter.instance(context);
		annotate = Annotate.instance(context);
		lint = Lint.instance(context);

		predefClassDef = make.ClassDef(
			make.Modifiers(PUBLIC),
			syms.predefClass.name, null, null, null, null);
		//predefClass是一个ClassSymbol(PUBLIC|ACYCLIC, names.empty, rootPackage)
		//且它的Scope members_field已有成员(几个基本类型符号(symbols for basic types)及其他操作符)
		//请参考Systab类的predefClass字段说明
		predefClassDef.sym = syms.predefClass;

		todo = Todo.instance(context);
		fileManager = context.get(JavaFileManager.class);
		
		names = Name.Table.instance(context);    //我加上的
		DEBUG.P(0,this,"Enter(1)");
    }
Ejemplo n.º 12
0
  @Override
  public View getChildView(
      int groupPosition, int childPosition, boolean isLastChild, View view, ViewGroup parent) {

    Log.v("EXP", "getChildView");
    Todo todo = (Todo) getChild(groupPosition, childPosition);
    if (view == null) {
      LayoutInflater infalInflater =
          (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      view = infalInflater.inflate(R.layout.todo_list_item_expanded, null);
    }

    TextView tv_fullContent = (TextView) view.findViewById(R.id.tv_fullContent);
    tv_fullContent.setText(todo.getContent());

    return view;
  }
Ejemplo n.º 13
0
  @Override
  public void visitTopLevel(JCCompilationUnit tree) {
    JavaFileObject prev = log.useSource(tree.sourcefile);
    boolean addEnv = false;
    boolean isPkgInfo =
        tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
    if (tree.pid != null) {
      tree.packge = reader.enterPackage(TreeInfo.fullName(tree.pid));
      if (tree.packageAnnotations.nonEmpty() || pkginfoOpt == PkgInfo.ALWAYS) {
        if (isPkgInfo) {
          addEnv = true;
        } else {
          log.error(tree.packageAnnotations.head.pos(), "pkg.annotations.sb.in.package-info.java");
        }
      }
    } else {
      tree.packge = syms.unnamedPackage;
    }
    tree.packge.complete(); // Find all classes in package.
    Env<AttrContext> topEnv = topLevelEnv(tree);

    // Save environment of package-info.java file.
    if (isPkgInfo) {
      Env<AttrContext> env0 = typeEnvs.get(tree.packge);
      if (env0 == null) {
        typeEnvs.put(tree.packge, topEnv);
      } else {
        JCCompilationUnit tree0 = env0.toplevel;
        if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) {
          log.warning(
              tree.pid != null ? tree.pid.pos() : null, "pkg-info.already.seen", tree.packge);
          if (addEnv
              || (tree0.packageAnnotations.isEmpty()
                  && tree.docComments != null
                  && tree.docComments.get(tree) != null)) {
            typeEnvs.put(tree.packge, topEnv);
          }
        }
      }

      for (Symbol q = tree.packge; q != null && q.kind == PCK; q = q.owner) q.flags_field |= EXISTS;

      Name name = names.package_info;
      ClassSymbol c = reader.enterClass(name, tree.packge);
      c.flatname = names.fromString(tree.packge + "." + name);
      c.sourcefile = tree.sourcefile;
      c.completer = null;
      c.members_field = new Scope(c);
      tree.packge.package_info = c;
    }
    classEnter(tree.defs, topEnv);
    if (addEnv) {
      todo.append(topEnv);
    }
    log.useSource(prev);
    result = null;
  }
  @Override
  public TodoDTO create(TodoDTO todo) {
    LOGGER.info("Creating a new todo entry with information: {}", todo);

    Todo persisted =
        Todo.getBuilder().title(todo.getTitle()).description(todo.getDescription()).build();

    persisted = repository.save(persisted);
    LOGGER.info("Created a new todo entry with information: {}", persisted);

    return convertToDTO(persisted);
  }
Ejemplo n.º 15
0
  public void visitTopLevel(JCCompilationUnit tree) {
    JavaFileObject prev = log.useSource(tree.sourcefile);
    boolean addEnv = false;
    boolean isPkgInfo =
        tree.sourcefile.isNameCompatible("package-info", JavaFileObject.Kind.SOURCE);
    if (tree.pid != null) {
      tree.packge = reader.enterPackage(TreeInfo.fullName(tree.pid));
      if (tree.packageAnnotations.nonEmpty()) {
        if (isPkgInfo) {
          addEnv = true;
        } else {
          log.error(tree.packageAnnotations.head.pos(), "pkg.annotations.sb.in.package-info.java");
        }
      }
    } else {
      tree.packge = syms.unnamedPackage;
    }
    tree.packge.complete(); // Find all classes in package.
    Env<AttrContext> env = topLevelEnv(tree);

    // Save environment of package-info.java file.
    if (isPkgInfo) {
      Env<AttrContext> env0 = typeEnvs.get(tree.packge);
      if (env0 == null) {
        typeEnvs.put(tree.packge, env);
      } else {
        JCCompilationUnit tree0 = env0.toplevel;
        if (!fileManager.isSameFile(tree.sourcefile, tree0.sourcefile)) {
          log.warning(
              tree.pid != null ? tree.pid.pos() : null, "pkg-info.already.seen", tree.packge);
          if (addEnv
              || (tree0.packageAnnotations.isEmpty()
                  && tree.docComments != null
                  && tree.docComments.get(tree) != null)) {
            typeEnvs.put(tree.packge, env);
          }
        }
      }
    }
    classEnter(tree.defs, env);
    if (addEnv) {
      todo.append(env);
    }
    log.useSource(prev);
    result = null;
  }
Ejemplo n.º 16
0
  private String listItems(HttpServletRequest request) {
    String html = "";

    Long userID = (Long) request.getSession().getAttribute("userID");
    if (userID == null) {
      return "You must log in first!";
    }

    for (Object o : DBUtil.get("SELECT t FROM Todo t WHERE t.completed != null")) {
      Todo t = (Todo) o;
      html += "<tr><td>" + t.getId() + "</td>";
      html += "<td>" + t.getName() + "</td>";
      html += "<td>" + t.getDescription() + "</td>";
      html += "<td>" + t.getDue() + "</td>";
      html += "<td>" + t.getCompleted() + "</td>";
      html += "<td>" + t.getStatusid() + "</td>";
      html += "<td>" + t.getPriority() + "</td></tr>";
    }
    return html;
  }
Ejemplo n.º 17
0
  protected Enter(Context context) {
    context.put(enterKey, this);

    log = Log.instance(context);
    reader = ClassReader.instance(context);
    make = TreeMaker.instance(context);
    syms = Symtab.instance(context);
    chk = Check.instance(context);
    memberEnter = MemberEnter.instance(context);
    types = Types.instance(context);
    annotate = Annotate.instance(context);
    lint = Lint.instance(context);

    predefClassDef =
        make.ClassDef(make.Modifiers(PUBLIC), syms.predefClass.name, null, null, null, null);
    predefClassDef.sym = syms.predefClass;
    todo = Todo.instance(context);
    fileManager = context.get(JavaFileManager.class);
  }
Ejemplo n.º 18
0
  public void testEquals() {
    Todo todo1 = new Todo();
    todo1.setTodoId("001");

    Todo todo2 = new Todo();
    todo2.setTodoId("001");

    assertEquals(todo1, todo2);

    Todo todo3 = new Todo();
    todo3.setTodoId("003");

    assertNotSame(todo1, todo3);
  }
Ejemplo n.º 19
0
 private Todo cursorToTodo(Cursor cursor) {
   Todo todo = new Todo();
   todo.setId(cursor.getLong(0));
   todo.setTodo(cursor.getString(1));
   return todo;
 }
Ejemplo n.º 20
0
 public void deleteTodo(Todo todo) {
   long id = todo.getId();
   System.out.println("Todo deleted with id: " + id);
   database.delete(MySQLiteHelper.TABLE_TODOS, MySQLiteHelper.COLUMN_ID + " = " + id, null);
 }
Ejemplo n.º 21
0
 public void add(IParser parser, GSS cu, int ci, Node cn) {
   todo.add(parser, cu, ci, cn);
 }
Ejemplo n.º 22
0
  public void testCompareTo() {
    Todo todo1 = new Todo();
    todo1.setTodoId("01");
    todo1.setCompleted(false);
    todo1.setDescription("Description");
    todo1.setPriority(0);

    Todo todo2 = new Todo();
    todo2.setTodoId("02");
    todo2.setCompleted(true);
    todo2.setDescription("Description");
    todo2.setPriority(0);

    Todo todo3 = new Todo();
    todo3.setTodoId("03");
    todo3.setCompleted(false);
    todo3.setDescription("Description");
    todo3.setPriority(10);

    Todo todo4 = new Todo();
    todo4.setTodoId("04");
    todo4.setCompleted(false);
    todo4.setDescription("AA");
    todo4.setPriority(10);

    Todo todo5 = new Todo();
    todo5.setTodoId("05");
    todo5.setCompleted(true);
    todo5.setDescription("Description");
    todo5.setPriority(10);

    Todo todo6 = new Todo();
    todo6.setTodoId("06");
    todo6.setCompleted(false);
    todo6.setDescription("Description");
    todo6.setPriority(10);

    Collection<Todo> sortedTodos = new TreeSet<Todo>();
    sortedTodos.add(todo2);
    sortedTodos.add(todo6);
    sortedTodos.add(todo4);
    sortedTodos.add(todo1);
    sortedTodos.add(todo5);
    sortedTodos.add(todo3);

    assertEquals(6, sortedTodos.size());
    Iterator<Todo> iterator = sortedTodos.iterator();

    Todo testTodo = iterator.next();
    assertEquals("04", testTodo.getTodoId());
    testTodo = iterator.next();
    assertEquals("03", testTodo.getTodoId());
    testTodo = iterator.next();
    assertEquals("06", testTodo.getTodoId());
    testTodo = iterator.next();
    assertEquals("01", testTodo.getTodoId());
    testTodo = iterator.next();
    assertEquals("05", testTodo.getTodoId());
    testTodo = iterator.next();
    assertEquals("02", testTodo.getTodoId());
  }
 private boolean isSameTodo(@PathVariable Long id, @RequestBody Todo todo) {
   return !id.equals(todo.getId());
 }
Ejemplo n.º 24
0
 public void loadJson(String folderPath) {
   String content = "";
   File file = new File(folderPath + "content.json");
   BufferedReader bufferedReader = null;
   try {
     bufferedReader = new BufferedReader(new FileReader(file));
     String read;
     while ((read = bufferedReader.readLine()) != null) {
       content += read;
     }
   } catch (FileNotFoundException e) {
     e.printStackTrace();
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     if (bufferedReader != null)
       try {
         bufferedReader.close();
       } catch (IOException e) {
         e.printStackTrace();
       }
   }
   this.removeAllViews();
   ArrayList<LinkedTreeMap> beans = new Gson().fromJson(content, ArrayList.class);
   if (beans == null) {
     return;
   }
   for (LinkedTreeMap<String, Object> bean : beans) {
     // F**k me.
     int type = (int) Math.round((Double) bean.get("type"));
     switch (type) {
       case Constants.TYPE_TEXT:
         Text text = addTextOn((int) Math.round((Double) bean.get("index")));
         SpannableString ssText = new SpannableString(Html.fromHtml((String) bean.get("text")));
         populateAdditionalStyles(bean, ssText);
         text.setText(ssText);
         break;
       case Constants.TYPE_IMAGE:
         Image img = addImageOn((int) Math.round((Double) bean.get("index")));
         img.setImage((String) bean.get("imgPath"), (int) Math.round((Double) bean.get("width")));
         break;
       case Constants.TYPE_TODO:
         Todo todo = addTodoOn((int) Math.round((Double) bean.get("index")));
         SpannableString ssTodo = new SpannableString(Html.fromHtml((String) bean.get("text")));
         populateAdditionalStyles(bean, ssTodo);
         // Why the hell there are to extra '\n' appended???
         ssTodo = (SpannableString) ssTodo.subSequence(0, ssTodo.length() - 2);
         todo.setText(ssTodo);
         todo.setChecked((Boolean) bean.get("checked"));
         break;
       case Constants.TYPE_ITEM:
         Item item = addItemOn((int) Math.round((Double) bean.get("index")));
         SpannableString ssItem = new SpannableString(Html.fromHtml((String) bean.get("text")));
         populateAdditionalStyles(bean, ssItem);
         ssItem = (SpannableString) ssItem.subSequence(0, ssItem.length() - 2);
         item.setText(ssItem);
         break;
       case Constants.TYPE_ATT:
         sun.bob.pooredit.views.File fileView =
             addFileOn((int) Math.round((Double) bean.get("index")));
         fileView.setFilePath((String) bean.get("filePath"));
         break;
       default:
         break;
     }
   }
 }