Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 42 → Rev 84

/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMClient.java
47,6 → 47,11
import net.brutex.sbm.wsclient.NameValue;
import net.brutex.sbm.wsclient.Note;
import net.brutex.sbm.wsclient.ObjectFactory;
import net.brutex.sbm.wsclient.ReportCategory;
import net.brutex.sbm.wsclient.ReportInfo;
import net.brutex.sbm.wsclient.ReportResult;
import net.brutex.sbm.wsclient.ReportsFilter;
import net.brutex.sbm.wsclient.RunReportResult;
import net.brutex.sbm.wsclient.TTItem;
import net.brutex.sbm.wsclient.TableData;
import net.brutex.sbm.wsclient.TableType;
139,6 → 144,41
return list;
}
public List<TTItem> getTTItemsByReport(String reportuuid) throws CoreException {
List<TTItem> list = new ArrayList<TTItem>();
try {
RunReportResult result = port.runReport(
getAuth(), of.createQueryRange(), reportuuid, null, null, null, null, null, null,
null, null, null, null, null);
List<ReportResult> resultlist = result.getResult();
for(ReportResult r : resultlist) {
list.add(port.getItem( getAuth(), r.getItemId().getValue(), null));
}
} catch (AEWebservicesFaultFault e) {
throw new CoreException(
RepositoryStatus.createInternalError(
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
}
return list;
}
public List<ReportInfo> getReportList(String solutionname) throws CoreException {
ReportsFilter filter = of.createReportsFilter();
List<ReportInfo> reportlist = new ArrayList<ReportInfo>();
filter.setSolutionName(of.createSolutionDataName(solutionname));
filter.setReportCategory(ReportCategory.USERREPORTS); //Limit this for now, because we execute by uuid only
try {
reportlist = port.getReports(getAuth(), null, filter).getReport();
} catch (AEWebservicesFaultFault e) {
throw new CoreException(
RepositoryStatus.createInternalError(
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
}
return reportlist;
}
public List<String> getResultCount(String tablename, String sql) throws CoreException {
List<TTItem> list = new ArrayList<TTItem>();
List<String> idlist = new ArrayList<String>();
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMTicketAttribute.java
37,7 → 37,7
SBMFieldTypes.TEXT,
TaskAttribute.DESCRIPTION,
TaskAttribute.TYPE_LONG_RICH_TEXT,
SBMTicketAttribute.HIDDEN), //hidden because has extra part
false), //hidden because has extra part
ID(
SBMStaticFields.ID.getValue(),
"ts_id",
44,7 → 44,7
SBMFieldTypes.SYSTEM,
TaskAttribute.TASK_KEY,
TaskAttribute.TYPE_SHORT_TEXT,
SBMTicketAttribute.HIDDEN),
false),
UUID(
SBMStaticFields.UUID.getValue(),
"ts_uuid",
51,7 → 51,7
SBMFieldTypes.SYSTEM,
TaskAttribute.KIND_DEFAULT,
TaskAttribute.TYPE_SHORT_TEXT,
SBMTicketAttribute.HIDDEN),
false),
PROJECT(
SBMStaticFields.PROJECTID.getValue(),
"label_project",
64,7 → 64,7
SBMFieldTypes.SYSTEM,
TaskAttribute.STATUS,
TaskAttribute.TYPE_SHORT_TEXT,
SBMTicketAttribute.HIDDEN), //hidden because has extra part
false), //hidden because has extra part
SUBMITTER(
SBMStaticFields.SUBMITTER.getValue(),
"label_submitter",
71,7 → 71,7
SBMFieldTypes.USER,
TaskAttribute.USER_REPORTER,
TaskAttribute.TYPE_PERSON,
SBMTicketAttribute.HIDDEN), //hidden because has extra part
false), //hidden because has extra part
SUBMITDATE(
SBMStaticFields.SUBMITDATE.getValue(),
"label_submitdate",
90,7 → 90,7
SBMFieldTypes.DATETIME,
TaskAttribute.DATE_MODIFICATION,
TaskAttribute.TYPE_DATETIME,
SBMTicketAttribute.HIDDEN), //hidden because has extra part
false), //hidden because has extra part
CLOSEDATE(
SBMStaticFields.CLOSEDATE.getValue(),
"label_closedate",
103,7 → 103,7
SBMFieldTypes.SYSTEM,
TaskAttribute.TASK_URL,
TaskAttribute.TYPE_URL,
SBMTicketAttribute.HIDDEN),
false),
TITLE(
"TITLE",
"label_title",
110,7 → 110,7
SBMFieldTypes.TEXT,
TaskAttribute.SUMMARY,
TaskAttribute.TYPE_SHORT_TEXT,
SBMTicketAttribute.HIDDEN), //hidden because has extra part
false), //hidden because has extra part
ACTIVEINACTIVE(
SBMStaticFields.ACTIVEINACTIVE.getValue(),
"label_activeinactive",
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMRepositoryConnector.java
26,6 → 26,7
 
import net.brutex.mylyn.sbmconnector.SBMConnectorPlugin;
import net.brutex.mylyn.sbmconnector.core.model.SBMStaticFields;
import net.brutex.mylyn.sbmconnector.ui.SBMQueryComposite;
import net.brutex.mylyn.sbmconnector.ui.SBMRepositoryQueryPage;
import net.brutex.mylyn.sbmconnector.ui.SBMRepositorySettingsPage;
import net.brutex.sbm.wsclient.TTItem;
34,7 → 35,6
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITask;
45,7 → 45,6
import org.eclipse.mylyn.tasks.core.data.TaskDataCollector;
import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
import org.eclipse.ui.statushandlers.StatusManager;
 
public class SBMRepositoryConnector extends AbstractRepositoryConnector {
 
121,7 → 120,7
@Override
public String getTaskUrl(String repositoryUrl, String taskId) {
// TODO Auto-generated method stub
return null;
return "http://something/I/havent/implemented/yet?"+taskId;
}
 
@Override
146,40 → 145,71
public IStatus performQuery(TaskRepository repository,
IRepositoryQuery query, TaskDataCollector collector,
ISynchronizationSession session, IProgressMonitor monitor) {
 
SBMClient client = new SBMClient(repository);
// do we use a report or a query?
if (query.getAttribute(SBMRepositoryQueryPage.SQL_QUERY_NAME).equals(
query.getAttribute(SBMRepositoryQueryPage.REPORT_OR_QUERY))) {
monitor.subTask("Calculating query result size ...");
try {
SBMClient client = new SBMClient(repository);
List<String> idlist = client.getResultCount(getQueryTable(repository),
query.getAttribute("sql_where"));
int countItem = idlist.size();
monitor.beginTask("", countItem);
monitor.subTask("Loading "+countItem+" items ...");
//List<TTItem> list = client.getTTItemsByTable(
// getQueryTable(repository), query.getAttribute("sql_where"),
// true);
monitor.worked(1);
int i = 1;
for (String id : idlist) {
if(id!=null) {
monitor.subTask("Loading item "+i+"/"+countItem+" ...");
TTItem ttitem = client.getTTItem("["+id+"]");
TaskData data = datahandler.convert(repository, ttitem,
monitor, query);
collector.accept(data);
try {
 
List<String> idlist = client.getResultCount(
getQueryTable(repository),
query.getAttribute("sql_where"));
int countItem = idlist.size();
monitor.beginTask("", countItem);
monitor.subTask("Loading " + countItem + " items ...");
 
// List<TTItem> list = client.getTTItemsByTable(
// getQueryTable(repository), query.getAttribute("sql_where"),
// true);
monitor.worked(1);
int i = 1;
for (String id : idlist) {
if (id != null) {
monitor.subTask("Loading item " + i + "/" + countItem
+ " ...");
TTItem ttitem = client.getTTItem("[" + id + "]");
TaskData data = datahandler.convert(repository, ttitem,
monitor, query);
collector.accept(data);
}
monitor.worked(1);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
i++;
}
monitor.worked(1);
if(monitor.isCanceled()) return Status.CANCEL_STATUS;
i++;
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR,
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e);
// StatusManager.getManager().handle(status,
// StatusManager.BLOCK);
return status;
} finally {
monitor.done();
}
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR, SBMConnectorPlugin.PLUGIN_ID,
e.getMessage(), e);
//StatusManager.getManager().handle(status, StatusManager.BLOCK);
return status;
} finally {
monitor.done();
} else {
// use report
monitor.beginTask("Loading Report", 0);
try {
List<TTItem> list = client.getTTItemsByReport(query
.getAttribute(SBMRepositoryQueryPage.REPORT));
for(TTItem i:list) {
TaskData data = datahandler.convert(repository, i,
monitor, query);
collector.accept(data);
}
} catch (CoreException e) {
IStatus status = new Status(IStatus.ERROR,
SBMConnectorPlugin.PLUGIN_ID, e.getMessage(), e);
// StatusManager.getManager().handle(status,
// StatusManager.BLOCK);
return status;
} finally {
monitor.done();
}
}
 
return Status.OK_STATUS;
}
 
206,7 → 236,6
return datahandler;
}
 
@Override
public boolean canDeleteTask(TaskRepository repository, ITask task) {
return false;
}
223,4 → 252,5
.getProperty(SBMRepositorySettingsPage.STRING_SOLUTIONTABLE);
}
 
}
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMTicketDataHandler.java
120,8 → 120,7
/**
* Convert.
*
* @param repository
* the repository
* @param repository the repository
* @param ttitem
* the ttitem
* @param monitor
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/ui/SBMRepositorySettingsPage.java
33,8 → 33,6
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositorySettingsPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/ui/SBMRepositoryQueryPage.java
20,10 → 20,12
package net.brutex.mylyn.sbmconnector.ui;
 
import java.awt.Color;
import java.util.ArrayList;
 
import net.brutex.mylyn.sbmconnector.core.SBMRepositoryConnector;
import net.brutex.mylyn.sbmconnector.core.model.SBMField;
import net.brutex.mylyn.sbmconnector.core.model.SBMSystemFields;
import net.brutex.sbm.wsclient.ReportInfo;
 
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.layout.GridDataFactory;
47,12 → 49,21
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
 
public class SBMRepositoryQueryPage extends AbstractRepositoryQueryPage {
 
private Text sql_where_clause = null;
private Text query_title = null;
private Combo reportcombo = null;
private ReportInfo selectedReport = null;
 
public static String SQL_QUERY = "sql_where";
public static String SQL_QUERY_NAME = "name";
public static String REPORT = "report";
public static String REPORT_OR_QUERY = "-- use query --";
 
public SBMRepositoryQueryPage(String pageName, TaskRepository repository,
IRepositoryQuery query) {
super(pageName, repository, query);
65,8 → 76,9
if (getQueryTitle() != null) {
query.setSummary(getQueryTitle());
}
query.setAttribute("sql_where", sql_where_clause.getText());
query.setAttribute("name", query_title.getText());
query.setAttribute(SQL_QUERY, sql_where_clause.getText());
query.setAttribute(SQL_QUERY_NAME, query_title.getText());
query.setAttribute(REPORT, selectedReport.getReportUUID());
}
 
@Override
80,18 → 92,84
public void createControl(Composite arg0) {
Composite control = new Composite(arg0, SWT.BORDER);
control.setLayout(new GridLayout(2, false));
 
Label report_label = new Label(control, SWT.NONE);
reportcombo = new Combo(control, SWT.SINGLE | SWT.BORDER);
new Label(control, SWT.NONE).setText(" OR ");
new Label(control, SWT.SEPARATOR | SWT.HORIZONTAL);
 
Label query_label = new Label(control, SWT.NONE);
query_label.setText("Query Name:");
 
report_label.setText("Report");
 
String solutionname = getTaskRepository().getProperty(
SBMRepositorySettingsPage.STRING_SOLUTIONTABLE);
 
try {
final java.util.List<ReportInfo> reportlist = SBMRepositoryConnector
.getClient(getTaskRepository()).getReportList(solutionname);
 
reportcombo.add(REPORT_OR_QUERY);
reportcombo.select(0);
for (ReportInfo report : reportlist) {
reportcombo.add(report.getReportName());
}
 
reportcombo.addListener(SWT.Selection, new Listener() {
 
@Override
public void handleEvent(Event arg0) {
if (reportcombo.getSelectionIndex() == 0) {
query_title.setEditable(true);
query_title.setEnabled(true);
sql_where_clause.setEditable(true);
sql_where_clause.setEnabled(true);
query_title.setText("");
} else {
query_title.setEditable(false);
query_title.setEnabled(false);
sql_where_clause.setEditable(false);
sql_where_clause.setEnabled(false);
query_title.setText(reportcombo.getText());
selectedReport = reportlist.get(reportcombo
.getSelectionIndex() - 1);
 
}
 
}
});
 
} catch (Exception e) {
}
/*
*
*
* table.addListener(SWT.Selection, new Listener() {
*
* @Override public void handleEvent(Event arg0) { // when the table has
* been changed // try to re-read the field list tableFieldList = "";
* tableFullFieldList = ""; try { SBMField[] fields =
* SBMRepositoryConnector.getClient(
* createTaskRepository()).getFields(table.getText()) .toArray(new
* SBMField[0]); fillList(list, fields); } catch (Exception e) { } if
* (getWizard() != null) { solutionTable = table.getText();
* getWizard().getContainer().updateButtons(); } }
*
* }); regenerateTables(); expander.setClient(control);
*/
 
query_title = new Text(control, SWT.BORDER);
if (getQuery() != null)
query_title.setText(getQuery().getAttribute("name"));
 
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
data.heightHint = 200;
 
Label label_sql = new Label(control, SWT.NONE);
label_sql.setText("SQL where:");
sql_where_clause = new Text(control, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
sql_where_clause = new Text(control, SWT.MULTI | SWT.WRAP
| SWT.V_SCROLL | SWT.BORDER);
GridData gd = new GridData(300, 150);
gd.horizontalSpan = 2;
sql_where_clause.setLayoutData(gd);
98,8 → 176,8
if (getQuery() != null)
sql_where_clause.setText(getQuery().getAttribute("sql_where"));
 
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).applyTo(
query_title);
GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP)
.applyTo(query_title);
Dialog.applyDialogFont(control);
setControl(control);
}