@Nullable
  @Override
  public String getLineText(int line, Editor editor) {
    VcsRevisionNumber revisionNumber = annotation.getLineRevisionNumber(line);
    if (revisionNumber == null) {
      return null;
    }
    if (devMotivePanel == null) {
      return "---";
    }
    Collection<WorkItem> workItems =
        devMotivePanel.getWorkItemsByRevisionNumber(revisionNumber, false);
    if (workItems == null) {
      return unknownLine;
    }
    StringBuffer buf = new StringBuffer();
    for (WorkItem workItem : workItems) {
      if (buf.length() > 0) {
        buf.append(", ");
      }
      switch (workItem.getType()) {
        case DEFECT:
          buf.append("D: ");
          break;

        case USER_STORY:
          buf.append("U: ");
          break;
      }
      buf.append(workItem.getId());
    }
    return buf.toString();
  }
 private String getWorkItemToolTip(WorkItem workItem) {
   if (WorkItem.Type.NONE.equals(workItem.getType())) {
     return workItem.getName();
   } else {
     return workItem.getType() + " #" + workItem.getId() + ": " + workItem.getName();
   }
 }
Esempio n. 3
0
  public final List<WorkItem> GetExecutingWorkItems(ActivityInst activityInst) {
    List<WorkItem> executingWorkItems = new ArrayList<WorkItem>();
    for (WorkItem workItem : getPersistence().GetWorkItems(activityInst.getId())) {
      if (workItem.getCurrentState() == (short) WorkItemStatus.Executing.getValue()) {
        executingWorkItems.add(workItem);
      }
    }

    return executingWorkItems;
  }
 /*
  * Method to indicate a work completion.
  */
 private void workCompleted(
     final WorkItem workItem, final Work work, final WorkSchedulerException exception) {
   WorkListener listener = workItems.get(workItem);
   if (listener != null) {
     workItem.setStatus(WorkEvent.WORK_COMPLETED);
     workItem.setResult(work);
     workItem.setException(exception);
     WorkEvent event = new WorkEvent(workItem);
     listener.workCompleted(event);
     workItems.remove(workItem);
   }
 }
Esempio n. 5
0
  @SuppressLint("InflateParams")
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    WorkItem item = getItem(position);

    if (convertView == null) {
      convertView = mInflater.inflate(R.layout.list_item, null);
      TextView worktime = (TextView) convertView.findViewById(R.id.worktime);
      TextView changed = (TextView) convertView.findViewById(R.id.changed);
      TextView totalyen = (TextView) convertView.findViewById(R.id.totalyen);
      TextView memo = (TextView) convertView.findViewById(R.id.memo);

      holder = new ViewHolder();
      holder.worktime = worktime;
      holder.changed = changed;
      holder.totalyen = totalyen;
      holder.memo = memo;

      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }
    double yen = (item.getHour() + (double) item.getMinute() / 60) * item.getJikyu();
    String yen_str = NumberFormat.getCurrencyInstance().format(yen);

    holder.worktime.setText(
        String.valueOf(item.getHour()) + "時間" + String.valueOf(item.getMinute()) + "分");
    holder.changed.setText("更新:" + item.getChanged());
    holder.totalyen.setText(yen_str);
    holder.memo.setText(item.getMemo());

    return convertView;
  }
 @Override
 public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
   if (currentWorkItem >= 0) {
     throw new RuntimeException("Existing work item was not completed correctly!");
   }
   currentWorkItem = workItem.getId();
 }
  /**
   * Schedules a unit of work asynchronously.
   *
   * @param work Work that needs to be scheduled.
   * @param workListener Work listener for callbacks.
   * @return Work Work item representing the asynchronous work
   */
  public WorkItem schedule(Work work, WorkListener workListener) throws IllegalArgumentException {

    WorkItem workItem = new WorkItem(UUID.randomUUID().toString(), work);
    if (workListener != null) {
      workItems.put(workItem, workListener);
    }
    workAccepted(workItem, work);
    if (scheduleWork(work, workItem)) {
      return workItem;
    } else {
      workItem.setStatus(WorkEvent.WORK_REJECTED);
      if (workListener != null) {
        workListener.workRejected(new WorkEvent(workItem));
      }
      throw new IllegalArgumentException("Unable to schedule work");
    }
  }
 /*
  * Method to indicate a work start.
  */
 private void workStarted(final WorkItem workItem, final Work work) {
   WorkListener listener = workItems.get(workItem);
   if (listener != null) {
     workItem.setStatus(WorkEvent.WORK_STARTED);
     WorkEvent event = new WorkEvent(workItem);
     listener.workStarted(event);
   }
 }
Esempio n. 9
0
  @Override
  public void tick(WorkItem item) {
    DateTime now = BusinessDateTimeFactory.now();

    if (now.equals(item.start) || now.isAfter(item.start)) {
      item.tryToStart();
    }
  }
  private boolean getNotification(String type)
      throws RemoteException, IllegalStateFault, IllegalAccessFault, IllegalArgumentFault,
          InterruptedException {

    boolean success = false;
    Thread.sleep(3000); // force delay otherwise getWorkItems return null
    // get all the management console notifications
    WorkItem[] workItems = WorkItemClient.getWorkItems(humanTaskAdminClient);
    for (WorkItem workItem : workItems) {
      // search for the correct notification
      if ((workItem.getPresentationSubject().toString()).contains(type)) {
        success = true;
        break;
      }
    }
    workItems = null;
    return success;
  }
Esempio n. 11
0
 @Override
 public void run() {
   while (bRunning) {
     long size = workQueue.size();
     if (size > 0) {
       System.out.println(System.currentTimeMillis() + "\t Work queue size:" + size);
     }
     WorkItem item = workQueue.poll();
     if (item != null) {
       item.process();
     } else {
       try {
         Thread.currentThread().sleep(10);
       } catch (InterruptedException e) {
         e.printStackTrace();
       }
     }
   }
 }
	/**
	 * Returns the view for a specific item on the list
	 */
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View row = convertView;

		final WorkItem currentItem = getItem(position);

		if (row == null) {
			LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
			row = inflater.inflate(mLayoutResourceId, parent, false);
		}

		row.setTag(currentItem);
		final CheckBox checkBox = (CheckBox) row
				.findViewById(R.id.checkToDoItem);
		final TextView txtDate = (TextView) row
				.findViewById(R.id.textDueDate);

		final Calendar c = Calendar.getInstance();
		c.setTime(currentItem.getDueDate());

		int year = c.get(Calendar.YEAR);
		int month = c.get(Calendar.MONTH);
		int day = c.get(Calendar.DAY_OF_MONTH);
		int hour = c.get(Calendar.HOUR_OF_DAY);
		int minute = c.get(Calendar.MINUTE);
		@SuppressWarnings("deprecation")
		String gmtTime = currentItem.getDueDate().toGMTString();
		// set current date into textview
		txtDate.setText(gmtTime);
		
		checkBox.setText(currentItem.getTitle());
		checkBox.setChecked(currentItem.isComplete());
		checkBox.setEnabled(true);
		checkBox.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View arg0) {
				if (checkBox.isChecked()) {
					checkBox.setEnabled(false);
					if (mContext instanceof ToDoActivity) {
						ToDoActivity activity = (ToDoActivity) mContext;
						activity.checkItem(currentItem);
					}
				}
			}
		});
		
		Date currentDate = new Date();
		row.setBackgroundResource(R.color.normal);
		if(currentItem.getDueDate().before(currentDate))
		{
			row.setBackgroundResource(R.color.highlight);	
		}
		
		return row;
	}
Esempio n. 13
0
 public void executeWorkItem(WorkItem workItem, WorkItemManager manager) {
   manager.completeWorkItem(workItem.getId(), null);
 }
Esempio n. 14
0
  public void testWorkItem() {
    KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
    Reader source =
        new StringReader(
            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
                + "<process xmlns=\"http://drools.org/drools-5.0/process\"\n"
                + "         xmlns:xs=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
                + "         xs:schemaLocation=\"http://drools.org/drools-5.0/process drools-processes-5.0.xsd\"\n"
                + "         type=\"RuleFlow\" name=\"flow\" id=\"org.drools.actions\" package-name=\"org.drools\" version=\"1\" >\n"
                + "\n"
                + "  <header>\n"
                + "    <variables>\n"
                + "      <variable name=\"UserName\" >\n"
                + "        <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n"
                + "        <value>John Doe</value>\n"
                + "      </variable>\n"
                + "      <variable name=\"Person\" >\n"
                + "        <type name=\"org.drools.core.process.core.datatype.impl.type.ObjectDataType\" className=\"org.jbpm.Person\" />\n"
                + "      </variable>\n"
                + "      <variable name=\"MyObject\" >\n"
                + "        <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n"
                + "      </variable>\n"
                + "      <variable name=\"Number\" >\n"
                + "        <type name=\"org.drools.core.process.core.datatype.impl.type.IntegerDataType\" />\n"
                + "      </variable>\n"
                + "    </variables>\n"
                + "  </header>\n"
                + "\n"
                + "  <nodes>\n"
                + "    <start id=\"1\" name=\"Start\" />\n"
                + "    <workItem id=\"2\" name=\"HumanTask\" >\n"
                + "      <work name=\"Human Task\" >\n"
                + "        <parameter name=\"ActorId\" >\n"
                + "          <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n"
                + "          <value>#{UserName}</value>\n"
                + "        </parameter>\n"
                + "        <parameter name=\"Content\" >\n"
                + "          <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n"
                + "          <value>#{Person.name}</value>\n"
                + "        </parameter>\n"
                + "        <parameter name=\"TaskName\" >\n"
                + "          <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n"
                + "          <value>Do something</value>\n"
                + "        </parameter>\n"
                + "        <parameter name=\"Priority\" >\n"
                + "          <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n"
                + "        </parameter>\n"
                + "        <parameter name=\"Comment\" >\n"
                + "          <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n"
                + "        </parameter>\n"
                + "        <parameter name=\"Attachment\" >\n"
                + "          <type name=\"org.drools.core.process.core.datatype.impl.type.StringDataType\" />\n"
                + "        </parameter>\n"
                + "      </work>\n"
                + "      <mapping type=\"in\" from=\"MyObject\" to=\"Attachment\" />"
                + "      <mapping type=\"in\" from=\"Person.name\" to=\"Comment\" />"
                + "      <mapping type=\"out\" from=\"Result\" to=\"MyObject\" />"
                + "      <mapping type=\"out\" from=\"Result.length()\" to=\"Number\" />"
                + "    </workItem>\n"
                + "    <end id=\"3\" name=\"End\" />\n"
                + "  </nodes>\n"
                + "\n"
                + "  <connections>\n"
                + "    <connection from=\"1\" to=\"2\" />\n"
                + "    <connection from=\"2\" to=\"3\" />\n"
                + "  </connections>\n"
                + "\n"
                + "</process>");
    kbuilder.add(ResourceFactory.newReaderResource(source), ResourceType.DRF);
    KnowledgeBase kbase = KnowledgeBaseFactory.newKnowledgeBase();
    kbase.addKnowledgePackages(kbuilder.getKnowledgePackages());
    StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

    TestWorkItemHandler handler = new TestWorkItemHandler();
    ksession.getWorkItemManager().registerWorkItemHandler("Human Task", handler);
    Map<String, Object> parameters = new HashMap<String, Object>();
    parameters.put("UserName", "John Doe");
    Person person = new Person();
    person.setName("John Doe");
    parameters.put("Person", person);
    WorkflowProcessInstance processInstance =
        (WorkflowProcessInstance) ksession.startProcess("org.drools.actions", parameters);
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    WorkItem workItem = handler.getWorkItem();
    assertNotNull(workItem);
    assertEquals("John Doe", workItem.getParameter("ActorId"));
    assertEquals("John Doe", workItem.getParameter("Content"));
    assertEquals("John Doe", workItem.getParameter("Comment"));
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), null);
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());

    parameters = new HashMap<String, Object>();
    parameters.put("UserName", "Jane Doe");
    parameters.put("MyObject", "SomeString");
    person = new Person();
    person.setName("Jane Doe");
    parameters.put("Person", person);
    processInstance =
        (WorkflowProcessInstance) ksession.startProcess("org.drools.actions", parameters);
    assertEquals(ProcessInstance.STATE_ACTIVE, processInstance.getState());
    workItem = handler.getWorkItem();
    assertNotNull(workItem);
    assertEquals("Jane Doe", workItem.getParameter("ActorId"));
    assertEquals("SomeString", workItem.getParameter("Attachment"));
    assertEquals("Jane Doe", workItem.getParameter("Content"));
    assertEquals("Jane Doe", workItem.getParameter("Comment"));
    Map<String, Object> results = new HashMap<String, Object>();
    results.put("Result", "SomeOtherString");
    ksession.getWorkItemManager().completeWorkItem(workItem.getId(), results);
    assertEquals(ProcessInstance.STATE_COMPLETED, processInstance.getState());
    assertEquals("SomeOtherString", processInstance.getVariable("MyObject"));
    assertEquals(15, processInstance.getVariable("Number"));
  }