Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Activiti/Activiti
Browse files Browse the repository at this point in the history
  • Loading branch information
tijsrademakers committed Mar 4, 2013
2 parents 2c57b60 + 96b27e6 commit 4639467
Show file tree
Hide file tree
Showing 15 changed files with 571 additions and 54 deletions.
2 changes: 2 additions & 0 deletions modules/activiti-explorer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId>
<scope>compile</scope>
</dependency>

<!-- Database -->
Expand Down Expand Up @@ -132,6 +133,7 @@
<groupId>org.vaadin.addons</groupId>
<artifactId>dcharts-widget</artifactId>
<version>0.10.0</version>
<scope>compile</scope>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,5 +476,7 @@ public interface Messages {
String TIME_UNIT_YEAR = "time.unit.year";
String TIME_UNIT_YEARS = "time.unit.years";
String TIME_UNIT_JUST_NOW = "time.unit.just.now";

String MONTH_PREFIX = "month.";

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@

import java.io.InputStream;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Random;

import org.activiti.editor.constants.ModelDataJsonConstants;
import org.activiti.engine.IdentityService;
Expand All @@ -24,9 +26,11 @@
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.Picture;
import org.activiti.engine.identity.User;
import org.activiti.engine.impl.util.ClockUtil;
import org.activiti.engine.impl.util.IoUtil;
import org.activiti.engine.repository.Deployment;
import org.activiti.engine.repository.Model;
import org.activiti.engine.task.Task;
import org.apache.commons.io.IOUtils;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.node.ObjectNode;
Expand All @@ -48,6 +52,7 @@ public class DemoDataGenerator implements ModelDataJsonConstants {
protected boolean createDemoUsersAndGroups;
protected boolean createDemoProcessDefinitions;
protected boolean createDemoModels;
protected boolean generateReportData;

public void init() {
this.identityService = processEngine.getIdentityService();
Expand Down Expand Up @@ -82,6 +87,10 @@ public void setCreateDemoProcessDefinitions(boolean createDemoProcessDefinitions
public void setCreateDemoModels(boolean createDemoModels) {
this.createDemoModels = createDemoModels;
}

public void setGenerateReportData(boolean generateReportData) {
this.generateReportData = generateReportData;
}

protected void initDemoGroups() {
String[] assignmentGroups = new String[] {"management", "sales", "marketing", "engineering"};
Expand Down Expand Up @@ -187,8 +196,33 @@ protected void initProcessDefinitions() {
.name(reportDeploymentName)
.addClasspathResource("org/activiti/explorer/demo/process/reports/taskDurationForProcessDefinition.bpmn20.xml")
.addClasspathResource("org/activiti/explorer/demo/process/reports/processInstanceOverview.bpmn20.xml")
.addClasspathResource("org/activiti/explorer/demo/process/reports/helpdeskFirstLineVsEscalated.bpmn20.xml")
.addClasspathResource("org/activiti/explorer/demo/process/reports/employeeProductivity.bpmn20.xml")
.deploy();
}

// Generate some data for the 'employee productivity' report
if (generateReportData) {
Date now = new Date();
ClockUtil.setCurrentTime(now);
for (int i=0; i<100; i++) {
processEngine.getRuntimeService().startProcessInstanceByKey("escalationExample");
}

Random random = new Random();
for (Task task : processEngine.getTaskService().createTaskQuery().list()) {
processEngine.getTaskService().complete(task.getId());

if (random.nextBoolean()) {
now = new Date(now.getTime() + ((24 * 60 * 60 * 1000) + (60 * 60 * 1000)));
ClockUtil.setCurrentTime(now);
}

}

ClockUtil.reset();
}

}

protected void initModelData() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.activiti.explorer.form;

import org.activiti.engine.form.AbstractFormType;


/**
* @author Joram Barrez
*/
public class MonthFormType extends AbstractFormType {

public static final String TYPE_NAME = "month";

public String getName() {
return TYPE_NAME;
}

@Override
public Object convertFormValueToModelValue(String propertyValue) {
Integer month = Integer.valueOf(propertyValue);
return month;
}

@Override
public String convertModelValueToFormValue(Object modelValue) {
if (modelValue == null) {
return null;
}
return modelValue.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,22 @@
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.persistence.entity.ExecutionEntity;
import org.activiti.engine.repository.ProcessDefinition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


/**
* @author Joram Barrez
*/
public class ReportingUtil {


public static Connection getCurrentDatabaseConnection() {
return Context.getCommandContext().getDbSqlSession().getSqlSession().getConnection();
}

public static ResultSet executeSelectSqlQuery(String sql) throws Exception {

Connection connection = getCurrentDatabaseConnection();
Statement select = connection.createStatement();
return select.executeQuery(sql);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.explorer.ui.form;

import java.util.Calendar;

import org.activiti.engine.form.FormProperty;
import org.activiti.explorer.ExplorerApp;
import org.activiti.explorer.I18nManager;
import org.activiti.explorer.Messages;
import org.activiti.explorer.form.MonthFormType;

import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Field;


/**
* @author Joram Barrez
*/
public class MonthFormPropertyRenderer extends AbstractFormPropertyRenderer {

private static final long serialVersionUID = 1L;

public MonthFormPropertyRenderer() {
super(MonthFormType.class);
}

public Field getPropertyField(FormProperty formProperty) {
ComboBox comboBox = new MonthCombobox(getPropertyLabel(formProperty));
comboBox.setRequired(formProperty.isRequired());
comboBox.setRequiredError(getMessage(Messages.FORM_FIELD_REQUIRED, getPropertyLabel(formProperty)));
comboBox.setEnabled(formProperty.isWritable());

// Fill combobox
I18nManager i18nManager = ExplorerApp.get().getI18nManager();
for (int i=0; i<12; i++) {
comboBox.addItem(i);
comboBox.setItemCaption(i, i18nManager.getMessage(Messages.MONTH_PREFIX + i));
}

// Select first
comboBox.setNullSelectionAllowed(false);
Calendar cal = Calendar.getInstance();
comboBox.select(cal.get(Calendar.MONTH));

return comboBox;
}


// See https://vaadin.com/forum/-/message_boards/view_message/142750
public class MonthCombobox extends ComboBox {

private static final long serialVersionUID = 1L;

public MonthCombobox(String s) {
super(s);
pageLength = 20;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,30 @@

import org.dussan.vaadin.dcharts.DCharts;

import com.vaadin.ui.Component;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;
import com.vaadin.ui.themes.Reindeer;


/**
* @author Joram Barrez
*/
public class ChartComponent extends VerticalLayout {

private static final long serialVersionUID = 1L;

public ChartComponent(String description, String errorMessage) {
this(description, null, errorMessage);
}

public ChartComponent(String description, DCharts dCharts) {
this(description, dCharts, null);
public ChartComponent(String title) {

if (title != null) {
Label label = new Label(title);
label.addStyleName(Reindeer.LABEL_H2);
addComponent(label);
}

}

public ChartComponent(String description, DCharts dCharts, String errorMessage) {

public void addChart(String description, Component chart, String errorMessage) {

addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));

Expand All @@ -43,18 +46,21 @@ public ChartComponent(String description, DCharts dCharts, String errorMessage)
Label label = new Label(description);
label.addStyleName(Reindeer.LABEL_H2);
addComponent(label);

addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
}

// Chart
if (dCharts != null) {
dCharts.setWidth(600, UNITS_PIXELS);
dCharts.setHeight(500, UNITS_PIXELS);
addComponent(dCharts);
dCharts.show();
if (chart != null) {
if (chart instanceof DCharts) {
// DCharts doesn't know how to size itself
chart.setWidth(600, UNITS_PIXELS);
chart.setHeight(450, UNITS_PIXELS);
((DCharts) chart).show();
}
addComponent(chart);
}

// Error message
if (errorMessage != null) {
Label errorLabel = new Label(errorMessage);
Expand Down
Loading

0 comments on commit 4639467

Please sign in to comment.