Subversion Repositories XServices

Compare Revisions

Ignore whitespace Rev 185 → Rev 42

/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMClient.java
47,11 → 47,6
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;
144,41 → 139,6
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/SBMRepositoryConnector.java
26,7 → 26,6
 
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;
35,6 → 34,7
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,6 → 45,7
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 {
 
120,7 → 121,7
@Override
public String getTaskUrl(String repositoryUrl, String taskId) {
// TODO Auto-generated method stub
return "http://something/I/havent/implemented/yet?"+taskId;
return null;
}
 
@Override
145,71 → 146,40
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 {
 
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);
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);
}
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++;
}
} 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();
if(monitor.isCanceled()) return Status.CANCEL_STATUS;
i++;
}
} 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();
}
} 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;
}
 
236,6 → 206,7
return datahandler;
}
 
@Override
public boolean canDeleteTask(TaskRepository repository, ITask task) {
return false;
}
252,5 → 223,4
.getProperty(SBMRepositorySettingsPage.STRING_SOLUTIONTABLE);
}
 
}
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMTicketDataHandler.java
120,7 → 120,8
/**
* Convert.
*
* @param repository the repository
* @param repository
* the repository
* @param ttitem
* the ttitem
* @param monitor
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/core/SBMTicketAttribute.java
37,7 → 37,7
SBMFieldTypes.TEXT,
TaskAttribute.DESCRIPTION,
TaskAttribute.TYPE_LONG_RICH_TEXT,
false), //hidden because has extra part
SBMTicketAttribute.HIDDEN), //hidden because has extra part
ID(
SBMStaticFields.ID.getValue(),
"ts_id",
44,7 → 44,7
SBMFieldTypes.SYSTEM,
TaskAttribute.TASK_KEY,
TaskAttribute.TYPE_SHORT_TEXT,
false),
SBMTicketAttribute.HIDDEN),
UUID(
SBMStaticFields.UUID.getValue(),
"ts_uuid",
51,7 → 51,7
SBMFieldTypes.SYSTEM,
TaskAttribute.KIND_DEFAULT,
TaskAttribute.TYPE_SHORT_TEXT,
false),
SBMTicketAttribute.HIDDEN),
PROJECT(
SBMStaticFields.PROJECTID.getValue(),
"label_project",
64,7 → 64,7
SBMFieldTypes.SYSTEM,
TaskAttribute.STATUS,
TaskAttribute.TYPE_SHORT_TEXT,
false), //hidden because has extra part
SBMTicketAttribute.HIDDEN), //hidden because has extra part
SUBMITTER(
SBMStaticFields.SUBMITTER.getValue(),
"label_submitter",
71,7 → 71,7
SBMFieldTypes.USER,
TaskAttribute.USER_REPORTER,
TaskAttribute.TYPE_PERSON,
false), //hidden because has extra part
SBMTicketAttribute.HIDDEN), //hidden because has extra part
SUBMITDATE(
SBMStaticFields.SUBMITDATE.getValue(),
"label_submitdate",
90,7 → 90,7
SBMFieldTypes.DATETIME,
TaskAttribute.DATE_MODIFICATION,
TaskAttribute.TYPE_DATETIME,
false), //hidden because has extra part
SBMTicketAttribute.HIDDEN), //hidden because has extra part
CLOSEDATE(
SBMStaticFields.CLOSEDATE.getValue(),
"label_closedate",
103,7 → 103,7
SBMFieldTypes.SYSTEM,
TaskAttribute.TASK_URL,
TaskAttribute.TYPE_URL,
false),
SBMTicketAttribute.HIDDEN),
TITLE(
"TITLE",
"label_title",
110,7 → 110,7
SBMFieldTypes.TEXT,
TaskAttribute.SUMMARY,
TaskAttribute.TYPE_SHORT_TEXT,
false), //hidden because has extra part
SBMTicketAttribute.HIDDEN), //hidden because has extra part
ACTIVEINACTIVE(
SBMStaticFields.ACTIVEINACTIVE.getValue(),
"label_activeinactive",
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/ui/SBMRepositorySettingsPage.java
33,6 → 33,8
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;
106,11 → 108,8
 
@Override
public boolean isPageComplete() {
if (table != null
&& table.getText().length() > 4
&& getUserName() != null
&& getUserName().length() > 0) {
return true;
if (table != null && table.getText().length() > 4) {
return super.isPageComplete();
}
return false;
}
/sbm4mylyn/trunk/src/net/brutex/mylyn/sbmconnector/ui/SBMRepositoryQueryPage.java
20,12 → 20,10
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;
49,21 → 47,12
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);
76,9 → 65,8
if (getQueryTitle() != null) {
query.setSummary(getQueryTitle());
}
query.setAttribute(SQL_QUERY, sql_where_clause.getText());
query.setAttribute(SQL_QUERY_NAME, query_title.getText());
query.setAttribute(REPORT, selectedReport.getReportUUID());
query.setAttribute("sql_where", sql_where_clause.getText());
query.setAttribute("name", query_title.getText());
}
 
@Override
92,84 → 80,18
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);
176,8 → 98,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);
}