Java Data Sources > Working with the Server/Java Mapping > Gantt Charts > Working with Gantt Data Sources
 
Working with Gantt Data Sources
Presentation
Rogue Wave® Server Gantt data sources are new data sources for the Rogue Wave JViews Gantt chart. A Gantt data source connects and synchronizes a business model running in an Rogue Wave Server server to a Gantt model running and displayed in a JavaTM client. Rogue Wave Server offers a bidirectional synchronization between the two models through a mapping defined in an .ils view specification file.
Requirements
To work with Rogue Wave JViews data sources, make sure the following software is correctly installed on your machine:
*Rogue Wave Server
*Rogue Wave JViews 8.10
*Java SE 6
Example
Let us define a dynamic business model to manage the projects of a company. This company is organized into departments with employees. Projects are organized hierarchically starting from a main project called rootProject. Each project is assigned to a department, and is composed of tasks. These tasks or projects are viewed as activities. The activities are assigned to employees and they are ordered with a precedence relation.
Gantt Model
You can refer to the gantt.ilj file in the Gantt demo distributed with server to see how to instantiate your model in JavaScriptTM.
The synchronization between the business model on the server and the Gantt model is defined in the view specification, namely:
view GanttView (any containerIndex=0, string containerClass=""):
represent IlsDSRepresentation repres:
any containerIndex = view.containerIndex;
string containerClass = view.containerClass;
string title = "A gantt view";
subscribe origin CompanyModel:
represent IlsRpGanttModel gantt:
ref<IlsRpResource> rootResource = company->resource;
ref<IlsRpActivity> rootActivity = rootProject->activity;
collector constraints = precedences->constraint;
collector reservations = assignations->reservation;
# rootResource
propagate company;
# rootActivity
propagate rootProject;
# constraints
propagate precedences;
# reservations
propagate assignations;
# a company is assigned to a global project
represent IlsRpReservation reservation:
mandatory ref<IlsRpResource> resource = company->resource;
mandatory ref<IlsRpActivity> activity = rootProject->activity;
subscribe Company:
# rootResource
represent IlsRpResource resource:
mandatory ref<IlsRpGanttModel> gantt = view.origin->gantt;
# ref<IlsRpResource> parent = 0;
string id = identifier;
string name = name;
# resources
propagate departments;
subscribe Department:
represent IlsRpResource resource:
mandatory ref<IlsRpGanttModel> gantt = view.origin->gantt;
ref<IlsRpResource> parent = company->resource;
string id = identifier;
string name = name;
# resources
propagate employees;
subscribe Employee:
represent IlsRpResource resource:
mandatory ref<IlsRpGanttModel> gantt = view.origin->gantt;
ref<IlsRpResource> parent = department->resource;
string id = initials;
string name = name;
subscribe Activity:
represent IlsRpActivity activity:
# virtual representation for polymorphism
subscribe Project:
represent IlsRpActivity activity:
mandatory ref<IlsRpGanttModel> gantt = view.origin->gantt;
ref<IlsRpActivity> parent = superProject->activity;
string id = ID;
string name = name;
# date are in seconds
int startTime = startTime;
int endTime = endTime;
represent IlsRpReservation reservation:
mandatory ref<IlsRpResource> resource = department->resource;
mandatory ref<IlsRpActivity> activity = this->activity;
activities
propagate subProjects;
propagate tasks;
subscribe Task:
represent IlsRpActivity activity:
mandatory ref<IlsRpGanttModel> gantt = view.origin->gantt;
ref<IlsRpActivity> parent = project->activity;
string id = ID;
string name = name;
# date are in seconds
int startTime = startTime;
int endTime = endTime;
subscribe Precedence:
represent IlsRpConstraint constraint:
mandatory ref<IlsRpActivity> fromActivity =
beforeActivity->activity;
mandatory ref<IlsRpActivity> toActivity =
afterActivity->activity;
boolean fromStart = false;
boolean toStart = true;
subscribe Assignation:
represent IlsRpReservation reservation:
mandatory ref<IlsRpResource> resource = employee->resource;
mandatory ref<IlsRpActivity> activity = activity->activity;
This specification defines the view as follows:
*The instance of CompanyModel is mapped to a Gantt model representation object which is an instance of IlsRpGanttModel.
*Resource and activity hierarchies are propagated from their roots to the leaves.
* Company, departments and employees are seen as resources while project and tasks are activities in the Gantt model.
* The assignations are reservations and the precedence relation is mapped to end/start constraints.
*Dates are expressed in seconds. However, because in a Gantt model dates are in milliseconds, the adapter will by default automatically convert the dates (see the member functions setTimeFactor and setTimeConstant.
Your server is now ready to run. You are now going to create a Java client.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import ilog.server.jcomp.*;
import ilog.server.jsds.*;
import ilog.server.jsds.swing.*;
import java.awt.*;
public class MyGanttFrame extends JFrame {
IlsDSIlvScheduleChart schedule = new IlsDSIlvScheduleChart();
public MySDMFrame() {
getContentPane().add(schedule);
schedule.setServerName("ganttserver");
schedule.setObjectId("JCOM");
schedule.setViewId("GanttView");
schedule.setLabel("gantt");
schedule.connect();
}
public static void main(String[] args) {
IlsDSComponent.Initialize(args);
MyGanttFrame myFrame = new MyGanttFrame();
myFrame.setSize(512, 256);
myFrame.setVisible(true);
}
}
This Java client uses a high-level object (an instance of IlsDSIlvScheduleChart or IlsDSIlvGanttChart) containing:
*a data source container,
*an instance of IlsGanttDataSource,
*an instance of IlvScheduleChart or IlvGanttChart, and
*an adapter (IlsGanttDS2IlvHierarchyChartAdapter) to interface the data source with the Gantt data model.
This high level object manages the connection to the server and can be used to replace the adapter or the graphic component in managing the correct relations between the different objects.

Version 6.3
Copyright © 2018, Rogue Wave Software, Inc. All Rights Reserved.