mantisconnect-cvs Mailing List for MantisConnect (Page 6)
Brought to you by:
vboctor
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(20) |
Oct
(16) |
Nov
(1) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
|
Feb
(7) |
Mar
(7) |
Apr
|
May
(19) |
Jun
(22) |
Jul
(1) |
Aug
(2) |
Sep
(63) |
Oct
(1) |
Nov
|
Dec
(4) |
2006 |
Jan
|
Feb
(11) |
Mar
(26) |
Apr
(22) |
May
(13) |
Jun
|
Jul
|
Aug
(34) |
Sep
(15) |
Oct
(28) |
Nov
(7) |
Dec
|
2007 |
Jan
(14) |
Feb
|
Mar
(23) |
Apr
(3) |
May
(3) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(4) |
2008 |
Jan
(11) |
Feb
(34) |
Mar
|
Apr
|
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(7) |
2011 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <pl...@us...> - 2006-10-19 17:04:06
|
Revision: 76 http://svn.sourceforge.net/mantisconnect/?rev=76&view=rev Author: planser Date: 2006-10-19 10:03:59 -0700 (Thu, 19 Oct 2006) Log Message: ----------- Removed invalid TestSuite Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java Modified: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java 2006-10-19 14:31:50 UTC (rev 75) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java 2006-10-19 17:03:59 UTC (rev 76) @@ -35,7 +35,6 @@ // $JUnit-BEGIN$ suite.addTestSuite(MantisConnectPortTypeTest.class); suite.addTestSuite(SessionTest.class); - suite.addTestSuite(MantisConnectTask.class); suite.addTestSuite(IssueSubmitTaskTest.class); suite.addTestSuite(VersionAddTaskTest.class); suite.addTestSuite(VersionDeleteTaskTest.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-19 14:32:14
|
Revision: 75 http://svn.sourceforge.net/mantisconnect/?rev=75&view=rev Author: planser Date: 2006-10-19 07:31:50 -0700 (Thu, 19 Oct 2006) Log Message: ----------- Restructured layout of editor (moved section for custom fields on main page) Modified Paths: -------------- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/lib/mantisconnect-client-api-0.0.6.jar mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPage.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/GeneralPage.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/IssueEditor.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/TextSection.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/views/IssuesLabelProvider.java Added Paths: ----------- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/AdditionalInfoSection.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsSection.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/ExpandableTextSection.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/StepsToReproduceSection.java Removed Paths: ------------- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPart.java Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/lib/mantisconnect-client-api-0.0.6.jar =================================================================== (Binary files differ) Added: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/AdditionalInfoSection.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/AdditionalInfoSection.java (rev 0) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/AdditionalInfoSection.java 2006-10-19 14:31:50 UTC (rev 75) @@ -0,0 +1,41 @@ +/* + * Copyright 2005 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.eclipse.editors; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.forms.widgets.Section; + +/** + * @author Peter Lanser, pl...@us... + */ +public class AdditionalInfoSection extends ExpandableTextSection { + + public AdditionalInfoSection(IssuePage page, Composite parent) { + super(page, parent, Section.TITLE_BAR | Section.TWISTIE); + getSection().setText("Additional Information"); + getSection().setExpanded(! isEmpty(getIssue().getAdditional_information())); + } + + public void commit(boolean onSave) { + if (onSave) { + getIssue().setAdditional_information(text.getText()); + super.commit(onSave); + } + } + + public void refresh() { + text.setText(getIssue().getAdditional_information() != null ? getIssue() + .getAdditional_information() : ""); + super.refresh(); + } + +} Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPage.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPage.java 2006-10-19 14:26:23 UTC (rev 74) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPage.java 2006-10-19 14:31:50 UTC (rev 75) @@ -40,8 +40,8 @@ } } - private CustomFieldsPart createCustomFieldsPart(Composite parent) { - CustomFieldsPart part = new CustomFieldsPart(this, parent); + private CustomFieldsSection createCustomFieldsPart(Composite parent) { + CustomFieldsSection part = new CustomFieldsSection(this, parent); TableWrapData gd = new TableWrapData(TableWrapData.FILL_GRAB); part.getSection().setLayoutData(gd); return part; Deleted: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPart.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPart.java 2006-10-19 14:26:23 UTC (rev 74) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPart.java 2006-10-19 14:31:50 UTC (rev 75) @@ -1,158 +0,0 @@ -/* - * Copyright 2005 Peter Lanser - * - * MantisConnect is copyrighted to Victor Boctor - * - * This program is distributed under the terms and conditions of the GPL - * See LICENSE file for details. - * - * For commercial applications to link with or modify MantisConnect, they - * require the purchase of a MantisConnect commercial license. - */ -package org.mantisbt.connect.eclipse.editors; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.forms.widgets.FormToolkit; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.forms.widgets.TableWrapLayout; -import org.mantisbt.connect.ISession; -import org.mantisbt.connect.eclipse.CustomFieldType; -import org.mantisbt.connect.eclipse.MantisConnectPlugin; -import org.mantisbt.connect.eclipse.ui.customfields.CheckboxCustomFieldControl; -import org.mantisbt.connect.eclipse.ui.customfields.CustomFieldControl; -import org.mantisbt.connect.eclipse.ui.customfields.DateCustomFieldControl; -import org.mantisbt.connect.eclipse.ui.customfields.EmailCustomFieldControl; -import org.mantisbt.connect.eclipse.ui.customfields.EnumerationCustomFieldControl; -import org.mantisbt.connect.eclipse.ui.customfields.FloatCustomFieldControl; -import org.mantisbt.connect.eclipse.ui.customfields.ICustomFieldContainer; -import org.mantisbt.connect.eclipse.ui.customfields.ListCustomFieldControl; -import org.mantisbt.connect.eclipse.ui.customfields.NumericCustomFieldControl; -import org.mantisbt.connect.eclipse.ui.customfields.StringCustomFieldControl; -import org.mantisbt.connect.service.CustomFieldDefinitionData; -import org.mantisbt.connect.service.CustomFieldValueForIssueData; -import org.mantisbt.connect.service.IssueData; -import org.mantisbt.connect.service.ObjectRef; - -/** - * @author Peter Lanser, pl...@us... - */ -public class CustomFieldsPart extends IssuePart implements ICustomFieldContainer { - - private List<CustomFieldControl> controls; - - public CustomFieldsPart(IssuePage page, Composite parent) { - super(page, parent, Section.NO_TITLE); - } - - @Override - protected void createClient(Section section, FormToolkit toolkit) { - controls = new ArrayList<CustomFieldControl>(); - Composite container = toolkit.createComposite(section); - TableWrapLayout layout = new TableWrapLayout(); - layout.bottomMargin = layout.topMargin = layout.leftMargin = layout.rightMargin = 2; - layout.verticalSpacing = 7; - layout.numColumns = 4; - container.setLayout(layout); - for (CustomFieldValueForIssueData field : getIssue().getCustom_fields()) { - CustomFieldType type = getType(field.getField()); - CustomFieldControl control = null; - if (type != null) { - if (type.equals(CustomFieldType.STRING)) { - control = new StringCustomFieldControl(this, field); - } else if (type.equals(CustomFieldType.NUMERIC)) { - control = new NumericCustomFieldControl(this, field); - } else if (type.equals(CustomFieldType.FLOAT)) { - control = new FloatCustomFieldControl(this, field); - } else if (type.equals(CustomFieldType.ENUM)) { - control = new EnumerationCustomFieldControl(this, field); - } else if (type.equals(CustomFieldType.CHECKBOX)) { - control = new CheckboxCustomFieldControl(this, field); - } else if (type.equals(CustomFieldType.EMAIL)) { - control = new EmailCustomFieldControl(this, field); - } else if (type.equals(CustomFieldType.LIST)) { - control = new ListCustomFieldControl(this, field, true); - } else if (type.equals(CustomFieldType.MULTI_SELECTION_LIST)) { - control = new ListCustomFieldControl(this, field, false); - } else if (type.equals(CustomFieldType.DATE)) { - control = new DateCustomFieldControl(this, field); - } - if (control != null) { - control.fillIntoGrid(container, 2, toolkit); - controls.add(control); - } - } - } - toolkit.paintBordersFor(container); - section.setClient(container); - } - - @Override - public void commit(boolean onSave) { - if (onSave) { - for (CustomFieldControl control : controls) { - control.commit(); - } - super.commit(onSave); - } - } - - @Override - public void refresh() { - for (CustomFieldControl control : controls) { - control.refresh(); - } - super.refresh(); - } - - private CustomFieldType getType(ObjectRef field) { - CustomFieldDefinitionData[] definitions; - try { - definitions = getSession().getCustomFieldDefinitions( - getIssue().getProject().getId().longValue()); - } catch (Exception e) { - MantisConnectPlugin.getDefault().error("Could not get custom field definitions.", e, - false); - definitions = null; - } - if (definitions != null) { - for (CustomFieldDefinitionData definition : definitions) { - if (definition.getField().equals(field)) { - return CustomFieldType.fromType(definition.getType().intValue()); - } - } - } - return null; - } - - public void modified(CustomFieldControl source) { - markDirty(); - ((IssueEditor) getPage().getEditor()).validate(); - } - - public Shell getShell() { - return getPage().getSite().getShell(); - } - - public IssueData getIssue() { - return super.getIssue(); - } - - public ISession getSession() { - return super.getSession(); - } - - @Override - public IStatus[] validate() { - IStatus[] status = new IStatus[controls.size()]; - for (int i = 0; i < status.length; i++) { - status[i] = controls.get(i).validate(); - } - return status; - } - -} Copied: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsSection.java (from rev 66, mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsPart.java) =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsSection.java (rev 0) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/CustomFieldsSection.java 2006-10-19 14:31:50 UTC (rev 75) @@ -0,0 +1,159 @@ +/* + * Copyright 2005 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.eclipse.editors; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.forms.widgets.TableWrapLayout; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.eclipse.CustomFieldType; +import org.mantisbt.connect.eclipse.MantisConnectPlugin; +import org.mantisbt.connect.eclipse.ui.customfields.CheckboxCustomFieldControl; +import org.mantisbt.connect.eclipse.ui.customfields.CustomFieldControl; +import org.mantisbt.connect.eclipse.ui.customfields.DateCustomFieldControl; +import org.mantisbt.connect.eclipse.ui.customfields.EmailCustomFieldControl; +import org.mantisbt.connect.eclipse.ui.customfields.EnumerationCustomFieldControl; +import org.mantisbt.connect.eclipse.ui.customfields.FloatCustomFieldControl; +import org.mantisbt.connect.eclipse.ui.customfields.ICustomFieldContainer; +import org.mantisbt.connect.eclipse.ui.customfields.ListCustomFieldControl; +import org.mantisbt.connect.eclipse.ui.customfields.NumericCustomFieldControl; +import org.mantisbt.connect.eclipse.ui.customfields.StringCustomFieldControl; +import org.mantisbt.connect.service.CustomFieldDefinitionData; +import org.mantisbt.connect.service.CustomFieldValueForIssueData; +import org.mantisbt.connect.service.IssueData; +import org.mantisbt.connect.service.ObjectRef; + +/** + * @author Peter Lanser, pl...@us... + */ +public class CustomFieldsSection extends IssuePart implements ICustomFieldContainer { + + private List<CustomFieldControl> controls; + + public CustomFieldsSection(IssuePage page, Composite parent) { + super(page, parent, Section.TITLE_BAR | Section.TWISTIE | Section.EXPANDED); + getSection().setText("Custom Fields"); + } + + @Override + protected void createClient(Section section, FormToolkit toolkit) { + controls = new ArrayList<CustomFieldControl>(); + Composite container = toolkit.createComposite(section); + TableWrapLayout layout = new TableWrapLayout(); + layout.bottomMargin = layout.topMargin = layout.leftMargin = layout.rightMargin = 2; + layout.verticalSpacing = 7; + layout.numColumns = 4; + container.setLayout(layout); + for (CustomFieldValueForIssueData field : getIssue().getCustom_fields()) { + CustomFieldType type = getType(field.getField()); + CustomFieldControl control = null; + if (type != null) { + if (type.equals(CustomFieldType.STRING)) { + control = new StringCustomFieldControl(this, field); + } else if (type.equals(CustomFieldType.NUMERIC)) { + control = new NumericCustomFieldControl(this, field); + } else if (type.equals(CustomFieldType.FLOAT)) { + control = new FloatCustomFieldControl(this, field); + } else if (type.equals(CustomFieldType.ENUM)) { + control = new EnumerationCustomFieldControl(this, field); + } else if (type.equals(CustomFieldType.CHECKBOX)) { + control = new CheckboxCustomFieldControl(this, field); + } else if (type.equals(CustomFieldType.EMAIL)) { + control = new EmailCustomFieldControl(this, field); + } else if (type.equals(CustomFieldType.LIST)) { + control = new ListCustomFieldControl(this, field, true); + } else if (type.equals(CustomFieldType.MULTI_SELECTION_LIST)) { + control = new ListCustomFieldControl(this, field, false); + } else if (type.equals(CustomFieldType.DATE)) { + control = new DateCustomFieldControl(this, field); + } + if (control != null) { + control.fillIntoGrid(container, 2, toolkit); + controls.add(control); + } + } + } + toolkit.paintBordersFor(container); + section.setClient(container); + } + + @Override + public void commit(boolean onSave) { + if (onSave) { + for (CustomFieldControl control : controls) { + control.commit(); + } + super.commit(onSave); + } + } + + @Override + public void refresh() { + for (CustomFieldControl control : controls) { + control.refresh(); + } + super.refresh(); + } + + private CustomFieldType getType(ObjectRef field) { + CustomFieldDefinitionData[] definitions; + try { + definitions = getSession().getCustomFieldDefinitions( + getIssue().getProject().getId().longValue()); + } catch (Exception e) { + MantisConnectPlugin.getDefault().error("Could not get custom field definitions.", e, + false); + definitions = null; + } + if (definitions != null) { + for (CustomFieldDefinitionData definition : definitions) { + if (definition.getField().equals(field)) { + return CustomFieldType.fromType(definition.getType().intValue()); + } + } + } + return null; + } + + public void modified(CustomFieldControl source) { + markDirty(); + ((IssueEditor) getPage().getEditor()).validate(); + } + + public Shell getShell() { + return getPage().getSite().getShell(); + } + + public IssueData getIssue() { + return super.getIssue(); + } + + public ISession getSession() { + return super.getSession(); + } + + @Override + public IStatus[] validate() { + IStatus[] status = new IStatus[controls.size()]; + for (int i = 0; i < status.length; i++) { + status[i] = controls.get(i).validate(); + } + return status; + } + +} Added: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/ExpandableTextSection.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/ExpandableTextSection.java (rev 0) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/ExpandableTextSection.java 2006-10-19 14:31:50 UTC (rev 75) @@ -0,0 +1,53 @@ +package org.mantisbt.connect.eclipse.editors; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.forms.widgets.FormToolkit; +import org.eclipse.ui.forms.widgets.Section; +import org.eclipse.ui.forms.widgets.TableWrapData; +import org.eclipse.ui.forms.widgets.TableWrapLayout; + +public abstract class ExpandableTextSection extends IssuePart { + + protected Text text; + + public ExpandableTextSection(IssuePage page, Composite parent, String label) { + super(page, parent, Section.TITLE_BAR | Section.TWISTIE); + getSection().setText(label); + } + + public ExpandableTextSection(IssuePage page, Composite parent, int style) { + super(page, parent, style); + } + + public void createClient(Section section, FormToolkit toolkit) { + Composite container = toolkit.createComposite(section); + TableWrapLayout layout = new TableWrapLayout(); + layout.numColumns = 1; + layout.bottomMargin = layout.topMargin = layout.leftMargin = layout.rightMargin = 2; + layout.verticalSpacing = 7; + container.setLayout(layout); + text = createText(toolkit, container, "", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); + TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB); + twd.heightHint = 100; + text.setLayoutData(twd); + toolkit.paintBordersFor(container); + section.setClient(container); + } + + protected String getText() { + return text.getText(); + } + + @Override + public IStatus[] validate() { + return new IStatus[0]; + } + + protected boolean isEmpty(String string) { + return string == null || string.trim().length() == 0; + } + +} \ No newline at end of file Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/GeneralPage.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/GeneralPage.java 2006-10-19 14:26:23 UTC (rev 74) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/GeneralPage.java 2006-10-19 14:31:50 UTC (rev 75) @@ -91,6 +91,11 @@ managedForm.addPart(createMainAttributesSection(form.getBody())); managedForm.addPart(createDetailSection(form.getBody())); managedForm.addPart(createTextSection(form.getBody())); + managedForm.addPart(createAdditionalInfoSection(form.getBody())); + managedForm.addPart(createStepsToReproduceSection(form.getBody())); + if (getIssue().getCustom_fields() != null && getIssue().getCustom_fields().length > 0) { + managedForm.addPart(createCustomFieldsPart(form.getBody())); + } attachmentsSection = createAttachmentsSection(form.getBody()); managedForm.addPart(attachmentsSection); managedForm.addPart(createRelationshipsSection(form.getBody())); @@ -124,7 +129,31 @@ textSection.getSection().setLayoutData(gd); return textSection; } + + private ExpandableTextSection createAdditionalInfoSection(Composite parent) { + ExpandableTextSection textSection = new AdditionalInfoSection(this, parent); + TableWrapData gd = new TableWrapData(TableWrapData.FILL_GRAB); + gd.colspan = 2; + textSection.getSection().setLayoutData(gd); + return textSection; + } + private ExpandableTextSection createStepsToReproduceSection(Composite parent) { + ExpandableTextSection textSection = new StepsToReproduceSection(this, parent); + TableWrapData gd = new TableWrapData(TableWrapData.FILL_GRAB); + gd.colspan = 2; + textSection.getSection().setLayoutData(gd); + return textSection; + } + + private CustomFieldsSection createCustomFieldsPart(Composite parent) { + CustomFieldsSection part = new CustomFieldsSection(this, parent); + TableWrapData gd = new TableWrapData(TableWrapData.FILL_GRAB); + gd.colspan = 2; + part.getSection().setLayoutData(gd); + return part; + } + private MainAttributesSection createMainAttributesSection(Composite parent) { MainAttributesSection mainAttributesSection = new MainAttributesSection(this, parent); TableWrapData gd = new TableWrapData(TableWrapData.FILL_GRAB); Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/IssueEditor.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/IssueEditor.java 2006-10-19 14:26:23 UTC (rev 74) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/IssueEditor.java 2006-10-19 14:31:50 UTC (rev 75) @@ -58,9 +58,6 @@ protected void addPages() { try { addPage(new GeneralPage(this)); - if (getIssue().getCustom_fields() != null && getIssue().getCustom_fields().length > 0) { - addPage(new CustomFieldsPage(this)); - } addPage(new NotesPage(this)); URL url = ((IssueEditorInput) getEditorInput()).getUrlForIssue(); if (includeBrowserPage && url != null) { Added: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/StepsToReproduceSection.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/StepsToReproduceSection.java (rev 0) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/StepsToReproduceSection.java 2006-10-19 14:31:50 UTC (rev 75) @@ -0,0 +1,41 @@ +/* + * Copyright 2005 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.eclipse.editors; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.forms.widgets.Section; + +/** + * @author Peter Lanser, pl...@us... + */ +public class StepsToReproduceSection extends ExpandableTextSection { + + public StepsToReproduceSection(IssuePage page, Composite parent) { + super(page, parent, Section.TITLE_BAR | Section.TWISTIE); + getSection().setText("Steps To Reproduce"); + getSection().setExpanded(! isEmpty(getIssue().getSteps_to_reproduce())); + } + + public void commit(boolean onSave) { + if (onSave) { + getIssue().setSteps_to_reproduce(text.getText()); + super.commit(onSave); + } + } + + public void refresh() { + text.setText(getIssue().getSteps_to_reproduce() != null ? getIssue() + .getSteps_to_reproduce() : ""); + super.refresh(); + } + +} Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/TextSection.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/TextSection.java 2006-10-19 14:26:23 UTC (rev 74) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/TextSection.java 2006-10-19 14:31:50 UTC (rev 75) @@ -33,10 +33,6 @@ private Text description; - private Text additional; - - private Text stepsToReproduce; - public TextSection(IssuePage page, Composite parent) { super(page, parent); getSection().setText("Text"); @@ -61,18 +57,6 @@ twd.heightHint = 100; description.setLayoutData(twd); description.addModifyListener(validateListener); - toolkit.createLabel(container, "Additional Information:").setLayoutData( - new TableWrapData(TableWrapData.FILL)); - additional = createText(toolkit, container, "", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); - twd = new TableWrapData(TableWrapData.FILL_GRAB); - twd.heightHint = 100; - additional.setLayoutData(twd); - toolkit.createLabel(container, " Steps To Reproduce:").setLayoutData( - new TableWrapData(TableWrapData.FILL)); - stepsToReproduce = createText(toolkit, container, "", SWT.MULTI | SWT.WRAP | SWT.V_SCROLL); - twd = new TableWrapData(TableWrapData.FILL_GRAB); - twd.heightHint = 100; - stepsToReproduce.setLayoutData(twd); toolkit.paintBordersFor(container); section.setClient(container); } @@ -81,8 +65,6 @@ if (onSave) { getIssue().setSummary(summary.getText()); getIssue().setDescription(description.getText()); - getIssue().setAdditional_information(additional.getText()); - getIssue().setSteps_to_reproduce(stepsToReproduce.getText()); super.commit(onSave); } } @@ -90,10 +72,6 @@ public void refresh() { summary.setText(getIssue().getSummary() != null ? getIssue().getSummary() : ""); description.setText(getIssue().getDescription() != null ? getIssue().getDescription() : ""); - additional.setText(getIssue().getAdditional_information() != null ? getIssue() - .getAdditional_information() : ""); - stepsToReproduce.setText(getIssue().getSteps_to_reproduce() != null ? getIssue() - .getSteps_to_reproduce() : ""); super.refresh(); } Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/views/IssuesLabelProvider.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/views/IssuesLabelProvider.java 2006-10-19 14:26:23 UTC (rev 74) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/views/IssuesLabelProvider.java 2006-10-19 14:31:50 UTC (rev 75) @@ -169,7 +169,7 @@ private String getHandlerLabel(BigInteger projectId, BigInteger handler) { try { AccountData[] data = view.getSession().getProjectUsers( - projectId.longValue(), ISession.ANYBODY); + projectId.longValue(), ISession.AL_ANYBODY); for (AccountData account : data) { if (account.getId().equals(handler)) { return account.getName(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-19 14:26:41
|
Revision: 74 http://svn.sourceforge.net/mantisconnect/?rev=74&view=rev Author: planser Date: 2006-10-19 07:26:23 -0700 (Thu, 19 Oct 2006) Log Message: ----------- Some refactorings (submit issue via ant) Added support for adding, updating and deleting project versions via Ant Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java Modified: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java 2006-10-19 14:25:58 UTC (rev 73) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java 2006-10-19 14:26:23 UTC (rev 74) @@ -11,20 +11,21 @@ */ package org.mantisbt.connect; +import junit.framework.Test; +import junit.framework.TestSuite; + import org.mantisbt.connect.ant.taskdefs.IssueSubmitTaskTest; +import org.mantisbt.connect.ant.taskdefs.MantisConnectTask; +import org.mantisbt.connect.ant.taskdefs.VersionDeleteTaskTest; +import org.mantisbt.connect.ant.taskdefs.VersionAddTaskTest; +import org.mantisbt.connect.ant.taskdefs.VersionUpdateTaskTest; import org.mantisbt.connect.service.MantisConnectPortTypeTest; import org.mantisbt.connect.text.CheckboxCustomFieldFormatTest; import org.mantisbt.connect.text.DateCustomFieldFormatTest; import org.mantisbt.connect.text.ListCustomFieldFormatTest; import org.mantisbt.connect.text.StringCustomFieldFormatTest; -import junit.framework.Test; -import junit.framework.TestSuite; - /** - * @see org.mantisbt.connect.SessionTest - * @see org.mantisbt.connect.service.MantisConnectPortTypeTest - * * @author Peter Lanser, pl...@us... */ public class AllTests { @@ -34,7 +35,11 @@ // $JUnit-BEGIN$ suite.addTestSuite(MantisConnectPortTypeTest.class); suite.addTestSuite(SessionTest.class); + suite.addTestSuite(MantisConnectTask.class); suite.addTestSuite(IssueSubmitTaskTest.class); + suite.addTestSuite(VersionAddTaskTest.class); + suite.addTestSuite(VersionDeleteTaskTest.class); + suite.addTestSuite(VersionUpdateTaskTest.class); suite.addTestSuite(CheckboxCustomFieldFormatTest.class); suite.addTestSuite(DateCustomFieldFormatTest.class); suite.addTestSuite(ListCustomFieldFormatTest.class); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-19 14:26:10
|
Revision: 73 http://svn.sourceforge.net/mantisconnect/?rev=73&view=rev Author: planser Date: 2006-10-19 07:25:58 -0700 (Thu, 19 Oct 2006) Log Message: ----------- Some refactorings (submit issue via ant) Added support for adding, updating and deleting project versions via Ant Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/IssueSubmitTask.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/MantisConnectTask.java Added Paths: ----------- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionAddTask.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionDeleteTask.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionUpdateTask.java Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/IssueSubmitTask.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/IssueSubmitTask.java 2006-10-19 14:25:21 UTC (rev 72) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/IssueSubmitTask.java 2006-10-19 14:25:58 UTC (rev 73) @@ -41,8 +41,9 @@ * <p> * The following attributes are optional: * <ul> - * <li><b>proxHost</b> (mandatory if proxyPort is given)</li> - * <li><b>proxyPort</b> (mandatory if proxyHost is given)</li> + * <li><b>proxHost</b> (Mandatory if proxyPort is given)</li> + * <li><b>proxyPort</b> (Mandatory if proxyHost is given)</li> + * <li><b>category</b></li> * <li><b>version</b></li> * <li><b>reproducibility</b></li> * <li><b>severity</b></li> @@ -50,6 +51,10 @@ * <li><b>additionalInfo</b></li> * <li><b>stepsToReproduce</b></li> * <li><b>private</b></li> + * <li><b>platform</b></li> + * <li><b>os</b></li> + * <li><b>osVersion</b></li> + * <li><b>productBuild</b></li> * </ul> * </p> * <p> @@ -71,7 +76,7 @@ * </ul> * </p> * <p> - * <b>Support for custom fields</b> + * <b>Support for custom fields:</b> * </p> * <p> * Custom fields can be added by nesting <i>customfield</i> elements within a @@ -102,30 +107,33 @@ * <p> * * <pre> - * <taskdef name="submit" classname="org.mantisbt.connect.ant.taskdefs.IssueSubmitTask" classpath="${cp}" /> - * - * <target name="submit-issue"> - * <submit url="http://yourhost/mantis/mc/mantisconnect.php" - * username="AUser" password="APassword" - * project="AProjectName" - * category="ACategory" - * summary="ASummary" - * description="ADescription" - * version="AVersion" - * reproducibility="sometimes" - * severity="block" - * priority="high" - * additionalInfo="AdditionalInfo" - * platform="APlatform" - * os="AnOs" - * osVersion="AnOsVersion" - * productBuild="AProductBuild" - * stepsToReproduce="StepsToReproduce" - * private="true"/> - * <customfield name="AStringField" value="AValue"/> - * <customfield name="ADateField" value="02.05.1978" format="dd.MM.yy"/> - * </target> + * <taskdef name="submit" classname="org.mantisbt.connect.ant.taskdefs.IssueSubmitTask" classpath="${cp}" /> + * + * <target name="submit-issue"> + * <submit url="http://yourhost/mantis/mc/mantisconnect.php" + * username="AUser" + * password="APassword" + * project="AProjectName" + * category="ACategory" + * summary="ASummary" + * description="ADescription" + * version="AVersion" + * reproducibility="sometimes" + * severity="block" + * priority="high" + * additionalInfo="AdditionalInfo" + * platform="APlatform" + * os="AnOs" + * osVersion="AnOsVersion" + * productBuild="AProductBuild" + * stepsToReproduce="StepsToReproduce" + * private="true"> + * <customfield name="AStringField" value="AValue"/> + * <customfield name="ADateField" value="01.01.2000" format="dd.MM.yy"/> + * </submit> + * </target> * </pre> + * * </p> * * @author Peter Lanser, pl...@us... @@ -268,48 +276,41 @@ .size()]; for (int i = 0; i < fieldValues.length; i++) { CustomField customField = (CustomField) customFields.get(i); - fieldValues[i] = new CustomFieldValueForIssueData(customField - .getField(), customField.getMCValue()); + fieldValues[i] = new CustomFieldValueForIssueData(customField.getField(), customField + .getMCValue()); } issue.setCustom_fields(fieldValues); try { long issueId = session.addIssue(issue); - log("Added issue to '" + getUrl() + "' (ID " + issueId + ")"); + log("Added issue to project '" + project + "' at '" + getUrl() + "' (ID " + issueId + + ")"); } catch (JMTException e) { throw new BuildException("Could not add issue.", e); } } private ObjectRef getViewState() { - return new ObjectRef(isPrivate ? BigInteger - .valueOf(ISession.VS_PRIVATE) : BigInteger + return new ObjectRef(isPrivate ? BigInteger.valueOf(ISession.VS_PRIVATE) : BigInteger .valueOf(ISession.VS_PUBLIC), null); } private ObjectRef getPriority() { if (priority != null) { try { - return new ObjectRef(BigInteger.valueOf(Long - .parseLong(priority)), null); + return new ObjectRef(BigInteger.valueOf(Long.parseLong(priority)), null); } catch (NumberFormatException e) { if (priority.equalsIgnoreCase(PRIORITY_NONE)) { - return new ObjectRef(BigInteger.valueOf(PRIORITY_NONE_NUM), - null); + return new ObjectRef(BigInteger.valueOf(PRIORITY_NONE_NUM), null); } else if (priority.equalsIgnoreCase(PRIORITY_LOW)) { - return new ObjectRef(BigInteger.valueOf(PRIORITY_LOW_NUM), - null); + return new ObjectRef(BigInteger.valueOf(PRIORITY_LOW_NUM), null); } else if (priority.equalsIgnoreCase(PRIORITY_NORMAL)) { - return new ObjectRef(BigInteger - .valueOf(PRIORITY_NORMAL_NUM), null); + return new ObjectRef(BigInteger.valueOf(PRIORITY_NORMAL_NUM), null); } else if (priority.equalsIgnoreCase(PRIORITY_HIGH)) { - return new ObjectRef(BigInteger.valueOf(PRIORITY_HIGH_NUM), - null); + return new ObjectRef(BigInteger.valueOf(PRIORITY_HIGH_NUM), null); } else if (priority.equalsIgnoreCase(PRIORITY_URGENT)) { - return new ObjectRef(BigInteger - .valueOf(PRIORITY_URGENT_NUM), null); + return new ObjectRef(BigInteger.valueOf(PRIORITY_URGENT_NUM), null); } else if (priority.equalsIgnoreCase(PRIORITY_IMMEDIATE)) { - return new ObjectRef(BigInteger - .valueOf(PRIORITY_IMMEDIATE_NUM), null); + return new ObjectRef(BigInteger.valueOf(PRIORITY_IMMEDIATE_NUM), null); } } } @@ -319,33 +320,24 @@ private ObjectRef getSeverity() { if (severity != null) { try { - return new ObjectRef(BigInteger.valueOf(Long - .parseLong(severity)), null); + return new ObjectRef(BigInteger.valueOf(Long.parseLong(severity)), null); } catch (NumberFormatException e) { if (severity.equalsIgnoreCase(SEVERITY_FEATURE)) { - return new ObjectRef(BigInteger - .valueOf(SEVERITY_FEATURE_NUM), null); + return new ObjectRef(BigInteger.valueOf(SEVERITY_FEATURE_NUM), null); } else if (severity.equalsIgnoreCase(SEVERITY_TRIVIAL)) { - return new ObjectRef(BigInteger - .valueOf(SEVERITY_TRIVIAL_NUM), null); + return new ObjectRef(BigInteger.valueOf(SEVERITY_TRIVIAL_NUM), null); } else if (severity.equalsIgnoreCase(SEVERITY_TEXT)) { - return new ObjectRef(BigInteger.valueOf(SEVERITY_TEXT_NUM), - null); + return new ObjectRef(BigInteger.valueOf(SEVERITY_TEXT_NUM), null); } else if (severity.equalsIgnoreCase(SEVERITY_TWEAK)) { - return new ObjectRef( - BigInteger.valueOf(SEVERITY_TWEAK_NUM), null); + return new ObjectRef(BigInteger.valueOf(SEVERITY_TWEAK_NUM), null); } else if (severity.equalsIgnoreCase(SEVERITY_MINOR)) { - return new ObjectRef( - BigInteger.valueOf(SEVERITY_MINOR_NUM), null); + return new ObjectRef(BigInteger.valueOf(SEVERITY_MINOR_NUM), null); } else if (severity.equalsIgnoreCase(SEVERITY_MAJOR)) { - return new ObjectRef( - BigInteger.valueOf(SEVERITY_MAJOR_NUM), null); + return new ObjectRef(BigInteger.valueOf(SEVERITY_MAJOR_NUM), null); } else if (severity.equalsIgnoreCase(SEVERITY_CRASH)) { - return new ObjectRef( - BigInteger.valueOf(SEVERITY_CRASH_NUM), null); + return new ObjectRef(BigInteger.valueOf(SEVERITY_CRASH_NUM), null); } else if (severity.equalsIgnoreCase(SEVERITY_BLOCK)) { - return new ObjectRef( - BigInteger.valueOf(SEVERITY_BLOCK_NUM), null); + return new ObjectRef(BigInteger.valueOf(SEVERITY_BLOCK_NUM), null); } } } @@ -355,32 +347,22 @@ private ObjectRef getReproducibility() { if (reproducibility != null) { try { - return new ObjectRef(BigInteger.valueOf(Long - .parseLong(reproducibility)), null); + return new ObjectRef(BigInteger.valueOf(Long.parseLong(reproducibility)), null); } catch (NumberFormatException e) { if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_ALWAYS)) { - return new ObjectRef(BigInteger - .valueOf(REPRODUCIBILITY_ALWAYS_NUM), null); - } else if (reproducibility - .equalsIgnoreCase(REPRODUCIBILITY_SOMETIMES)) { - return new ObjectRef(BigInteger - .valueOf(REPRODUCIBILITY_SOMETIMES_NUM), null); - } else if (reproducibility - .equalsIgnoreCase(REPRODUCIBILITY_RANDOM)) { - return new ObjectRef(BigInteger - .valueOf(REPRODUCIBILITY_RANDOM_NUM), null); - } else if (reproducibility - .equalsIgnoreCase(REPRODUCIBILITY_HAVE_NOT_TRIED)) { - return new ObjectRef(BigInteger - .valueOf(REPRODUCIBILITY_HAVE_NOT_TRIED_NUM), null); - } else if (reproducibility - .equalsIgnoreCase(REPRODUCIBILITY_UNABLE_TO_REPRODUCE)) { - return new ObjectRef(BigInteger - .valueOf(REPRODUCIBILITY_UNABLE_TO_REPRODUCE_NUM), + return new ObjectRef(BigInteger.valueOf(REPRODUCIBILITY_ALWAYS_NUM), null); + } else if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_SOMETIMES)) { + return new ObjectRef(BigInteger.valueOf(REPRODUCIBILITY_SOMETIMES_NUM), null); + } else if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_RANDOM)) { + return new ObjectRef(BigInteger.valueOf(REPRODUCIBILITY_RANDOM_NUM), null); + } else if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_HAVE_NOT_TRIED)) { + return new ObjectRef(BigInteger.valueOf(REPRODUCIBILITY_HAVE_NOT_TRIED_NUM), null); - } else if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_NA)) { + } else if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_UNABLE_TO_REPRODUCE)) { return new ObjectRef(BigInteger - .valueOf(REPRODUCIBILITY_NA_NUM), null); + .valueOf(REPRODUCIBILITY_UNABLE_TO_REPRODUCE_NUM), null); + } else if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_NA)) { + return new ObjectRef(BigInteger.valueOf(REPRODUCIBILITY_NA_NUM), null); } } } @@ -392,8 +374,7 @@ try { return session.newIssue(projectData.getId().longValue()); } catch (JMTException e) { - throw new BuildException("Could not get initial data for '" - + project + "'.", e); + throw new BuildException("Could not get initial data for '" + project + "'.", e); } } @@ -408,16 +389,13 @@ protected void checkAttributes() { super.checkAttributes(); if (project == null) { - throw new BuildException("The project attribute must be present.", - getLocation()); + throw new BuildException("The project attribute must be present.", getLocation()); } if (summary == null) { - throw new BuildException("The summary attribute must be present.", - getLocation()); + throw new BuildException("The summary attribute must be present.", getLocation()); } if (description == null) { - throw new BuildException( - "The description attribute must be present.", getLocation()); + throw new BuildException("The description attribute must be present.", getLocation()); } } Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/MantisConnectTask.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/MantisConnectTask.java 2006-10-19 14:25:21 UTC (rev 72) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/MantisConnectTask.java 2006-10-19 14:25:58 UTC (rev 73) @@ -11,6 +11,7 @@ */ package org.mantisbt.connect.ant.taskdefs; +import java.net.MalformedURLException; import java.net.URL; import org.apache.tools.ant.BuildException; @@ -20,6 +21,7 @@ import org.mantisbt.connect.JMTException; import org.mantisbt.connect.SessionFactory; import org.mantisbt.connect.service.ProjectData; +import org.mantisbt.connect.service.ProjectVersionData; /** * <p> @@ -74,6 +76,12 @@ protected void checkAttributes() { if (url == null) { throw new BuildException("The url attribute must be present.", getLocation()); + } else { + try { + new URL(url); + } catch (MalformedURLException e) { + throw new BuildException(e); + } } if (username == null) { throw new BuildException("The username attribute must be present.", getLocation()); @@ -84,6 +92,9 @@ if (proxyHost != null && proxyPort == null) { throw new BuildException("The proxyPort attribute must be present.", getLocation()); } + if (proxyPort != null && proxyHost == null) { + throw new BuildException("The proxyHost attribute must be present.", getLocation()); + } if (proxyPort != null) { try { proxyPort.intValue(); @@ -91,9 +102,6 @@ throw new BuildException("The proxyPort attribute must be an integer.", getLocation()); } - if (proxyHost == null) { - throw new BuildException("The proxyHost attribute must be present.", getLocation()); - } } } @@ -114,6 +122,25 @@ throw new BuildException("Project '" + project + "' not found."); } + protected ProjectVersionData getVersionByName(String version, String project) { + ProjectData projectData = getProjectByName(project); + ProjectVersionData[] versions = null; + try { + versions = getSession().getVersions(projectData.getId().longValue()); + } catch (JMTException e) { + throw new BuildException("Could not get versions for '" + project + "'."); + } + if (versions != null) { + for (int i = 0; i < versions.length; i++) { + if (versions[i].getName().equals(version)) { + return versions[i]; + } + } + } + throw new BuildException("Version '" + version + "' not found for project '" + project + + "'."); + } + protected ISession getSession() throws BuildException { if (session == null) { ISessionFactory factory = SessionFactory.getInstance(); @@ -172,5 +199,5 @@ protected String getUsername() { return username; } - + } Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionAddTask.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionAddTask.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionAddTask.java 2006-10-19 14:25:58 UTC (rev 73) @@ -0,0 +1,153 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; + +import org.apache.tools.ant.BuildException; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.service.ProjectData; +import org.mantisbt.connect.service.ProjectVersionData; + +/** + * <p> + * This task can be used to submit project versions via Ant. + * </p> + * <p> + * The following attributes are mandatory: + * <ul> + * <li><b>url</b></li> + * <li><b>username</b></li> + * <li><b>password</b></li> + * <li><b>project</b> (The name of the project)</li> + * <li><b>name</b> (The name of the version to add)</li> + * </ul> + * </p> + * <p> + * The following attributes are optional: + * <ul> + * <li><b>description</b></li> + * <li><b>released</b> (Use "true" or "false")</li> + * <li><b>date</b> (Mandatory if format is given)</li> + * <li><b>format</b> (The format of the date, mandatory if date is given)</li> + * </ul> + * </p> + * <p> + * <b>Example:</b> + * </p> + * <p> + * + * <pre> + * <taskdef name="submit" classname="org.mantisbt.connect.ant.taskdefs.VersionAddTask" classpath="${cp}" /> + * + * <target name="submit-version"> + * <submit url="http://yourhost/mantis/mc/mantisconnect.php" + * username="AUser" + * password="APassword" + * project="AProjectName" + * name="1.0.1; + * description="ADescription" + * released="false" + * date="01.01.2000" + * format="dd.MM.yyyy"/> + * </target> + * </pre> + * + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class VersionAddTask extends MantisConnectTask { + + private String project; + + private String name; + + private String description; + + private String date; + + private String format; + + private Boolean released; + + public void execute() throws BuildException { + checkAttributes(); + ISession session = getSession(); + ProjectVersionData version = new ProjectVersionData(); + ProjectData projectData = getProjectByName(project); + version.setProject_id(projectData.getId()); + version.setName(name); + version.setDescription(description); + version.setReleased(released); + if (date != null) { + Calendar calendar = Calendar.getInstance(); + try { + calendar.setTime(new SimpleDateFormat(format).parse(date)); + } catch (ParseException e) { + throw new BuildException(e); + } + version.setDate_order(calendar); + } + try { + long versionId = session.addVersion(version); + log("Added version '" + name + "' to project '" + projectData.getName() + "' at '" + + getUrl() + "' (ID " + versionId + ")"); + } catch (JMTException e) { + throw new BuildException("Could not add version.", e); + } + } + + protected void checkAttributes() { + super.checkAttributes(); + if (project == null) { + throw new BuildException("The project attribute must be present.", getLocation()); + } + if (name == null) { + throw new BuildException("The name attribute must be present.", getLocation()); + } + if (date != null && format == null) { + throw new BuildException("The format attribute must be present.", getLocation()); + } + if (format != null && date == null) { + throw new BuildException("The date attribute must be present.", getLocation()); + } + } + + public void setFormat(String format) { + this.format = format; + } + + public void setDate(String date) { + this.date = date; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setName(String name) { + this.name = name; + } + + public void setProject(String project) { + this.project = project; + } + + public void setReleased(Boolean realeased) { + this.released = realeased; + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionDeleteTask.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionDeleteTask.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionDeleteTask.java 2006-10-19 14:25:58 UTC (rev 73) @@ -0,0 +1,91 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import org.apache.tools.ant.BuildException; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.service.ProjectVersionData; + +/** + * <p> + * This task can be used to delete a project version via Ant. + * </p> + * <p> + * The following attributes are mandatory: + * <ul> + * <li><b>url</b></li> + * <li><b>username</b></li> + * <li><b>password</b></li> + * <li><b>project</b> (The name of the project)</li> + * <li><b>name</b> (The name of the version to update)</li> + * </ul> + * </p> + * <p> + * <b>Example:</b> + * </p> + * <p> + * + * <pre> + * <taskdef name="delete" classname="org.mantisbt.connect.ant.taskdefs.VersionDeleteTask" classpath="${cp}" /> + * + * <target name="delete-version"> + * <delete url="http://yourhost/mantis/mc/mantisconnect.php" + * username="AUser" + * password="APassword" + * project="AProjectName" + * name="1.0.1"/> + * </target> + * </pre> + * + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class VersionDeleteTask extends MantisConnectTask { + + private String project; + + private String name; + + public void execute() throws BuildException { + checkAttributes(); + ProjectVersionData version = getVersionByName(name, project); + ISession session = getSession(); + try { + session.deleteVersion(getVersionByName(name, project).getId().longValue()); + log("Deleted version '" + name + "' of project '" + project + "' at '" + getUrl() + + "' (ID " + version.getId().longValue() + ")"); + } catch (JMTException e) { + throw new BuildException("Could not delete version.", e); + } + } + + protected void checkAttributes() { + super.checkAttributes(); + if (project == null) { + throw new BuildException("The project attribute must be present.", getLocation()); + } + if (name == null) { + throw new BuildException("The name attribute must be present.", getLocation()); + } + } + + public void setName(String name) { + this.name = name; + } + + public void setProject(String project) { + this.project = project; + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionUpdateTask.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionUpdateTask.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/VersionUpdateTask.java 2006-10-19 14:25:58 UTC (rev 73) @@ -0,0 +1,169 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; + +import org.apache.tools.ant.BuildException; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.service.ProjectVersionData; + +/** + * <p> + * This task can be used to update a project version via Ant. + * </p> + * <p> + * The following attributes are mandatory: + * <ul> + * <li><b>url</b></li> + * <li><b>username</b></li> + * <li><b>password</b></li> + * <li><b>project</b> (The name of the project)</li> + * <li><b>name</b> (The name of the version to update)</li> + * </ul> + * </p> + * <p> + * The following attributes are optional: + * <ul> + * <li><b>newname</b> (The new version name)</li> + * <li><b>description</b></li> + * <li><b>released</b> (Use "true" or "false")</li> + * <li><b>date</b> (Mandatory if format is given)</li> + * <li><b>format</b> (The format of the date, mandatory if date is given)</li> + * </ul> + * </p> + * <p> + * <b>Example:</b> + * </p> + * <p> + * + * <pre> + * <taskdef name="update" classname="org.mantisbt.connect.ant.taskdefs.VersionUpdateTask" classpath="${cp}" /> + * + * <target name="update-version"> + * <update url="http://yourhost/mantis/mc/mantisconnect.php" + * username="AUser" + * password="APassword" + * project="AProjectName" + * name="1.0.1; + * newname="1.0.1.1" + * description="ADescription" + * released="false" + * date="01.01.2000" + * format="dd.MM.yyyy"/> + * </target> + * </pre> + * + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class VersionUpdateTask extends MantisConnectTask { + + private String project; + + private String name; + + private String newname; + + private String description; + + private String date; + + private String format; + + private Boolean released; + + public void execute() throws BuildException { + checkAttributes(); + ISession session = getSession(); + ProjectVersionData existing = getVersionByName(name, project); + if (existing == null) { + throw new BuildException("Version '" + name + "' does not exist for project '" + + project + "'."); + } + if (newname != null) { + existing.setName(newname); + } + if (description != null) { + existing.setDescription(description); + } + if (released != null) { + existing.setReleased(released); + } + if (date != null) { + Calendar calendar = Calendar.getInstance(); + try { + calendar.setTime(new SimpleDateFormat(format).parse(date)); + } catch (ParseException e) { + throw new BuildException(e); + } + existing.setDate_order(calendar); + } + try { + session.updateVersion(existing); + log("Updated version '" + name + "' of project '" + project + "' at '" + getUrl() + + "' (ID " + existing.getId().longValue() + ")"); + } catch (JMTException e) { + e.printStackTrace(); + throw new BuildException("Could not update version.", e); + } + } + + protected void checkAttributes() { + super.checkAttributes(); + if (project == null) { + throw new BuildException("The project attribute must be present.", getLocation()); + } + if (name == null) { + throw new BuildException("The name attribute must be present.", getLocation()); + } + if (date != null && format == null) { + throw new BuildException("The format attribute must be present.", getLocation()); + } + if (format != null && date == null) { + throw new BuildException("The date attribute must be present.", getLocation()); + } + } + + public void setFormat(String format) { + this.format = format; + } + + public void setDate(String date) { + this.date = date; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setName(String name) { + this.name = name; + } + + public void setNewname(String newname) { + this.newname = newname; + } + + public void setProject(String project) { + this.project = project; + } + + public void setReleased(Boolean realeased) { + this.released = realeased; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-19 14:25:45
|
Revision: 72 http://svn.sourceforge.net/mantisconnect/?rev=72&view=rev Author: planser Date: 2006-10-19 07:25:21 -0700 (Thu, 19 Oct 2006) Log Message: ----------- Some refactorings (submit issue via ant) Added support for adding, updating and deleting project versions via Ant Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/IssueSubmitTaskTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml Added Paths: ----------- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/MantisConnectTaskTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/Utilities.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionAddTaskTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionDeleteTaskTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionUpdateTaskTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/mantisconnect.xml mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versionadd.xml mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versiondelete.xml mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versionupdate.xml Modified: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/IssueSubmitTaskTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/IssueSubmitTaskTest.java 2006-10-19 14:23:43 UTC (rev 71) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/IssueSubmitTaskTest.java 2006-10-19 14:25:21 UTC (rev 72) @@ -11,17 +11,13 @@ */ package org.mantisbt.connect.ant.taskdefs; -import java.math.BigInteger; import java.net.MalformedURLException; import java.net.URL; -import java.util.StringTokenizer; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.BuildFileTest; import org.mantisbt.connect.ISession; -import org.mantisbt.connect.ISessionFactory; import org.mantisbt.connect.JMTException; -import org.mantisbt.connect.SessionFactory; import org.mantisbt.connect.service.IssueData; import org.mantisbt.connect.service.ProjectData; @@ -34,8 +30,6 @@ private final static String TEST_DESCRIPTION = "Added by MantisConnect Ant Task (Description)"; - private ISession session; - public IssueSubmitTaskTest(String name) { super(name); } @@ -45,69 +39,26 @@ } public void testMandatory1() { - expectBuildException("testMandatory1", - "required arguments not specified"); + expectBuildException("testMandatory1", "required arguments not specified"); } public void testMandatory2() { - expectBuildException("testMandatory2", - "required arguments not specified"); + expectBuildException("testMandatory2", "required arguments not specified"); } - public void testMandatory3() { - expectBuildException("testMandatory3", - "required arguments not specified"); - } - - public void testMandatory4() { - expectBuildException("testMandatory4", - "required arguments not specified"); - } - - public void testMandatory5() { - expectBuildException("testMandatory5", - "required arguments not specified"); - } - - public void testMandatory6() { - expectBuildException("testMandatory6", - "required arguments not specified"); - } - - public void testInvalidProxySettings1() { - expectBuildException("testInvalidProxySettings1", - "required argument (proxyPort) not specified"); - } - - public void testInvalidProxySettings2() { - expectBuildException("testInvalidProxySettings2", - "required argument (proxyHost) not specified"); - } - - public void testInvalidProxySettings3() { - expectBuildException("testInvalidProxySettings3", - "proxyPort argument must be of type integer"); - } - - public void testInvalidUrl() { - expectBuildException("testInvalidUrl", "url argument is invalid"); - } - public void testValid1() { try { - ProjectData projectData = getAccessibleProject(); + ProjectData projectData = Utilities.getAccessibleProject(); project.setProperty("test.project.name", projectData.getName()); - project.setProperty("test.project.category", - getFirstProjectCategory()); + project.setProperty("test.project.category", Utilities.getFirstProjectCategory()); project.setProperty("test.summary", TEST_SUMMARY); project.setProperty("test.description", TEST_DESCRIPTION); executeTarget("testValid1"); long id = getIdFromLogLine(getLog()); try { - IssueData issue = session.getIssue(id); - assertEquals(projectData.getName(), issue.getProject() - .getName()); - assertEquals(getFirstProjectCategory(), issue.getCategory()); + IssueData issue = Utilities.getSession().getIssue(id); + assertEquals(projectData.getName(), issue.getProject().getName()); + assertEquals(Utilities.getFirstProjectCategory(), issue.getCategory()); assertEquals(TEST_SUMMARY, issue.getSummary()); assertEquals(TEST_DESCRIPTION, issue.getDescription()); } catch (JMTException e) { @@ -121,40 +72,34 @@ public void testValid2() { try { - ProjectData projectData = getAccessibleProject(); + ProjectData projectData = Utilities.getAccessibleProject(); project.setProperty("test.project.name", projectData.getName()); - project.setProperty("test.project.category", - getFirstProjectCategory()); + project.setProperty("test.project.category", Utilities.getFirstProjectCategory()); project.setProperty("test.summary", TEST_SUMMARY); project.setProperty("test.description", TEST_DESCRIPTION); - project.setProperty("test.project.version", - getFirstProjectReleasedVersion()); + project.setProperty("test.project.version", Utilities.getFirstProjectReleasedVersion()); executeTarget("testValid2"); long id = getIdFromLogLine(getLog()); try { - IssueData issue = session.getIssue(id); - assertEquals(projectData.getName(), issue.getProject() - .getName()); - assertEquals(getFirstProjectCategory(), issue.getCategory()); + IssueData issue = Utilities.getSession().getIssue(id); + assertEquals(projectData.getName(), issue.getProject().getName()); + assertEquals(Utilities.getFirstProjectCategory(), issue.getCategory()); assertEquals(TEST_SUMMARY, issue.getSummary()); assertEquals(TEST_DESCRIPTION, issue.getDescription()); - assertEquals(getFirstProjectReleasedVersion(), issue - .getVersion()); - assertEquals(IssueSubmitTask.REPRODUCIBILITY_SOMETIMES_NUM, - issue.getReproducibility().getId().longValue()); - assertEquals(IssueSubmitTask.SEVERITY_BLOCK_NUM, issue - .getSeverity().getId().longValue()); - assertEquals(IssueSubmitTask.PRIORITY_HIGH_NUM, issue - .getPriority().getId().longValue()); - assertEquals("AdditionalInfo", issue - .getAdditional_information()); + assertEquals(Utilities.getFirstProjectReleasedVersion(), issue.getVersion()); + assertEquals(IssueSubmitTask.REPRODUCIBILITY_SOMETIMES_NUM, issue + .getReproducibility().getId().longValue()); + assertEquals(IssueSubmitTask.SEVERITY_BLOCK_NUM, issue.getSeverity().getId() + .longValue()); + assertEquals(IssueSubmitTask.PRIORITY_HIGH_NUM, issue.getPriority().getId() + .longValue()); + assertEquals("AdditionalInfo", issue.getAdditional_information()); assertEquals("APlatform", issue.getPlatform()); assertEquals("AnOs", issue.getOs()); assertEquals("AnOsVersion", issue.getOs_build()); assertEquals("AProductBuild", issue.getBuild()); assertEquals("StepsToReproduce", issue.getSteps_to_reproduce()); - assertEquals(ISession.VS_PRIVATE, issue.getView_state().getId() - .longValue()); + assertEquals(ISession.VS_PRIVATE, issue.getView_state().getId().longValue()); } catch (JMTException e) { fail(e.getMessage()); } @@ -166,27 +111,25 @@ public void testValid3() { try { - ProjectData projectData = getAccessibleProject(); + ProjectData projectData = Utilities.getAccessibleProject(); project.setProperty("test.project.name", projectData.getName()); - project.setProperty("test.project.category", - getFirstProjectCategory()); + project.setProperty("test.project.category", Utilities.getFirstProjectCategory()); project.setProperty("test.summary", TEST_SUMMARY); project.setProperty("test.description", TEST_DESCRIPTION); executeTarget("testValid3"); long id = getIdFromLogLine(getLog()); try { - IssueData issue = session.getIssue(id); - assertEquals(projectData.getName(), issue.getProject() - .getName()); - assertEquals(getFirstProjectCategory(), issue.getCategory()); + IssueData issue = Utilities.getSession().getIssue(id); + assertEquals(projectData.getName(), issue.getProject().getName()); + assertEquals(Utilities.getFirstProjectCategory(), issue.getCategory()); assertEquals(TEST_SUMMARY, issue.getSummary()); assertEquals(TEST_DESCRIPTION, issue.getDescription()); - assertEquals(IssueSubmitTask.REPRODUCIBILITY_ALWAYS_NUM, issue - .getReproducibility().getId().longValue()); - assertEquals(IssueSubmitTask.SEVERITY_CRASH_NUM, issue - .getSeverity().getId().longValue()); - assertEquals(IssueSubmitTask.PRIORITY_IMMEDIATE_NUM, issue - .getPriority().getId().longValue()); + assertEquals(IssueSubmitTask.REPRODUCIBILITY_ALWAYS_NUM, issue.getReproducibility() + .getId().longValue()); + assertEquals(IssueSubmitTask.SEVERITY_CRASH_NUM, issue.getSeverity().getId() + .longValue()); + assertEquals(IssueSubmitTask.PRIORITY_IMMEDIATE_NUM, issue.getPriority().getId() + .longValue()); } catch (JMTException e) { fail(e.getMessage()); } @@ -198,25 +141,22 @@ public void testValid4() { try { - ProjectData projectData = getAccessibleProject(); + ProjectData projectData = Utilities.getAccessibleProject(); project.setProperty("test.project.name", projectData.getName()); - project.setProperty("test.project.category", - getFirstProjectCategory()); + project.setProperty("test.project.category", Utilities.getFirstProjectCategory()); project.setProperty("test.summary", TEST_SUMMARY); project.setProperty("test.description", TEST_DESCRIPTION); - project.setProperty("test.project.customfield.name", - getCustomFieldName()); - project.setProperty("test.project.customfield.value", - getCustomFieldValue()); - project.setProperty("test.project.customfield.format", - getCustomFieldFormat()); + project.setProperty("test.project.customfield.name", Utilities.getCustomFieldName()); + project.setProperty("test.project.customfield.value", Utilities.getCustomFieldValue()); + project + .setProperty("test.project.customfield.format", Utilities + .getCustomFieldFormat()); executeTarget("testValid4"); long id = getIdFromLogLine(getLog()); try { - IssueData issue = session.getIssue(id); - assertEquals(projectData.getName(), issue.getProject() - .getName()); - assertEquals(getFirstProjectCategory(), issue.getCategory()); + IssueData issue = Utilities.getSession().getIssue(id); + assertEquals(projectData.getName(), issue.getProject().getName()); + assertEquals(Utilities.getFirstProjectCategory(), issue.getCategory()); assertEquals(TEST_SUMMARY, issue.getSummary()); assertEquals(TEST_DESCRIPTION, issue.getDescription()); } catch (JMTException e) { @@ -231,15 +171,14 @@ private void deleteIssue(long id) { try { - getSession().deleteIssue(id); + Utilities.getSession().deleteIssue(id); } catch (JMTException e) { } } private long getIdFromLogLine(String log) { try { - return Long.parseLong(log.substring(log.lastIndexOf(" ") + 1, log - .lastIndexOf(")"))); + return Long.parseLong(log.substring(log.lastIndexOf(" ") + 1, log.lastIndexOf(")"))); } catch (Exception e) { return -1; } @@ -261,70 +200,4 @@ return System.getProperty("test.password"); } - private BigInteger getAccessibleProjectId() { - return BigInteger.valueOf(Long.parseLong(System - .getProperty("test.project.id"))); - } - - private ISession getSession() { - if (session == null) { - try { - ISessionFactory factory = SessionFactory.getInstance(); - String proxyHost = System.getProperty("test.http.proxyHost"); - String proxyPort = System.getProperty("test.http.proxyPort"); - if (!isEmpty(proxyHost) && !isEmpty(proxyPort)) { - factory.setProxy(proxyHost, Integer.parseInt(proxyPort)); - } - session = factory - .newSession(getUrl(), getUser(), getPassword()); - } catch (JMTException e) { - session = null; - } - } - return session; - } - - private boolean isEmpty(String string) { - return string == null || string.trim().length() == 0; - } - - private ProjectData getAccessibleProject() { - try { - ProjectData[] projects = getSession().getAccessibleProjects(); - if (projects != null) { - for (int i = 0; i < projects.length; i++) { - if (projects[i].getId().equals(getAccessibleProjectId())) { - return projects[i]; - } - } - } - } catch (JMTException e) { - return null; - } - return null; - } - - private String getFirstProjectCategory() { - return new StringTokenizer(System - .getProperty("test.project.categories"), ";").nextToken(); - } - - private String getFirstProjectReleasedVersion() { - return new StringTokenizer(System - .getProperty("test.project.versions.released"), ";") - .nextToken(); - } - - private String getCustomFieldName() { - return System.getProperty("test.project.customfield.name"); - } - - private String getCustomFieldValue() { - return System.getProperty("test.project.customfield.value"); - } - - private String getCustomFieldFormat() { - return System.getProperty("test.project.customfield.format"); - } - } Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/MantisConnectTaskTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/MantisConnectTaskTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/MantisConnectTaskTest.java 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,138 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.math.BigInteger; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.StringTokenizer; + +import org.apache.tools.ant.BuildFileTest; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.ISessionFactory; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.SessionFactory; +import org.mantisbt.connect.service.ProjectData; + +/** + * @author Peter Lanser, pl...@us... + */ +public class MantisConnectTaskTest extends BuildFileTest { + + private ISession session; + + public MantisConnectTaskTest(String name) { + super(name); + } + + public void setUp() { + configureProject("src/test/org/mantisbt/connect/ant/taskdefs/mantisconnect.xml"); + } + + public void testMandatory1() { + expectBuildException("testMandatory1", "required arguments not specified"); + } + + public void testMandatory2() { + expectBuildException("testMandatory2", "required arguments not specified"); + } + + public void testMandatory3() { + expectBuildException("testMandatory3", "required arguments not specified"); + } + + public void testInvalidProxySettings1() { + expectBuildException("testInvalidProxySettings1", + "required argument (proxyPort) not specified"); + } + + public void testInvalidProxySettings2() { + expectBuildException("testInvalidProxySettings2", + "required argument (proxyHost) not specified"); + } + + public void testInvalidProxySettings3() { + expectBuildException("testInvalidProxySettings3", + "proxyPort argument must be of type integer"); + } + + public void testInvalidUrl() { + expectBuildException("testInvalidUrl", "url argument is invalid"); + } + + private URL getUrl() { + try { + return new URL(System.getProperty("test.url")); + } catch (MalformedURLException e) { + return null; + } + } + + private String getUser() { + return System.getProperty("test.user"); + } + + private String getPassword() { + return System.getProperty("test.password"); + } + + private BigInteger getAccessibleProjectId() { + return BigInteger.valueOf(Long.parseLong(System.getProperty("test.project.id"))); + } + + private ISession getSession() { + if (session == null) { + try { + ISessionFactory factory = SessionFactory.getInstance(); + String proxyHost = System.getProperty("test.http.proxyHost"); + String proxyPort = System.getProperty("test.http.proxyPort"); + if (!isEmpty(proxyHost) && !isEmpty(proxyPort)) { + factory.setProxy(proxyHost, Integer.parseInt(proxyPort)); + } + session = factory.newSession(getUrl(), getUser(), getPassword()); + } catch (JMTException e) { + session = null; + } + } + return session; + } + + private boolean isEmpty(String string) { + return string == null || string.trim().length() == 0; + } + + private ProjectData getFirstAccessibleProject() { + try { + ProjectData[] projects = getSession().getAccessibleProjects(); + if (projects != null) { + for (int i = 0; i < projects.length; i++) { + if (projects[i].getId().equals(getAccessibleProjectId())) { + return projects[i]; + } + } + } + } catch (JMTException e) { + return null; + } + return null; + } + + private String getFirstProjectCategory() { + return new StringTokenizer(System.getProperty("test.project.categories"), ";").nextToken(); + } + + private String getFirstProjectReleasedVersion() { + return new StringTokenizer(System.getProperty("test.project.versions.released"), ";") + .nextToken(); + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/Utilities.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/Utilities.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/Utilities.java 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,111 @@ +package org.mantisbt.connect.ant.taskdefs; + +import java.math.BigInteger; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.StringTokenizer; + +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.ISessionFactory; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.SessionFactory; +import org.mantisbt.connect.service.ProjectData; +import org.mantisbt.connect.service.ProjectVersionData; + +public class Utilities { + + private static ISession session = null; + + private static URL getUrl() { + try { + return new URL(System.getProperty("test.url")); + } catch (MalformedURLException e) { + return null; + } + } + + private static String getUser() { + return System.getProperty("test.user"); + } + + private static String getPassword() { + return System.getProperty("test.password"); + } + + private static BigInteger getAccessibleProjectId() { + return BigInteger.valueOf(Long.parseLong(System.getProperty("test.project.id"))); + } + + public static ISession getSession() { + if (session == null) { + try { + ISessionFactory factory = SessionFactory.getInstance(); + String proxyHost = System.getProperty("test.http.proxyHost"); + String proxyPort = System.getProperty("test.http.proxyPort"); + if (!isEmpty(proxyHost) && !isEmpty(proxyPort)) { + factory.setProxy(proxyHost, Integer.parseInt(proxyPort)); + } + session = factory.newSession(getUrl(), getUser(), getPassword()); + } catch (JMTException e) { + session = null; + } + } + return session; + } + + public static boolean isEmpty(String string) { + return string == null || string.trim().length() == 0; + } + + public static ProjectData getAccessibleProject() { + try { + ProjectData[] projects = getSession().getAccessibleProjects(); + if (projects != null) { + for (int i = 0; i < projects.length; i++) { + if (projects[i].getId().equals(getAccessibleProjectId())) { + return projects[i]; + } + } + } + } catch (JMTException e) { + return null; + } + return null; + } + + public static String getFirstProjectCategory() { + return new StringTokenizer(System.getProperty("test.project.categories"), ";").nextToken(); + } + + public static String getFirstProjectReleasedVersion() { + return new StringTokenizer(System.getProperty("test.project.versions.released"), ";") + .nextToken(); + } + + public static String getCustomFieldName() { + return System.getProperty("test.project.customfield.name"); + } + + public static String getCustomFieldValue() { + return System.getProperty("test.project.customfield.value"); + } + + public static String getCustomFieldFormat() { + return System.getProperty("test.project.customfield.format"); + } + + public static ProjectVersionData getVersion(String name, long projectId) { + try { + ProjectVersionData[] versions = getSession().getVersions(projectId); + for (int i = 0; i < versions.length; i++) { + if (versions[i].getName().equals(name)) { + return versions[i]; + } + } + } catch (JMTException e) { + return null; + } + return null; + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionAddTaskTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionAddTaskTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionAddTaskTest.java 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,146 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.text.SimpleDateFormat; +import java.util.Calendar; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileTest; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.service.ProjectData; +import org.mantisbt.connect.service.ProjectVersionData; + +/** + * @author Peter Lanser, pl...@us... + */ +public class VersionAddTaskTest extends BuildFileTest { + + private final static String TEST_VERSION_DESCRIPTION = "AVersionDescription"; + + public VersionAddTaskTest(String name) { + super(name); + } + + public void setUp() { + Utilities.getSession().flush(); + configureProject("src/test/org/mantisbt/connect/ant/taskdefs/versionadd.xml"); + } + + public void testMandatory1() { + expectBuildException("testMandatory1", "required arguments not specified"); + } + + public void testMandatory2() { + expectBuildException("testMandatory2", "required arguments not specified"); + } + + public void testMandatory3() { + expectBuildException("testMandatory3", "required arguments not specified"); + } + + public void testMandatory4() { + expectBuildException("testMandatory4", "required arguments not specified"); + } + + public void testInvalidDateFormat1() { + expectBuildException("testInvalidDateFormat1", "required arguments not specified"); + } + + public void testInvalidDateFormat2() { + expectBuildException("testInvalidDateFormat2", "required arguments not specified"); + } + + public void testValid1() { + String versionName = getRandomVersionName(); + ProjectData projectData = null; + try { + projectData = Utilities.getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.version.name", versionName); + executeTarget("testValid1"); + } catch (BuildException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + ProjectVersionData version = null; + try { + version = Utilities.getVersion(versionName, projectData.getId().longValue()); + assertNotNull(version); + assertEquals(projectData.getId(), version.getProject_id()); + assertEquals(versionName, version.getName()); + assertNull(version.getDescription()); + Calendar today = Calendar.getInstance(); + assertEquals(today.get(Calendar.YEAR), version.getDate_order().get(Calendar.YEAR)); + assertEquals(today.get(Calendar.MONTH), version.getDate_order().get(Calendar.MONTH)); + assertEquals(today.get(Calendar.DAY_OF_MONTH), version.getDate_order().get( + Calendar.DAY_OF_MONTH)); + assertEquals(today.get(Calendar.HOUR_OF_DAY), version.getDate_order().get( + Calendar.HOUR_OF_DAY)); + assertTrue(version.getReleased().booleanValue()); + } finally { + deleteVersion(version.getId().longValue()); + } + } + + public void testValid2() { + String versionName = getRandomVersionName(); + ProjectData projectData = null; + String dateFormat = "dd.MM.yyyy"; + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, 2000); + calendar.set(Calendar.MONTH, 1); + calendar.set(Calendar.DAY_OF_MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + try { + projectData = Utilities.getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.version.name", versionName); + project.setProperty("test.project.version.description", TEST_VERSION_DESCRIPTION); + project.setProperty("test.project.version.date", new SimpleDateFormat(dateFormat) + .format(calendar.getTime())); + project.setProperty("test.project.version.date.format", dateFormat); + executeTarget("testValid2"); + } catch (BuildException e) { + fail(e.getMessage()); + } + ProjectVersionData version = null; + try { + version = Utilities.getVersion(versionName, projectData.getId().longValue()); + assertNotNull(version); + assertEquals(projectData.getId(), version.getProject_id()); + assertEquals(versionName, version.getName()); + assertEquals(TEST_VERSION_DESCRIPTION, version.getDescription()); + assertEquals(calendar.getTime(), version.getDate_order().getTime()); + assertFalse(version.getReleased().booleanValue()); + } finally { + if (version != null) { + deleteVersion(version.getId().longValue()); + } + } + } + + private void deleteVersion(long id) { + try { + Utilities.getSession().deleteVersion(id); + } catch (JMTException e) { + } + } + + private String getRandomVersionName() { + return String.valueOf(Math.random()); + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionDeleteTaskTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionDeleteTaskTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionDeleteTaskTest.java 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,78 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileTest; +import org.mantisbt.connect.service.ProjectData; +import org.mantisbt.connect.service.ProjectVersionData; + +/** + * @author Peter Lanser, pl...@us... + */ +public class VersionDeleteTaskTest extends BuildFileTest { + + public VersionDeleteTaskTest(String name) { + super(name); + } + + public void setUp() { + Utilities.getSession().flush(); + configureProject("src/test/org/mantisbt/connect/ant/taskdefs/versiondelete.xml"); + } + + public void testMandatory1() { + expectBuildException("testMandatory1", "required arguments not specified"); + } + + public void testMandatory2() { + expectBuildException("testMandatory2", "required arguments not specified"); + } + + public void testValid1() { + String versionName = getRandomVersionName(); + ProjectData projectData = null; + try { + projectData = Utilities.getAccessibleProject(); + ProjectVersionData newVersion = new ProjectVersionData(); + newVersion.setProject_id(projectData.getId()); + newVersion.setName(versionName); + Utilities.getSession().addVersion(newVersion); + } catch (Exception e) { + fail(e.getMessage()); + } + try { + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.version.name", versionName); + executeTarget("testValid1"); + } catch (BuildException e) { + fail(e.getMessage()); + } + assertNull(Utilities.getVersion(versionName, projectData.getId().longValue())); + } + + public void testVersionNotExists() { + try { + ProjectData projectData = Utilities.getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.version.name", getRandomVersionName()); + expectBuildException("testVersionNotExists", "specified version does not exist"); + } catch (BuildException e) { + fail(e.getMessage()); + } + } + + private String getRandomVersionName() { + return String.valueOf(Math.random()); + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionUpdateTaskTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionUpdateTaskTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/VersionUpdateTaskTest.java 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,175 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.text.SimpleDateFormat; +import java.util.Calendar; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileTest; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.service.ProjectData; +import org.mantisbt.connect.service.ProjectVersionData; + +/** + * @author Peter Lanser, pl...@us... + */ +public class VersionUpdateTaskTest extends BuildFileTest { + + private final static String TEST_VERSION_DESCRIPTION = "AVersionDescription"; + + public VersionUpdateTaskTest(String name) { + super(name); + } + + public void setUp() { + Utilities.getSession().flush(); + configureProject("src/test/org/mantisbt/connect/ant/taskdefs/versionupdate.xml"); + } + + public void testMandatory1() { + expectBuildException("testMandatory1", "required arguments not specified"); + } + + public void testMandatory2() { + expectBuildException("testMandatory2", "required arguments not specified"); + } + + public void testMandatory3() { + expectBuildException("testMandatory3", "required arguments not specified"); + } + + public void testMandatory4() { + expectBuildException("testMandatory4", "required arguments not specified"); + } + + public void testInvalidDateFormat1() { + expectBuildException("testInvalidDateFormat1", "required arguments not specified"); + } + + public void testInvalidDateFormat2() { + expectBuildException("testInvalidDateFormat2", "required arguments not specified"); + } + + public void testVersionNotExists() { + try { + ProjectData projectData = Utilities.getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.version.name", getRandomVersionName()); + expectBuildException("testVersionNotExists", "specified version does not exist"); + } catch (BuildException e) { + fail(e.getMessage()); + } + } + + public void testValid1() { + String versionName = getRandomVersionName(); + ProjectData projectData = null; + ProjectVersionData addedVersion = null; + long addedVersionId = 0; + try { + projectData = Utilities.getAccessibleProject(); + addedVersion = new ProjectVersionData(); + addedVersion.setProject_id(projectData.getId()); + addedVersion.setName(versionName); + addedVersionId = Utilities.getSession().addVersion(addedVersion); + } catch (Exception e) { + fail(e.getMessage()); + } + try { + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.version.name", versionName); + executeTarget("testValid1-NoChange"); + } catch (BuildException e) { + fail(e.getMessage()); + } + try { + ProjectVersionData version = Utilities.getVersion(versionName, projectData.getId() + .longValue()); + assertEquals(addedVersionId, version.getId().longValue()); + assertEquals(addedVersion.getProject_id().longValue(), version.getProject_id() + .longValue()); + assertEquals(addedVersion.getName(), version.getName()); + assertNull(version.getDescription()); + assertNotNull(version.getDate_order()); + assertTrue(version.getReleased().booleanValue()); + } catch (BuildException e) { + fail(e.getMessage()); + } finally { + deleteVersion(addedVersionId); + } + } + + public void testValid2() { + String versionName = getRandomVersionName(); + String updatedVersionName = versionName + " (Updated)"; + ProjectData projectData = null; + ProjectVersionData addedVersion = null; + long addedVersionId = 0; + String dateFormat = "dd.MM.yyyy"; + Calendar calendar = Calendar.getInstance(); + calendar.set(Calendar.YEAR, 2000); + calendar.set(Calendar.MONTH, 1); + calendar.set(Calendar.DAY_OF_MONTH, 1); + calendar.set(Calendar.HOUR_OF_DAY, 0); + calendar.set(Calendar.MINUTE, 0); + calendar.set(Calendar.SECOND, 0); + calendar.set(Calendar.MILLISECOND, 0); + try { + projectData = Utilities.getAccessibleProject(); + addedVersion = new ProjectVersionData(); + addedVersion.setProject_id(projectData.getId()); + addedVersion.setName(versionName); + addedVersionId = Utilities.getSession().addVersion(addedVersion); + } catch (Exception e) { + fail(e.getMessage()); + } + try { + projectData = Utilities.getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.version.name", versionName); + project.setProperty("test.project.version.newname", updatedVersionName); + project.setProperty("test.project.version.description", TEST_VERSION_DESCRIPTION); + project.setProperty("test.project.version.date", new SimpleDateFormat(dateFormat) + .format(calendar.getTime())); + project.setProperty("test.project.version.date.format", dateFormat); + executeTarget("testValid2"); + } catch (BuildException e) { + fail(e.getMessage()); + } + try { + ProjectVersionData version = Utilities.getVersion(updatedVersionName, projectData + .getId().longValue()); + assertEquals(addedVersionId, version.getId().longValue()); + assertEquals(addedVersion.getProject_id().longValue(), version.getProject_id() + .longValue()); + assertEquals(updatedVersionName, version.getName()); + assertEquals(TEST_VERSION_DESCRIPTION, version.getDescription()); + assertEquals(calendar.getTime(), version.getDate_order().getTime()); + assertFalse(version.getReleased().booleanValue()); + } finally { + deleteVersion(addedVersionId); + } + } + + private void deleteVersion(long id) { + try { + Utilities.getSession().deleteVersion(id); + } catch (JMTException e) { + } + } + + private String getRandomVersionName() { + return String.valueOf(Math.random()); + } + +} Modified: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml 2006-10-19 14:23:43 UTC (rev 71) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml 2006-10-19 14:25:21 UTC (rev 72) @@ -5,54 +5,15 @@ <taskdef name="submit" classname="org.mantisbt.connect.ant.taskdefs.IssueSubmitTask"/> <target name="testMandatory1"> - <submit/> - </target> - - <target name="testMandatory2"> - <submit url="http://localhost/"/> - </target> - - <target name="testMandatory3"> - <submit url="http://localhost/" username="AUsername"/> - </target> - - <target name="testMandatory4"> - <submit url="http://localhost/" username="AUsername" password="APassword"/> - </target> - - <target name="testMandatory5"> <submit url="http://localhost/" username="AUsername" password="APassword" project="AProject"/> </target> - <target name="testMandatory6"> + <target name="testMandatory2"> <submit url="http://localhost/" username="AUsername" password="APassword" project="AProject" summary="ASummary"/> </target> - <target name="testInvalidProxySettings1"> - <submit proxyHost="AProxyHost" - url="http://localhost/" username="AUsername" password="APassword" - project="AProject" summary="ASummary" description="ADescription"/> - </target> - - <target name="testInvalidProxySettings2"> - <submit proxyPort="8080" - url="http://localhost/" username="AUsername" password="APassword" - project="AProject" summary="ASummary" description="ADescription"/> - </target> - - <target name="testInvalidProxySettings3"> - <submit proxyHost="AProxyHost" proxyPort="APort" - url="http://localhost/" username="AUsername" password="APassword" - project="AProject" summary="ASummary" description="ADescription"/> - </target> - - <target name="testInvalidUrl"> - <submit url="AnInvalidUrl" username="AUsername" password="APassword" - project="AProject" summary="ASummary" description="ADescription"/> - </target> - <target name="testValid1"> <submit url="${test.url}" username="${test.user}" password="${test.password}" project="${test.project.name}" Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/mantisconnect.xml =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/mantisconnect.xml (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/mantisconnect.xml 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,38 @@ +<?xml version="1.0"?> + +<project name="versionsubmit-test"> + + <taskdef name="submit" classname="org.mantisbt.connect.ant.taskdefs.MantisConnectTask"/> + + <target name="testMandatory1"> + <submit/> + </target> + + <target name="testMandatory2"> + <submit url="http://localhost/"/> + </target> + + <target name="testMandatory3"> + <submit url="http://localhost/" username="AUsername"/> + </target> + + <target name="testInvalidProxySettings1"> + <submit proxyHost="AProxyHost" + url="http://localhost/" username="AUsername" password="APassword"/> + </target> + + <target name="testInvalidProxySettings2"> + <submit proxyPort="8080" + url="http://localhost/" username="AUsername" password="APassword"/> + </target> + + <target name="testInvalidProxySettings3"> + <submit proxyHost="AProxyHost" proxyPort="APort" + url="http://localhost/" username="AUsername" password="APassword"/> + </target> + + <target name="testInvalidUrl"> + <submit url="AnInvalidUrl" username="AUsername" password="APassword"/> + </target> + +</project> \ No newline at end of file Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versionadd.xml =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versionadd.xml (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versionadd.xml 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,55 @@ +<?xml version="1.0"?> + +<project name="issuesubmit-test"> + + <taskdef name="submit" classname="org.mantisbt.connect.ant.taskdefs.VersionAddTask"/> + + <target name="testMandatory1"> + <submit url="http://localhost/" username="AUsername" password="APassword" + project="AProject"/> + </target> + + <target name="testMandatory2"> + <submit url="http://localhost/" username="AUsername" password="APassword" + name="AName"/> + </target> + + <target name="testMandatory3"> + <submit url="http://localhost/" username="AUsername" password="APassword" + project="AProject" name="AName" date="ADate"/> + </target> + + <target name="testMandatory4"> + <submit url="http://localhost/" username="AUsername" password="APassword" + project="AProject" name="AName" format="ADate"/> + </target> + + <target name="testInvalidDateFormat1"> + <submit url="http://localhost/" username="AUsername" password="APassword" + project="AProject" name="AName" date="ADate" format="dd.MM.yyyy"/> + </target> + + <target name="testInvalidDateFormat2"> + <submit url="http://localhost/" username="AUsername" password="APassword" + project="AProject" name="AName" date="02.05.1978" format="AFormat"/> + </target> + + <target name="testValid1"> + <submit url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + name="${test.project.version.name}" + /> + </target> + + <target name="testValid2"> + <submit url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + name="${test.project.version.name}" + description="${test.project.version.description}" + released="false" + date="${test.project.version.date}" + format="${test.project.version.date.format}" + /> + </target> + +</project> \ No newline at end of file Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versiondelete.xml =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versiondelete.xml (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versiondelete.xml 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,31 @@ +<?xml version="1.0"?> + +<project name="issuesubmit-test"> + + <taskdef name="delete" classname="org.mantisbt.connect.ant.taskdefs.VersionDeleteTask"/> + + <target name="testMandatory1"> + <delete url="http://localhost/" username="AUsername" password="APassword" + project="AProject"/> + </target> + + <target name="testMandatory2"> + <delete url="http://localhost/" username="AUsername" password="APassword" + name="AName"/> + </target> + + <target name="testValid1"> + <delete url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + name="${test.project.version.name}" + /> + </target> + + <target name="testVersionNotExists"> + <delete url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + name="${test.project.version.name}" + /> + </target> + +</project> \ No newline at end of file Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versionupdate.xml =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versionupdate.xml (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/versionupdate.xml 2006-10-19 14:25:21 UTC (rev 72) @@ -0,0 +1,63 @@ +<?xml version="1.0"?> + +<project name="issuesubmit-test"> + + <taskdef name="update" classname="org.mantisbt.connect.ant.taskdefs.VersionUpdateTask"/> + + <target name="testMandatory1"> + <update url="http://localhost/" username="AUsername" password="APassword" + project="AProject"/> + </target> + + <target name="testMandatory2"> + <update url="http://localhost/" username="AUsername" password="APassword" + name="AName"/> + </target> + + <target name="testMandatory3"> + <update url="http://localhost/" username="AUsername" password="APassword" + project="AProject" name="AName" date="ADate"/> + </target> + + <target name="testMandatory4"> + <update url="http://localhost/" username="AUsername" password="APassword" + project="AProject" name="AName" format="ADate"/> + </target> + + <target name="testInvalidDateFormat1"> + <update url="http://localhost/" username="AUsername" password="APassword" + project="AProject" name="AName" date="ADate" format="dd.MM.yyyy"/> + </target> + + <target name="testInvalidDateFormat2"> + <update url="http://localhost/" username="AUsername" password="APassword" + project="AProject" name="AName" date="02.05.1978" format="AFormat"/> + </target> + + <target name="testVersionNotExists"> + <update url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + name="${test.project.version.name}" + /> + </target> + + <target name="testValid1-NoChange"> + <update url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + name="${test.project.version.name}" + /> + </target> + + <target name="testValid2"> + <update url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + name="${test.project.version.name}" + newname="${test.project.version.newname}" + description="${test.project.version.description}" + released="false" + date="${test.project.version.date}" + format="${test.project.version.date.format}" + /> + </target> + +</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-19 14:23:54
|
Revision: 71 http://svn.sourceforge.net/mantisconnect/?rev=71&view=rev Author: planser Date: 2006-10-19 07:23:43 -0700 (Thu, 19 Oct 2006) Log Message: ----------- Added support for date_order when adding a version. Fixed bug when looking for an existing version (version update) Modified Paths: -------------- mantisconnect/trunk/webservice/mc/mc_project_api.php Modified: mantisconnect/trunk/webservice/mc/mc_project_api.php =================================================================== --- mantisconnect/trunk/webservice/mc/mc_project_api.php 2006-10-18 18:13:50 UTC (rev 70) +++ mantisconnect/trunk/webservice/mc/mc_project_api.php 2006-10-19 14:23:43 UTC (rev 71) @@ -296,7 +296,13 @@ $v_released = VERSION_RELEASED; } if ( version_add( $v_project_id, $v_name, $v_released, $v_description ) ) { - return version_get_id( $v_name, $v_project_id ); + $t_version_id = version_get_id( $v_name, $v_project_id ); + if ( !is_blank( $v_date_order ) ) { + $t_version = version_get( $t_version_id ); + $t_version->date_order = $v_date_order; + version_update( $t_version ); + } + return $t_version_id; } else { return null; } @@ -335,7 +341,9 @@ if ( is_blank( $v_name ) ) { return new soap_fault('Client', '', 'Mandatory field "name" was missing'); } - if ( !version_is_unique( $v_name, $v_project_id ) ) { + # check for duplicates + $t_old_version_name = version_get_field( $p_version_id, 'version' ); + if ( ( strtolower( $t_old_version_name ) != strtolower( $v_name ) ) && !version_is_unique( $v_name, $v_project_id ) ) { return new soap_fault( 'Client', '', 'Version exists for project', 'The version you attempted to update already exists for this project'); } if ( $v_released === false ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-18 18:14:12
|
Revision: 70 http://svn.sourceforge.net/mantisconnect/?rev=70&view=rev Author: planser Date: 2006-10-18 11:13:50 -0700 (Wed, 18 Oct 2006) Log Message: ----------- Added support for adding, updating and deleting project versions Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ISession.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/Session.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/service/MantisConnectPortTypeTest.java Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ISession.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ISession.java 2006-10-18 18:12:34 UTC (rev 69) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ISession.java 2006-10-18 18:13:50 UTC (rev 70) @@ -307,5 +307,20 @@ * Get the custom fields that belong to the specified project. */ public CustomFieldDefinitionData[] getCustomFieldDefinitions(long projectId) throws JMTException; + + /** + * Submit the specified version details. + */ + public long addVersion(ProjectVersionData version) throws JMTException; + + /** + * Update version method. + */ + public boolean updateVersion(ProjectVersionData version) throws JMTException; + + /** + * Delete the version with the specified id. + */ + public boolean deleteVersion(long id) throws JMTException; } Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/Session.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/Session.java 2006-10-18 18:12:34 UTC (rev 69) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/Session.java 2006-10-18 18:13:50 UTC (rev 70) @@ -730,5 +730,31 @@ } return result; } + + public long addVersion(ProjectVersionData version) throws JMTException { + try { + return toLong(getPortType().mc_project_version_add(getUser(), getPwd(), version)); + } catch (RemoteException e) { + throw new JMTException(e); + } + } + + public boolean updateVersion(ProjectVersionData version) throws JMTException { + try { + return portType + .mc_project_version_update(getUser(), getPwd(), version.getId(), version); + } catch (RemoteException e) { + throw new JMTException(e); + } + } + + public boolean deleteVersion(long versionId) throws JMTException { + try { + return getPortType() + .mc_project_version_delete(getUser(), getPwd(), toBigInt(versionId)); + } catch (RemoteException e) { + throw new JMTException(e); + } + } } \ No newline at end of file Modified: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/service/MantisConnectPortTypeTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/service/MantisConnectPortTypeTest.java 2006-10-18 18:12:34 UTC (rev 69) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/service/MantisConnectPortTypeTest.java 2006-10-18 18:13:50 UTC (rev 70) @@ -15,6 +15,7 @@ import java.math.BigInteger; import java.net.URL; import java.rmi.RemoteException; +import java.util.Calendar; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; @@ -859,5 +860,71 @@ assertNotNull(result); assertTrue(result.length >= 1); } + + public void testCRUDVersion() { + BigInteger projectId = getAccessibleProject(); + ProjectVersionData[] oldData = null; + try { + oldData = portType.mc_project_get_versions(user, pwd, projectId); + } catch (RemoteException e) { + fail(e.toString()); + } + BigInteger newVersionId = null; + String name = "99.99"; + String description = "Ignore - Added by MantisConnect Tests - Description"; + ProjectVersionData version = new ProjectVersionData((BigInteger) null, name, projectId, null, description, null); + // create + try { + newVersionId = portType.mc_project_version_add(user, pwd, version); + } catch (RemoteException e) { + fail(e.toString()); + } + assertNotNull(newVersionId); + ProjectVersionData[] newData = null; + try { + newData = portType.mc_project_get_versions(user, pwd, projectId); + } catch (RemoteException e) { + fail(e.toString()); + } + assertEquals(oldData.length + 1, newData.length); + assertEquals(newVersionId, newData[0].getId()); + assertEquals(name, newData[0].getName()); + assertEquals(description, newData[0].getDescription()); + assertTrue(newData[0].getReleased().booleanValue()); + // update + name += " Updated"; + description += " Updated"; + newData[0].setName(name); + newData[0].setDescription(description); + newData[0].setReleased(Boolean.FALSE); + newData[0].setDate_order(Calendar.getInstance()); + try { + assertTrue(portType.mc_project_version_update(user, pwd, newVersionId, newData[0])); + } catch (RemoteException e) { + fail(e.getMessage()); + } + try { + newData = portType.mc_project_get_versions(user, pwd, projectId); + } catch (RemoteException e) { + fail(e.toString()); + } + assertEquals(newVersionId, newData[0].getId()); + assertEquals(name, newData[0].getName()); + assertEquals(description, newData[0].getDescription()); + assertFalse(newData[0].getReleased().booleanValue()); + // delete + try { + assertTrue(portType.mc_project_version_delete(user, pwd, newVersionId)); + } catch (RemoteException e) { + fail(e.getMessage()); + } + try { + newData = portType.mc_project_get_versions(user, pwd, projectId); + } catch (RemoteException e) { + fail(e.toString()); + } + assertEquals(oldData.length, newData.length); + System.out.println("Version added, read, updated and deleted (ID = " + newVersionId + ")"); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-18 18:12:43
|
Revision: 69 http://svn.sourceforge.net/mantisconnect/?rev=69&view=rev Author: planser Date: 2006-10-18 11:12:34 -0700 (Wed, 18 Oct 2006) Log Message: ----------- 0000234: Administrative webservices for MantisConnect (partly - added mc_project_version_(add|update|delete) Modified Paths: -------------- mantisconnect/trunk/webservice/mc/mantisconnect.php mantisconnect/trunk/webservice/mc/mc_project_api.php Modified: mantisconnect/trunk/webservice/mc/mantisconnect.php =================================================================== --- mantisconnect/trunk/webservice/mc/mantisconnect.php 2006-10-18 14:45:52 UTC (rev 68) +++ mantisconnect/trunk/webservice/mc/mantisconnect.php 2006-10-18 18:12:34 UTC (rev 69) @@ -1076,6 +1076,52 @@ false, false, false, 'Get the versions belonging to the specified project.' ); + + ### mc_project_version_add + $l_oServer->register( 'mc_project_version_add', + array( + 'username' => 'xsd:string', + 'password' => 'xsd:string', + 'version' => 'tns:ProjectVersionData' + ), + array( + 'return' => 'xsd:integer' + ), + $t_namespace, + false, false, false, + 'Submit the specified version details.' + ); + + ### mc_project_version_update + $l_oServer->register( 'mc_project_version_update', + array( + 'username' => 'xsd:string', + 'password' => 'xsd:string', + 'version_id' => 'xsd:integer', + 'version' => 'tns:ProjectVersionData' + ), + array( + 'return' => 'xsd:boolean' + ), + $t_namespace, + false, false, false, + 'Update version method.' + ); + + ### mc_project_version_delete + $l_oServer->register( 'mc_project_version_delete', + array( + 'username' => 'xsd:string', + 'password' => 'xsd:string', + 'version_id' => 'xsd:integer' + ), + array( + 'return' => 'xsd:boolean' + ), + $t_namespace, + false, false, false, + 'Delete the version with the specified id.' + ); ### mc_project_get_released_versions $l_oServer->register( 'mc_project_get_released_versions', Modified: mantisconnect/trunk/webservice/mc/mc_project_api.php =================================================================== --- mantisconnect/trunk/webservice/mc/mc_project_api.php 2006-10-18 14:45:52 UTC (rev 68) +++ mantisconnect/trunk/webservice/mc/mc_project_api.php 2006-10-18 18:12:34 UTC (rev 69) @@ -265,6 +265,120 @@ } /** + * Submit the specified version details. + * + * @param string $p_username The name of the user trying to add the issue. + * @param string $p_password The password of the user. + * @param Array $p_version A ProjectVersionData structure containing information about the new verison. + * @return integer The id of the created version. + */ + function mc_project_version_add( $p_username, $p_password, $p_version ) { + $t_user_id = mci_check_login( $p_username, $p_password ); + if ( $t_user_id === false ) { + return new soap_fault( 'Client', '', 'Access Denied', 'Username/password combination was incorrect'); + } + if ( !mci_has_administrator_access( $t_user_id ) ) { + return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access'); + } + extract( $p_version, EXTR_PREFIX_ALL, 'v'); + if ( is_blank( $v_project_id ) ) { + return new soap_fault('Client', '', 'Mandatory field "project_id" was missing'); + } + if ( is_blank( $v_name ) ) { + return new soap_fault('Client', '', 'Mandatory field "name" was missing'); + } + if ( !version_is_unique( $v_name, $v_project_id ) ) { + return new soap_fault( 'Client', '', 'Version exists for project', 'The version you attempted to add already exists for this project'); + } + if ( $v_released === false ) { + $v_released = VERSION_FUTURE; + } else { + $v_released = VERSION_RELEASED; + } + if ( version_add( $v_project_id, $v_name, $v_released, $v_description ) ) { + return version_get_id( $v_name, $v_project_id ); + } else { + return null; + } + } + + /** + * Submit the specified version details. + * + * @param string $p_username The name of the user trying to update the issue. + * @param string $p_password The password of the user. + * @param integer $p_version_id A version's id + * @param Array $p_version A ProjectVersionData structure containing information about the new verison. + * @return bool returns true or false depending on the success of the update action + */ + function mc_project_version_update( $p_username, $p_password, $p_version_id, $p_version ) { + $t_user_id = mci_check_login( $p_username, $p_password ); + if ( $t_user_id === false ) { + return new soap_fault( 'Client', '', 'Access Denied', 'Username/password combination was incorrect'); + } + if ( !mci_has_administrator_access( $t_user_id ) ) { + return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access'); + } + if ( is_blank( $p_version_id ) ) { + return new soap_fault('Client', '', 'Mandatory field "version_id" was missing'); + } + if ( !version_exists( $p_version_id ) ) { + return new soap_fault( 'Client', '', "Version '$p_version_id' does not exist." ); + } + extract( $p_version, EXTR_PREFIX_ALL, 'v'); + if ( is_blank( $v_project_id ) ) { + return new soap_fault('Client', '', 'Mandatory field "project_id" was missing'); + } + if ( !project_exists( $v_project_id ) ) { + return new soap_fault( 'Client', '', "Version '$v_project_id' does not exist." ); + } + if ( is_blank( $v_name ) ) { + return new soap_fault('Client', '', 'Mandatory field "name" was missing'); + } + if ( !version_is_unique( $v_name, $v_project_id ) ) { + return new soap_fault( 'Client', '', 'Version exists for project', 'The version you attempted to update already exists for this project'); + } + if ( $v_released === false ) { + $v_released = VERSION_FUTURE; + } else { + $v_released = VERSION_RELEASED; + } + $t_version_data = new VersionData(); + $t_version_data->id = $p_version_id; + $t_version_data->project_id = $v_project_id; + $t_version_data->version = $v_name; + $t_version_data->description = $v_description; + $t_version_data->released = $v_released; + $t_version_data->date_order = $v_date_order; + return version_update( $t_version_data ); + } + + /** + * Delete a version. + * + * @param string $p_username The name of the user trying to delete the version. + * @param string $p_password The password of the user. + * @param integer $p_version_id A version's id + * @return bool returns true or false depending on the success of the delete action + */ + function mc_project_version_delete( $p_username, $p_password, $p_version_id ) { + $t_user_id = mci_check_login( $p_username, $p_password ); + if ( $t_user_id === false ) { + return new soap_fault( 'Client', '', 'Access Denied', 'Username/password combination was incorrect'); + } + if ( !mci_has_administrator_access( $t_user_id ) ) { + return new soap_fault( 'Client', '', 'Access Denied', 'User does not have administrator access'); + } + if ( is_blank( $p_version_id ) ) { + return new soap_fault('Client', '', 'Mandatory field "version_id" was missing'); + } + if ( !version_exists( $p_version_id ) ) { + return new soap_fault( 'Client', '', "Version '$p_version_id' does not exist." ); + } + return version_remove( $p_version_id ); + } + + /** * Get the custom fields that belong to the specified project. * * @param string $p_username The name of the user trying to access the versions. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 68 http://svn.sourceforge.net/mantisconnect/?rev=68&view=rev Author: planser Date: 2006-10-18 07:45:52 -0700 (Wed, 18 Oct 2006) Log Message: ----------- Centered label, border was not drawn on all toolkits Modified Paths: -------------- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ui/customfields/DateCustomFieldControl.java Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ui/customfields/DateCustomFieldControl.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ui/customfields/DateCustomFieldControl.java 2006-10-18 13:32:56 UTC (rev 67) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ui/customfields/DateCustomFieldControl.java 2006-10-18 14:45:52 UTC (rev 68) @@ -48,10 +48,13 @@ @Override public void fillIntoGrid(final Composite parent, int columns, FormToolkit toolkit) { createLabel(toolkit, parent, getName() + ": ").setLayoutData( - new TableWrapData(TableWrapData.LEFT, TableWrapData.TOP)); + new TableWrapData(TableWrapData.LEFT, TableWrapData.MIDDLE)); Composite composite = toolkit.createComposite(parent); GridLayout gl = new GridLayout(2, false); gl.marginHeight = gl.marginWidth = 0; + // There seems to be a bug when rendering the border. + // We need 1 pixel here. Otherwise the border on the left hand side will not be drawn. + gl.marginLeft = 1; composite.setLayout(gl); TableWrapData twd = new TableWrapData(TableWrapData.FILL_GRAB); twd.colspan = columns - 1; @@ -62,6 +65,7 @@ Button button = createButton(toolkit, composite, "...", false, SWT.PUSH, new ButtonSelectionListener()); button.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL)); + toolkit.paintBordersFor(composite); } @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-18 13:33:15
|
Revision: 67 http://svn.sourceforge.net/mantisconnect/?rev=67&view=rev Author: planser Date: 2006-10-18 06:32:56 -0700 (Wed, 18 Oct 2006) Log Message: ----------- Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CheckboxCustomFieldFormat.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/DateCustomFieldFormat.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ListCustomFieldFormat.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/StringCustomFieldFormat.java Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CheckboxCustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CheckboxCustomFieldFormat.java 2006-10-18 08:22:56 UTC (rev 66) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CheckboxCustomFieldFormat.java 2006-10-18 13:32:56 UTC (rev 67) @@ -37,6 +37,9 @@ * ("true" or "false"). */ public String format(Object object) throws CustomFieldFormatException { + if (! (object instanceof Boolean)) { + throw new CustomFieldFormatException("java.lang.Boolean expected."); + } return ((Boolean) object).toString(); } Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/DateCustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/DateCustomFieldFormat.java 2006-10-18 08:22:56 UTC (rev 66) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/DateCustomFieldFormat.java 2006-10-18 13:32:56 UTC (rev 67) @@ -40,6 +40,9 @@ * @return The date in miliseconds. */ public String format(Object object) throws CustomFieldFormatException { + if (! (object instanceof Date)) { + throw new CustomFieldFormatException("java.util.Date expected."); + } return String.valueOf(((Date) object).getTime() / 1000); } @@ -51,9 +54,13 @@ * @return An object of type <code>java.util.Date.</code> */ public Object parse(String string) throws CustomFieldFormatException { - Calendar calendar = GregorianCalendar.getInstance(); - calendar.setTimeInMillis(Long.parseLong(string) * 1000); - return calendar.getTime(); + try { + Calendar calendar = GregorianCalendar.getInstance(); + calendar.setTimeInMillis(Long.parseLong(string) * 1000); + return calendar.getTime(); + } catch (Exception e) { + throw new CustomFieldFormatException(e); + } } } Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ListCustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ListCustomFieldFormat.java 2006-10-18 08:22:56 UTC (rev 66) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ListCustomFieldFormat.java 2006-10-18 13:32:56 UTC (rev 67) @@ -47,6 +47,9 @@ * by "|". */ public String format(Object object) throws CustomFieldFormatException { + if (! (object instanceof String[])) { + throw new CustomFieldFormatException("java.lang.String[] expected."); + } String[] items = (String[]) object; validateSingleSelection(items); validateAllowedValues(items); @@ -82,13 +85,17 @@ * als String-Array). */ public Object parse(String string) throws CustomFieldFormatException { - StringTokenizer tokenizer = new StringTokenizer(string, "|"); - String[] result = new String[tokenizer.countTokens()]; - int pos = 0; - while (tokenizer.hasMoreElements()) { - result[pos++] = tokenizer.nextToken(); + try { + StringTokenizer tokenizer = new StringTokenizer(string, "|"); + String[] result = new String[tokenizer.countTokens()]; + int pos = 0; + while (tokenizer.hasMoreElements()) { + result[pos++] = tokenizer.nextToken(); + } + return result; + } catch (Exception e) { + throw new CustomFieldFormatException(e); } - return result; } } Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/StringCustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/StringCustomFieldFormat.java 2006-10-18 08:22:56 UTC (rev 66) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/StringCustomFieldFormat.java 2006-10-18 13:32:56 UTC (rev 67) @@ -38,6 +38,9 @@ * @return The unmodified parameter <code>object.</code> */ public String format(Object object) throws CustomFieldFormatException { + if (! (object instanceof String)) { + throw new CustomFieldFormatException("java.lang.String expected."); + } validateMinLength((String) object); validateMaxLength((String) object); validateAllowedValue((String) object); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-18 08:23:02
|
Revision: 66 http://svn.sourceforge.net/mantisconnect/?rev=66&view=rev Author: planser Date: 2006-10-18 01:22:56 -0700 (Wed, 18 Oct 2006) Log Message: ----------- Added Ant libs to classpath Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/.classpath Modified: mantisconnect/trunk/clients/java/client-api/.classpath =================================================================== --- mantisconnect/trunk/clients/java/client-api/.classpath 2006-10-17 20:19:21 UTC (rev 65) +++ mantisconnect/trunk/clients/java/client-api/.classpath 2006-10-18 08:22:56 UTC (rev 66) @@ -14,5 +14,8 @@ <classpathentry kind="lib" path="lib/saaj.jar"/> <classpathentry kind="lib" path="lib/wsdl4j-1.5.1.jar"/> <classpathentry kind="lib" path="lib/activation.jar"/> + <classpathentry kind="lib" path="lib/ant.jar"/> + <classpathentry kind="lib" path="lib/ant-launcher.jar"/> + <classpathentry kind="lib" path="lib/ant-testutil.jar"/> <classpathentry kind="output" path="classes"/> </classpath> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 20:19:30
|
Revision: 65 http://svn.sourceforge.net/mantisconnect/?rev=65&view=rev Author: planser Date: 2006-10-17 13:19:21 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/build.properties.sample mantisconnect/trunk/clients/java/client-api/build.xml Modified: mantisconnect/trunk/clients/java/client-api/build.properties.sample =================================================================== --- mantisconnect/trunk/clients/java/client-api/build.properties.sample 2006-10-17 20:04:23 UTC (rev 64) +++ mantisconnect/trunk/clients/java/client-api/build.properties.sample 2006-10-17 20:19:21 UTC (rev 65) @@ -22,6 +22,13 @@ test.project.versions.future = 2.0 # All filters we get with the project (separated by semicolon) # The first filter should return at least one issue. -test.project.filters = ReportedByMe +test.project.filters = ReportedByMe;AssignedToMe # Names of custom fields expected for issues -test.project.customfields = ACustomField; \ No newline at end of file +test.project.customfields = ADateField;AStringField +# Name of the custom field we want to submit with test issues +test.project.customfield.name = ADateField +# Value of the custom field we want to submit +test.project.customfield.value = 02.05.1978 +# Format of the custom field we want to submit +# (only needed if the custom field is a date field - leave empty otherwise) +test.project.customfield.format = dd.MM.yy \ No newline at end of file Modified: mantisconnect/trunk/clients/java/client-api/build.xml =================================================================== --- mantisconnect/trunk/clients/java/client-api/build.xml 2006-10-17 20:04:23 UTC (rev 64) +++ mantisconnect/trunk/clients/java/client-api/build.xml 2006-10-17 20:19:21 UTC (rev 65) @@ -47,7 +47,7 @@ <target name="compile-tests" depends="compile"> <mkdir dir="${build.test.dir}"/> - <javac srcdir="${test.src.dir}" destdir="${build.test.dir}"> + <javac srcdir="${test.src.dir}" destdir="${build.test.dir}" debug="true"> <classpath refid="project.classpath"/> </javac> </target> @@ -97,7 +97,7 @@ </target> <target name="test" depends="compile-tests"> - <junit haltonfailure="false"> + <junit haltonfailure="true"> <sysproperty key="test.version" value="${test.version}"/> <sysproperty key="test.url" value="${test.url}"/> <sysproperty key="test.user" value="${test.user}"/> @@ -111,9 +111,12 @@ <sysproperty key="test.project.versions.future" value="${test.project.versions.future}"/> <sysproperty key="test.project.filters" value="${test.project.filters}"/> <sysproperty key="test.project.customfields" value="${test.project.customfields}"/> + <sysproperty key="test.project.customfield.name" value="${test.project.customfield.name}"/> + <sysproperty key="test.project.customfield.value" value="${test.project.customfield.value}"/> + <sysproperty key="test.project.customfield.format" value="${test.project.customfield.format}"/> <classpath refid="project.classpath"/> <formatter type="plain" usefile="false"/> - <batchtest> + <batchtest fork="yes"> <fileset dir="${build.test.dir}" includes="**/*Test.class"/> </batchtest> </junit> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 20:04:34
|
Revision: 64 http://svn.sourceforge.net/mantisconnect/?rev=64&view=rev Author: planser Date: 2006-10-17 13:04:23 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Added Paths: ----------- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/CustomField.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/IssueSubmitTask.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/MantisConnectTask.java Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/CustomField.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/CustomField.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/CustomField.java 2006-10-17 20:04:23 UTC (rev 64) @@ -0,0 +1,141 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.StringTokenizer; + +import org.apache.tools.ant.BuildException; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.service.CustomFieldDefinitionData; +import org.mantisbt.connect.service.ObjectRef; +import org.mantisbt.connect.service.ProjectData; +import org.mantisbt.connect.text.CustomFieldFormat; +import org.mantisbt.connect.text.CustomFieldFormatException; + +/** + * @author Peter Lanser, pl...@us... + */ +public class CustomField { + + private IssueSubmitTask task; + + private String name; + + private String value; + + private String format; + + public CustomField(IssueSubmitTask task) { + this.task = task; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public void setFormat(String format) { + this.format = format; + } + + protected CustomFieldDefinitionData getCustomFieldDefinition() { + ProjectData project = task.getProjectData(); + CustomFieldDefinitionData[] definitions = null; + try { + definitions = task.getSession().getCustomFieldDefinitions( + project.getId().longValue()); + } catch (JMTException e) { + throw new BuildException(e.getMessage()); + } + if (definitions != null) { + for (int i = 0; i < definitions.length; i++) { + if (definitions[i].getField().getName().equals(getName())) { + return definitions[i]; + } + } + } + throw new BuildException("Custom field '" + name + + "' not found for project '" + project.getName() + "'."); + } + + public String getMCValue() throws BuildException { + CustomFieldDefinitionData definition = getCustomFieldDefinition(); + try { + Object object = parseValue(definition.getType().intValue(), value); + return CustomFieldFormat.getInstance(definition).format(object); + } catch (CustomFieldFormatException e) { + throw new BuildException(e); + } + } + + protected Object parseValue(int type, String value) { + switch (type) { + case ISession.CF_TYPE_CHECKBOX: + return Boolean.valueOf(value); + case ISession.CF_TYPE_DATE: + return parseDate(value); + case ISession.CF_TYPE_EMAIL: + case ISession.CF_TYPE_FLOAT: + case ISession.CF_TYPE_NUMERIC: + case ISession.CF_TYPE_STRING: + return value; + case ISession.CF_TYPE_ENUM: + case ISession.CF_TYPE_LIST: + case ISession.CF_TYPE_MULTILIST: + return parseList(value); + default: + throw new IllegalArgumentException("Cannot parse type '" + type + + "'."); + } + } + + private Object parseList(String value) { + StringTokenizer tokenizer = new StringTokenizer(value, "|"); + String[] result = new String[tokenizer.countTokens()]; + int pos = 0; + while (tokenizer.hasMoreElements()) { + result[pos++] = tokenizer.nextToken(); + } + return result; + } + + private Object parseDate(String value) { + if (format == null) { + throw new BuildException( + "The format attribute must be present if custom field is of type date."); + } + try { + return new SimpleDateFormat(format).parse(value); + } catch (ParseException e) { + throw new BuildException(e); + } + } + + public ObjectRef getField() { + return getCustomFieldDefinition().getField(); + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/IssueSubmitTask.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/IssueSubmitTask.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/IssueSubmitTask.java 2006-10-17 20:04:23 UTC (rev 64) @@ -0,0 +1,490 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import org.apache.tools.ant.BuildException; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.service.CustomFieldValueForIssueData; +import org.mantisbt.connect.service.IssueData; +import org.mantisbt.connect.service.ObjectRef; +import org.mantisbt.connect.service.ProjectData; + +/** + * <p> + * This task can be used to submit issues via Ant. + * </p> + * <p> + * The following attributes are mandatory: + * <ul> + * <li><b>url</b></li> + * <li><b>username</b></li> + * <li><b>password</b></li> + * <li><b>project</b> (The name of the project)</li> + * <li><b>summary</b></li> + * <li><b>description</b></li> + * </ul> + * </p> + * <p> + * The following attributes are optional: + * <ul> + * <li><b>proxHost</b> (mandatory if proxyPort is given)</li> + * <li><b>proxyPort</b> (mandatory if proxyHost is given)</li> + * <li><b>version</b></li> + * <li><b>reproducibility</b></li> + * <li><b>severity</b></li> + * <li><b>priority</b></li> + * <li><b>additionalInfo</b></li> + * <li><b>stepsToReproduce</b></li> + * <li><b>private</b></li> + * </ul> + * </p> + * <p> + * <b>Enumerations (reproducibility, severity and priority):</b> + * </p> + * <p> + * For each enumeration you can use strings. The strings map to integers as + * defined for the appropriate enum in config_defaults_inc.php of Mantis. If + * you've defined your own enums then you can use integers instead of strings. + * </p> + * <p> + * <ul> + * <li><b>reproducibility:</b> "always" (10), "sometimes" (30), "random" (50), + * "have-not-tried" (70), "unable-to-reproduce" (90), "n/a" (100)</li> + * <li><b>severity:</b> "feature" (10), "trivial" (20), "text" (30), "tweak" + * (40), "minor" (50), "major" (60), "crash" (70), "block" (80)</li> + * <li><b>priority:</b> "none" (10), "low" (20), "normal" (30), "high" (40), + * "urgent" (50), "immediate" (60)</li> + * </ul> + * </p> + * <p> + * <b>Support for custom fields</b> + * </p> + * <p> + * Custom fields can be added by nesting <i>customfield</i> elements within a + * submit task. + * </p> + * <p> + * The attributes <i>name</i> and <i>value</i> are mandatory for + * <i>customfield</i> elements. + * <p> + * <p> + * <b>Remarks:</b> + * <ul> + * <li>Use "true" or "false" for custom fields of type <i>Checkboxfield.</i></li> + * <li>If a custom field is of type <i>Date</i> then a third attribute + * <i>format</i> is mandatory which defines the format of the given date.</li> + * </ul> + * </p> + * <p> + * <b>Example:</b> + * </p> + * <p> + * In the following example all attributes and two custom fields are set. The + * first custom field would be a string the second one would be a date. Note + * that instead of using <i>sometimes, block</i> and <i>high</i> for + * reproducibility, severity and priority you could also use the integer values + * <i>30, 80</i> and <i>40.</i> + * <p> + * <p> + * + * <pre> + * <taskdef name="submit" classname="org.mantisbt.connect.ant.taskdefs.IssueSubmitTask" classpath="${cp}" /> + * + * <target name="submit-issue"> + * <submit url="http://yourhost/mantis/mc/mantisconnect.php" + * username="AUser" password="APassword" + * project="AProjectName" + * category="ACategory" + * summary="ASummary" + * description="ADescription" + * version="AVersion" + * reproducibility="sometimes" + * severity="block" + * priority="high" + * additionalInfo="AdditionalInfo" + * platform="APlatform" + * os="AnOs" + * osVersion="AnOsVersion" + * productBuild="AProductBuild" + * stepsToReproduce="StepsToReproduce" + * private="true"/> + * <customfield name="AStringField" value="AValue"/> + * <customfield name="ADateField" value="02.05.1978" format="dd.MM.yy"/> + * </target> + * </pre> + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class IssueSubmitTask extends MantisConnectTask { + + public static final String REPRODUCIBILITY_ALWAYS = "always"; + + public static final String REPRODUCIBILITY_SOMETIMES = "sometimes"; + + public static final String REPRODUCIBILITY_RANDOM = "random"; + + public static final String REPRODUCIBILITY_HAVE_NOT_TRIED = "have-not-tried"; + + public static final String REPRODUCIBILITY_UNABLE_TO_REPRODUCE = "unable-to-reproduce"; + + public static final String REPRODUCIBILITY_NA = "n/a"; + + public static final long REPRODUCIBILITY_ALWAYS_NUM = 10; + + public static final long REPRODUCIBILITY_SOMETIMES_NUM = 30; + + public static final long REPRODUCIBILITY_RANDOM_NUM = 50; + + public static final long REPRODUCIBILITY_HAVE_NOT_TRIED_NUM = 70; + + public static final long REPRODUCIBILITY_UNABLE_TO_REPRODUCE_NUM = 90; + + public static final long REPRODUCIBILITY_NA_NUM = 100; + + public static final String SEVERITY_FEATURE = "feature"; + + public static final String SEVERITY_TRIVIAL = "trivial"; + + public static final String SEVERITY_TEXT = "text"; + + public static final String SEVERITY_TWEAK = "tweak"; + + public static final String SEVERITY_MINOR = "minor"; + + public static final String SEVERITY_MAJOR = "major"; + + public static final String SEVERITY_CRASH = "crash"; + + public static final String SEVERITY_BLOCK = "block"; + + public static final long SEVERITY_FEATURE_NUM = 10; + + public static final long SEVERITY_TRIVIAL_NUM = 20; + + public static final long SEVERITY_TEXT_NUM = 30; + + public static final long SEVERITY_TWEAK_NUM = 40; + + public static final long SEVERITY_MINOR_NUM = 50; + + public static final long SEVERITY_MAJOR_NUM = 60; + + public static final long SEVERITY_CRASH_NUM = 70; + + public static final long SEVERITY_BLOCK_NUM = 80; + + public static final String PRIORITY_NONE = "none"; + + public static final String PRIORITY_LOW = "low"; + + public static final String PRIORITY_NORMAL = "normal"; + + public static final String PRIORITY_HIGH = "high"; + + public static final String PRIORITY_URGENT = "urgent"; + + public static final String PRIORITY_IMMEDIATE = "immediate"; + + public static final long PRIORITY_NONE_NUM = 10; + + public static final long PRIORITY_LOW_NUM = 20; + + public static final long PRIORITY_NORMAL_NUM = 30; + + public static final long PRIORITY_HIGH_NUM = 40; + + public static final long PRIORITY_URGENT_NUM = 50; + + public static final long PRIORITY_IMMEDIATE_NUM = 60; + + private String project; + + private String category; + + private String version; + + private String reproducibility; + + private String severity; + + private String priority; + + private String summary; + + private String description; + + private String additionalInfo; + + private String platform; + + private String os; + + private String osVersion; + + private String productBuild; + + private String stepsToReproduce; + + private boolean isPrivate; + + private List customFields = new ArrayList(); + + public void execute() throws BuildException { + checkAttributes(); + ISession session = getSession(); + IssueData issue = createIssue(session); + ProjectData projectData = getProjectByName(project); + issue.setProject(new ObjectRef(projectData.getId(), null)); + issue.setCategory(category); + issue.setSummary(summary); + issue.setDescription(description); + issue.setAdditional_information(additionalInfo); + issue.setSteps_to_reproduce(stepsToReproduce); + issue.setVersion(version); + issue.setOs(os); + issue.setPlatform(platform); + issue.setBuild(productBuild); + issue.setOs_build(osVersion); + issue.setReproducibility(getReproducibility()); + issue.setSeverity(getSeverity()); + issue.setPriority(getPriority()); + issue.setView_state(getViewState()); + CustomFieldValueForIssueData[] fieldValues = new CustomFieldValueForIssueData[customFields + .size()]; + for (int i = 0; i < fieldValues.length; i++) { + CustomField customField = (CustomField) customFields.get(i); + fieldValues[i] = new CustomFieldValueForIssueData(customField + .getField(), customField.getMCValue()); + } + issue.setCustom_fields(fieldValues); + try { + long issueId = session.addIssue(issue); + log("Added issue to '" + getUrl() + "' (ID " + issueId + ")"); + } catch (JMTException e) { + throw new BuildException("Could not add issue.", e); + } + } + + private ObjectRef getViewState() { + return new ObjectRef(isPrivate ? BigInteger + .valueOf(ISession.VS_PRIVATE) : BigInteger + .valueOf(ISession.VS_PUBLIC), null); + } + + private ObjectRef getPriority() { + if (priority != null) { + try { + return new ObjectRef(BigInteger.valueOf(Long + .parseLong(priority)), null); + } catch (NumberFormatException e) { + if (priority.equalsIgnoreCase(PRIORITY_NONE)) { + return new ObjectRef(BigInteger.valueOf(PRIORITY_NONE_NUM), + null); + } else if (priority.equalsIgnoreCase(PRIORITY_LOW)) { + return new ObjectRef(BigInteger.valueOf(PRIORITY_LOW_NUM), + null); + } else if (priority.equalsIgnoreCase(PRIORITY_NORMAL)) { + return new ObjectRef(BigInteger + .valueOf(PRIORITY_NORMAL_NUM), null); + } else if (priority.equalsIgnoreCase(PRIORITY_HIGH)) { + return new ObjectRef(BigInteger.valueOf(PRIORITY_HIGH_NUM), + null); + } else if (priority.equalsIgnoreCase(PRIORITY_URGENT)) { + return new ObjectRef(BigInteger + .valueOf(PRIORITY_URGENT_NUM), null); + } else if (priority.equalsIgnoreCase(PRIORITY_IMMEDIATE)) { + return new ObjectRef(BigInteger + .valueOf(PRIORITY_IMMEDIATE_NUM), null); + } + } + } + return null; + } + + private ObjectRef getSeverity() { + if (severity != null) { + try { + return new ObjectRef(BigInteger.valueOf(Long + .parseLong(severity)), null); + } catch (NumberFormatException e) { + if (severity.equalsIgnoreCase(SEVERITY_FEATURE)) { + return new ObjectRef(BigInteger + .valueOf(SEVERITY_FEATURE_NUM), null); + } else if (severity.equalsIgnoreCase(SEVERITY_TRIVIAL)) { + return new ObjectRef(BigInteger + .valueOf(SEVERITY_TRIVIAL_NUM), null); + } else if (severity.equalsIgnoreCase(SEVERITY_TEXT)) { + return new ObjectRef(BigInteger.valueOf(SEVERITY_TEXT_NUM), + null); + } else if (severity.equalsIgnoreCase(SEVERITY_TWEAK)) { + return new ObjectRef( + BigInteger.valueOf(SEVERITY_TWEAK_NUM), null); + } else if (severity.equalsIgnoreCase(SEVERITY_MINOR)) { + return new ObjectRef( + BigInteger.valueOf(SEVERITY_MINOR_NUM), null); + } else if (severity.equalsIgnoreCase(SEVERITY_MAJOR)) { + return new ObjectRef( + BigInteger.valueOf(SEVERITY_MAJOR_NUM), null); + } else if (severity.equalsIgnoreCase(SEVERITY_CRASH)) { + return new ObjectRef( + BigInteger.valueOf(SEVERITY_CRASH_NUM), null); + } else if (severity.equalsIgnoreCase(SEVERITY_BLOCK)) { + return new ObjectRef( + BigInteger.valueOf(SEVERITY_BLOCK_NUM), null); + } + } + } + return null; + } + + private ObjectRef getReproducibility() { + if (reproducibility != null) { + try { + return new ObjectRef(BigInteger.valueOf(Long + .parseLong(reproducibility)), null); + } catch (NumberFormatException e) { + if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_ALWAYS)) { + return new ObjectRef(BigInteger + .valueOf(REPRODUCIBILITY_ALWAYS_NUM), null); + } else if (reproducibility + .equalsIgnoreCase(REPRODUCIBILITY_SOMETIMES)) { + return new ObjectRef(BigInteger + .valueOf(REPRODUCIBILITY_SOMETIMES_NUM), null); + } else if (reproducibility + .equalsIgnoreCase(REPRODUCIBILITY_RANDOM)) { + return new ObjectRef(BigInteger + .valueOf(REPRODUCIBILITY_RANDOM_NUM), null); + } else if (reproducibility + .equalsIgnoreCase(REPRODUCIBILITY_HAVE_NOT_TRIED)) { + return new ObjectRef(BigInteger + .valueOf(REPRODUCIBILITY_HAVE_NOT_TRIED_NUM), null); + } else if (reproducibility + .equalsIgnoreCase(REPRODUCIBILITY_UNABLE_TO_REPRODUCE)) { + return new ObjectRef(BigInteger + .valueOf(REPRODUCIBILITY_UNABLE_TO_REPRODUCE_NUM), + null); + } else if (reproducibility.equalsIgnoreCase(REPRODUCIBILITY_NA)) { + return new ObjectRef(BigInteger + .valueOf(REPRODUCIBILITY_NA_NUM), null); + } + } + } + return null; + } + + private IssueData createIssue(ISession session) throws BuildException { + ProjectData projectData = getProjectByName(project); + try { + return session.newIssue(projectData.getId().longValue()); + } catch (JMTException e) { + throw new BuildException("Could not get initial data for '" + + project + "'.", e); + } + } + + public ProjectData getProjectData() { + return getProjectByName(project); + } + + public ISession getSession() { + return super.getSession(); + } + + protected void checkAttributes() { + super.checkAttributes(); + if (project == null) { + throw new BuildException("The project attribute must be present.", + getLocation()); + } + if (summary == null) { + throw new BuildException("The summary attribute must be present.", + getLocation()); + } + if (description == null) { + throw new BuildException( + "The description attribute must be present.", getLocation()); + } + } + + public void setAdditionalInfo(String additionalInfo) { + this.additionalInfo = additionalInfo; + } + + public void setCategory(String category) { + this.category = category; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setPrivate(boolean isPrivate) { + this.isPrivate = isPrivate; + } + + public void setOs(String os) { + this.os = os; + } + + public void setOsVersion(String osVersion) { + this.osVersion = osVersion; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + + public void setPriority(String priority) { + this.priority = priority; + } + + public void setProductBuild(String productBuild) { + this.productBuild = productBuild; + } + + public void setProject(String project) { + this.project = project; + } + + public void setReproducibility(String reproducibility) { + this.reproducibility = reproducibility; + } + + public void setSeverity(String severity) { + this.severity = severity; + } + + public void setStepsToReproduce(String stepsToReproduce) { + this.stepsToReproduce = stepsToReproduce; + } + + public void setSummary(String summary) { + this.summary = summary; + } + + public void setVersion(String version) { + this.version = version; + } + + public Object createCustomfield() { + CustomField field = new CustomField(this); + customFields.add(field); + return field; + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/MantisConnectTask.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/MantisConnectTask.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/MantisConnectTask.java 2006-10-17 20:04:23 UTC (rev 64) @@ -0,0 +1,176 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.net.URL; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Task; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.ISessionFactory; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.SessionFactory; +import org.mantisbt.connect.service.ProjectData; + +/** + * <p> + * Base class for MantisConnect Ant Tasks. + * </p> + * <p> + * Tasks of this types at least have the following attributes: + * <ul> + * <li><b>url:</b> The endpoint of a MantisConnect webservice (mandatory)</li> + * <li><b>username:</b> The username to use with the webservice (mandatory)</li> + * <li><b>password:</b> The password to use with the webservice (mandatory)</li> + * <li><b>proxyHost:</b> The proxy host to use (only mandatory if proxyPort is + * given)</li> + * <li><b>proxyPort:</b> The proxy port to use (only mandatory if proxyHost is + * given)</li> + * </ul> + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class MantisConnectTask extends Task { + + private String url; + + private String username; + + private String password; + + private String proxyHost; + + private Integer proxyPort; + + private ISession session; + + /** + * <p> + * Calls <code>checkAttributes().</code> Overriding classes should call + * this super implementation. + * </p> + */ + public void execute() throws BuildException { + checkAttributes(); + } + + /** + * <p> + * Checks the presence of attributes <i>url, username, password, proxyHost + * and proxyPort.</i> Overriding classes should call this super + * implementation. + * </p> + */ + protected void checkAttributes() { + if (url == null) { + throw new BuildException("The url attribute must be present.", getLocation()); + } + if (username == null) { + throw new BuildException("The username attribute must be present.", getLocation()); + } + if (password == null) { + throw new BuildException("The password attribute must be present.", getLocation()); + } + if (proxyHost != null && proxyPort == null) { + throw new BuildException("The proxyPort attribute must be present.", getLocation()); + } + if (proxyPort != null) { + try { + proxyPort.intValue(); + } catch (NumberFormatException e) { + throw new BuildException("The proxyPort attribute must be an integer.", + getLocation()); + } + if (proxyHost == null) { + throw new BuildException("The proxyHost attribute must be present.", getLocation()); + } + } + } + + protected ProjectData getProjectByName(String project) { + ProjectData[] projects = null; + try { + projects = getSession().getAccessibleProjects(); + } catch (JMTException e) { + throw new BuildException("Could not get accessible projects.", e); + } + if (projects != null) { + for (int i = 0; i < projects.length; i++) { + if (projects[i].getName().equals(project)) { + return projects[i]; + } + } + } + throw new BuildException("Project '" + project + "' not found."); + } + + protected ISession getSession() throws BuildException { + if (session == null) { + ISessionFactory factory = SessionFactory.getInstance(); + if (useProxy()) { + factory.setProxy(proxyHost, proxyPort.intValue()); + } + try { + session = factory.newSession(new URL(url), username, password); + } catch (Exception e) { + throw new BuildException(e); + } + } + return session; + } + + protected boolean useProxy() { + return proxyHost != null && proxyPort != null; + } + + public void setPassword(String password) { + this.password = password; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setUsername(String username) { + this.username = username; + } + + public void setProxyHost(String proxyHost) { + this.proxyHost = proxyHost; + } + + public void setProxyPort(Integer proxyPort) { + this.proxyPort = proxyPort; + } + + protected String getPassword() { + return password; + } + + protected String getProxyHost() { + return proxyHost; + } + + protected Integer getProxyPort() { + return proxyPort; + } + + protected String getUrl() { + return url; + } + + protected String getUsername() { + return username; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 20:03:55
|
Revision: 63 http://svn.sourceforge.net/mantisconnect/?rev=63&view=rev Author: planser Date: 2006-10-17 13:03:37 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Added Paths: ----------- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CheckboxCustomFieldFormat.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CustomFieldFormat.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CustomFieldFormatException.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/DateCustomFieldFormat.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ICustomFieldFormat.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ListCustomFieldFormat.java mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/StringCustomFieldFormat.java Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CheckboxCustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CheckboxCustomFieldFormat.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CheckboxCustomFieldFormat.java 2006-10-17 20:03:37 UTC (rev 63) @@ -0,0 +1,55 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import org.mantisbt.connect.service.CustomFieldDefinitionData; + +/** + * <p> + * Use objects of this type for Custom Fields of type <i>Checkbox.</i> + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class CheckboxCustomFieldFormat extends CustomFieldFormat { + + public CheckboxCustomFieldFormat(CustomFieldDefinitionData definition) { + super(definition); + } + + /** + * <p> + * No restrictions are evaluated. + * </p> + * + * @param object + * Must be an object of type <code>java.lang.Boolean.</code> + * @return The string-representation of the parameter <code>object</code> + * ("true" or "false"). + */ + public String format(Object object) throws CustomFieldFormatException { + return ((Boolean) object).toString(); + } + + /** + * <p> + * Expects a String containing which will be evaluated with + * <code>java.lang.Boolean.valueOf(string).</code> + * </p> + * + * @return An object of type <code>java.lang.Boolean</code> + */ + public Object parse(String string) throws CustomFieldFormatException { + return Boolean.valueOf(string); + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CustomFieldFormat.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CustomFieldFormat.java 2006-10-17 20:03:37 UTC (rev 63) @@ -0,0 +1,122 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import java.util.StringTokenizer; + +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.service.CustomFieldDefinitionData; + +/** + * @author Peter Lanser, pl...@us... + */ +public abstract class CustomFieldFormat implements ICustomFieldFormat { + + private CustomFieldDefinitionData definition; + + public CustomFieldFormat(CustomFieldDefinitionData definition) { + this.definition = definition; + } + + public static CustomFieldFormat getInstance(CustomFieldDefinitionData definition) { + int type = definition.getType().intValue(); + switch (type) { + case ISession.CF_TYPE_CHECKBOX: + return new CheckboxCustomFieldFormat(definition); + case ISession.CF_TYPE_DATE: + return new DateCustomFieldFormat(definition); + case ISession.CF_TYPE_EMAIL: + case ISession.CF_TYPE_FLOAT: + case ISession.CF_TYPE_NUMERIC: + case ISession.CF_TYPE_STRING: + return new StringCustomFieldFormat(definition); + case ISession.CF_TYPE_ENUM: + case ISession.CF_TYPE_LIST: + case ISession.CF_TYPE_MULTILIST: + return new ListCustomFieldFormat(definition); + default: + throw new IllegalArgumentException("No format found for type " + type + "."); + } + } + + protected void validateMinLength(String value) throws CustomFieldFormatException { + int minLength = getMinLength(); + if (value.length() < minLength) { + throw new CustomFieldFormatException("Minimum length for '" + getFieldName() + "' is " + minLength + "."); + } + } + + protected void validateMaxLength(String value) throws CustomFieldFormatException { + int maxLength = getMaxLength(); + if (maxLength > 0 && value.length() > maxLength) { + throw new CustomFieldFormatException("Maximum length for '" + getFieldName() + "' is " + maxLength + "."); + } + } + + protected void validateAllowedValue(String value) throws CustomFieldFormatException { + String[] possibleValues = getPossibleValues(); + if (possibleValues != null && possibleValues.length > 0) { + boolean success = false; + for (int i = 0; i < possibleValues.length; i++) { + if (value.equals(possibleValues[i])) { + success = true; + } + } + if (! success) { + throw new CustomFieldFormatException("'" + value + "' is not allowed for '" + getFieldName() + "'."); + } + } + } + + protected String[] getPossibleValues() { + return parseItems(getDefinition().getPossible_values()); + } + + protected String[] parseItems(String values) { + if (values != null) { + StringTokenizer tokenizer = new StringTokenizer(values, "|"); + String[] result = new String[tokenizer.countTokens()]; + int idx = 0; + while (tokenizer.hasMoreElements()) { + result[idx++] = tokenizer.nextToken(); + } + return result; + } else { + return new String[0]; + } + } + + protected String getFieldName() { + return getDefinition().getField().getName(); + } + + protected int getMinLength() { + if (getDefinition().getLength_min() == null) { + return 0; + } else { + return getDefinition().getLength_min().intValue(); + } + } + + protected int getMaxLength() { + if (getDefinition().getLength_max() == null) { + return 0; + } else { + return getDefinition().getLength_max().intValue(); + } + } + + protected CustomFieldDefinitionData getDefinition() { + return definition; + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CustomFieldFormatException.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CustomFieldFormatException.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/CustomFieldFormatException.java 2006-10-17 20:03:37 UTC (rev 63) @@ -0,0 +1,33 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +/** + * @author Peter Lanser, pl...@us... + */ +public class CustomFieldFormatException extends Exception { + + private static final long serialVersionUID = -8002565027750783275L; + + public CustomFieldFormatException(String msg) { + super(msg); + } + + public CustomFieldFormatException(Throwable t) { + super(t); + } + + public CustomFieldFormatException(String msg, Throwable t) { + super(msg, t); + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/DateCustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/DateCustomFieldFormat.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/DateCustomFieldFormat.java 2006-10-17 20:03:37 UTC (rev 63) @@ -0,0 +1,59 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import org.mantisbt.connect.service.CustomFieldDefinitionData; + +/** + * <p> + * Use objects of this type for Custom Fields of type <i>Date.</i> + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class DateCustomFieldFormat extends CustomFieldFormat { + + public DateCustomFieldFormat(CustomFieldDefinitionData definition) { + super(definition); + } + + /** + * <p> + * No restrictions are evaluated. + * </p> + * + * @param object + * Must be an object of type <code>java.util.Date.</code> + * @return The date in miliseconds. + */ + public String format(Object object) throws CustomFieldFormatException { + return String.valueOf(((Date) object).getTime() / 1000); + } + + /** + * <p> + * Expects a String containing a date in miliseconds. + * </p> + * + * @return An object of type <code>java.util.Date.</code> + */ + public Object parse(String string) throws CustomFieldFormatException { + Calendar calendar = GregorianCalendar.getInstance(); + calendar.setTimeInMillis(Long.parseLong(string) * 1000); + return calendar.getTime(); + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ICustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ICustomFieldFormat.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ICustomFieldFormat.java 2006-10-17 20:03:37 UTC (rev 63) @@ -0,0 +1,50 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +/** + * <p> + * Objects of this type can be used to transfer values from Mantis-Format to + * Java-Format and vice-versa. + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public interface ICustomFieldFormat { + + /** + * <p> + * Parses a value which comes in Mantis-Format and transforms it into an + * appropriate Java-Object. + * </p> + * + * @throws CustomFieldFormatException + * This exception is thrown if an error occurres while the + * transformation. + */ + public Object parse(String string) throws CustomFieldFormatException; + + /** + * <p> + * Formats a Java-Object into the appropriate string representation for + * Mantis. + * </p> + * + * @throws CustomFieldFormatException + * This exception is thrown if the value doesn't fulfill certain + * restrictions (e.g. minimum length, maximum length, allowed + * values etc.). It depends on the concrete type which + * restrictions are checked. + */ + public String format(Object object) throws CustomFieldFormatException; + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ListCustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ListCustomFieldFormat.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ListCustomFieldFormat.java 2006-10-17 20:03:37 UTC (rev 63) @@ -0,0 +1,94 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import java.util.StringTokenizer; + +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.service.CustomFieldDefinitionData; + +/** + * <p> + * Use objects of this type for Custom Fields of type <i>Enumeration, List</i> + * and <i>Multiselection List.</i> + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class ListCustomFieldFormat extends CustomFieldFormat { + + public ListCustomFieldFormat(CustomFieldDefinitionData definition) { + super(definition); + } + + /** + * <p> + * For fields of type <i>Enumeration</i> and <i>List</i> only one single + * selection is possible. An exception is thrown if the field is of type + * <i>Enumeration</i> or <i>List</i> and the array contains more than one + * value. + * </p> + * <p> + * It is also checked that the values are allowed. + * </p> + * + * @param object + * Must be an object of type <code>java.lang.String[]</code> + * @return The elements of the parameter <code>object</code> concatenated + * by "|". + */ + public String format(Object object) throws CustomFieldFormatException { + String[] items = (String[]) object; + validateSingleSelection(items); + validateAllowedValues(items); + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < items.length; i++) { + if (i > 0) { + buffer.append("|"); + } + buffer.append(items[i]); + } + return buffer.toString(); + } + + private void validateAllowedValues(String[] items) throws CustomFieldFormatException { + for (int i = 0; i < items.length; i++) { + validateAllowedValue(items[i]); + } + } + + private void validateSingleSelection(String[] items) throws CustomFieldFormatException { + long type = getDefinition().getType().longValue(); + if ((type == ISession.CF_TYPE_ENUM || type == ISession.CF_TYPE_LIST) && items.length > 1) { + throw new CustomFieldFormatException("Only single selection allowed."); + } + } + + /** + * <p> + * Expects a string containing values separated by "|" + * </p> + * + * @return An object of type <code>java.lang.String[]</code> (the values + * als String-Array). + */ + public Object parse(String string) throws CustomFieldFormatException { + StringTokenizer tokenizer = new StringTokenizer(string, "|"); + String[] result = new String[tokenizer.countTokens()]; + int pos = 0; + while (tokenizer.hasMoreElements()) { + result[pos++] = tokenizer.nextToken(); + } + return result; + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/StringCustomFieldFormat.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/StringCustomFieldFormat.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/StringCustomFieldFormat.java 2006-10-17 20:03:37 UTC (rev 63) @@ -0,0 +1,55 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import org.mantisbt.connect.service.CustomFieldDefinitionData; + +/** + * <p> + * Use objects of this type for Custom Fields of type <i>String, Numeric, Float</i> + * and <i>Email.</i> + * </p> + * + * @author Peter Lanser, pl...@us... + */ +public class StringCustomFieldFormat extends CustomFieldFormat { + + public StringCustomFieldFormat(CustomFieldDefinitionData definition) { + super(definition); + } + + /** + * <p> + * Evaluated restrictions are <i>Minimum Length, Maximum Length</i> and + * <i>Allowed Values.</i> + * </p> + * + * @param object + * Must be an object of type <code>java.lang.String.</code> + * @return The unmodified parameter <code>object.</code> + */ + public String format(Object object) throws CustomFieldFormatException { + validateMinLength((String) object); + validateMaxLength((String) object); + validateAllowedValue((String) object); + return (String) object; + } + + /** + * @return An object of type <code>java.lang.String</code> (the unmodified + * parameter <code>string</code>). + */ + public Object parse(String string) throws CustomFieldFormatException { + return string; + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 20:03:20
|
Revision: 62 http://svn.sourceforge.net/mantisconnect/?rev=62&view=rev Author: planser Date: 2006-10-17 13:03:12 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/service/MantisConnectPortTypeTest.java Modified: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java 2006-10-17 20:02:40 UTC (rev 61) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/AllTests.java 2006-10-17 20:03:12 UTC (rev 62) @@ -1,5 +1,5 @@ /* - * Copyright 2005 Peter Lanser + * Copyright 2005, 2006 Peter Lanser * * MantisConnect is copyrighted to Victor Boctor * @@ -11,7 +11,12 @@ */ package org.mantisbt.connect; +import org.mantisbt.connect.ant.taskdefs.IssueSubmitTaskTest; import org.mantisbt.connect.service.MantisConnectPortTypeTest; +import org.mantisbt.connect.text.CheckboxCustomFieldFormatTest; +import org.mantisbt.connect.text.DateCustomFieldFormatTest; +import org.mantisbt.connect.text.ListCustomFieldFormatTest; +import org.mantisbt.connect.text.StringCustomFieldFormatTest; import junit.framework.Test; import junit.framework.TestSuite; @@ -29,6 +34,11 @@ // $JUnit-BEGIN$ suite.addTestSuite(MantisConnectPortTypeTest.class); suite.addTestSuite(SessionTest.class); + suite.addTestSuite(IssueSubmitTaskTest.class); + suite.addTestSuite(CheckboxCustomFieldFormatTest.class); + suite.addTestSuite(DateCustomFieldFormatTest.class); + suite.addTestSuite(ListCustomFieldFormatTest.class); + suite.addTestSuite(StringCustomFieldFormatTest.class); // $JUnit-END$ return suite; } Modified: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/service/MantisConnectPortTypeTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/service/MantisConnectPortTypeTest.java 2006-10-17 20:02:40 UTC (rev 61) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/service/MantisConnectPortTypeTest.java 2006-10-17 20:03:12 UTC (rev 62) @@ -1,5 +1,5 @@ /* - * Copyright 2005 Peter Lanser + * Copyright 2005, 2006 Peter Lanser * * MantisConnect is copyrighted to Victor Boctor * @@ -46,8 +46,14 @@ * id - separated by semicolon)</li> * <li>test.project.filters (filters of project with the given id - separated * by semicolon - the first filter should return at least one issue)</li> - * <li>test.project.customfields (optional - names of custom fields expected for - * issues - separated by semicolon)</li> + * <li>test.project.customfields (optional - names of custom fields expected + * for issues - separated by semicolon)</li> + * <li>test.project.customfield.name (optional - name of the custom field we + * want to submit with test issues)</li> + * <li>test.project.customfield.value (optional - value of the custom field we + * want to submit)</li> + * <li>test.project.customfield.format (optional - only needed if the custom + * field is a date field - leave empty otherwise)</li> * </ul> * </p> * @@ -854,5 +860,4 @@ assertTrue(result.length >= 1); } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 20:02:52
|
Revision: 61 http://svn.sourceforge.net/mantisconnect/?rev=61&view=rev Author: planser Date: 2006-10-17 13:02:40 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Added Paths: ----------- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/CheckboxCustomFieldFormatTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/DateCustomFieldFormatTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/ListCustomFieldFormatTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/StringCustomFieldFormatTest.java Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/CheckboxCustomFieldFormatTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/CheckboxCustomFieldFormatTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/CheckboxCustomFieldFormatTest.java 2006-10-17 20:02:40 UTC (rev 61) @@ -0,0 +1,55 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import java.math.BigInteger; + +import junit.framework.TestCase; + +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.service.CustomFieldDefinitionData; +import org.mantisbt.connect.service.ObjectRef; + +/** + * @author Peter Lanser, pl...@us... + */ +public class CheckboxCustomFieldFormatTest extends TestCase { + + private CustomFieldDefinitionData definition; + + public void setUp() { + definition = new CustomFieldDefinitionData(); + definition.setField(new ObjectRef(BigInteger.ONE, "ACheckboxField")); + definition.setType(BigInteger.valueOf(ISession.CF_TYPE_CHECKBOX)); + } + + public void testFormat() { + CheckboxCustomFieldFormat format = new CheckboxCustomFieldFormat(definition); + try { + assertEquals("false", format.format(Boolean.FALSE)); + assertEquals("true", format.format(Boolean.TRUE)); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + + public void testParse() { + CheckboxCustomFieldFormat format = new CheckboxCustomFieldFormat(definition); + try { + assertEquals(Boolean.FALSE, format.parse("false")); + assertEquals(Boolean.TRUE, format.parse("true")); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/DateCustomFieldFormatTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/DateCustomFieldFormatTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/DateCustomFieldFormatTest.java 2006-10-17 20:02:40 UTC (rev 61) @@ -0,0 +1,67 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import java.math.BigInteger; +import java.util.Calendar; +import java.util.GregorianCalendar; + +import junit.framework.TestCase; + +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.service.CustomFieldDefinitionData; +import org.mantisbt.connect.service.ObjectRef; + +/** + * @author Peter Lanser, pl...@us... + */ +public class DateCustomFieldFormatTest extends TestCase { + + private final static Calendar DATE = GregorianCalendar.getInstance(); + + static { + DATE.set(Calendar.YEAR, 2006); + DATE.set(Calendar.MONTH, 10); + DATE.set(Calendar.DAY_OF_MONTH, 16); + DATE.set(Calendar.HOUR_OF_DAY, 12); + DATE.set(Calendar.MINUTE, 0); + DATE.set(Calendar.SECOND, 0); + DATE.set(Calendar.MILLISECOND, 0); + } + + private CustomFieldDefinitionData definition; + + public void setUp() { + definition = new CustomFieldDefinitionData(); + definition.setField(new ObjectRef(BigInteger.ONE, "ADateField")); + definition.setType(BigInteger.valueOf(ISession.CF_TYPE_DATE)); + } + + public void testFormat() { + DateCustomFieldFormat format = new DateCustomFieldFormat(definition); + try { + assertEquals("1163674800", format.format(DATE.getTime())); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + + public void testParse() { + DateCustomFieldFormat format = new DateCustomFieldFormat(definition); + try { + assertEquals(DATE.getTime(), format.parse("1163674800")); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/ListCustomFieldFormatTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/ListCustomFieldFormatTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/ListCustomFieldFormatTest.java 2006-10-17 20:02:40 UTC (rev 61) @@ -0,0 +1,87 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import java.math.BigInteger; +import java.util.Arrays; + +import junit.framework.TestCase; + +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.service.CustomFieldDefinitionData; +import org.mantisbt.connect.service.ObjectRef; + +/** + * @author Peter Lanser, pl...@us... + */ +public class ListCustomFieldFormatTest extends TestCase { + + private CustomFieldDefinitionData definition; + + public void setUp() { + definition = new CustomFieldDefinitionData(); + definition.setField(new ObjectRef(BigInteger.ONE, "ACheckboxField")); + definition.setType(BigInteger.valueOf(ISession.CF_TYPE_LIST)); + } + + public void testFormat() { + ListCustomFieldFormat format = new ListCustomFieldFormat(definition); + definition.setType(BigInteger.valueOf(ISession.CF_TYPE_MULTILIST)); + try { + assertEquals("Value1", format.format(new String[] { "Value1" })); + assertEquals("Value1|Value2", format.format(new String[] { "Value1", "Value2" })); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + + public void testParse() { + ListCustomFieldFormat format = new ListCustomFieldFormat(definition); + try { + assertTrue(Arrays.deepEquals(new String[] { "Value1" }, (String[]) format.parse("Value1"))); + assertTrue(Arrays.deepEquals(new String[] { "Value1", "Value2" }, (String[]) format.parse("Value1|Value2"))); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + + public void testOnlyOneValueAllowed() { + ListCustomFieldFormat format = new ListCustomFieldFormat(definition); + definition.setType(BigInteger.valueOf(ISession.CF_TYPE_LIST)); + try { + format.format(new String[] { "Value1", "Value2" }); + fail("CustomFieldFormatException expected."); + } catch (CustomFieldFormatException e) { + // pass + } + definition.setType(BigInteger.valueOf(ISession.CF_TYPE_ENUM)); + try { + format.format(new String[] { "Value1", "Value2" }); + fail("CustomFieldFormatException expected."); + } catch (CustomFieldFormatException e) { + // pass + } + } + + public void testInvalidValue() { + ListCustomFieldFormat format = new ListCustomFieldFormat(definition); + definition.setPossible_values("Value2|Value3"); + definition.setType(BigInteger.valueOf(ISession.CF_TYPE_MULTILIST)); + try { + format.format(new String[] { "Value1", "Value2" }); + fail("CustomFieldFormatException expected."); + } catch (CustomFieldFormatException e) { + // pass + } + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/StringCustomFieldFormatTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/StringCustomFieldFormatTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/StringCustomFieldFormatTest.java 2006-10-17 20:02:40 UTC (rev 61) @@ -0,0 +1,97 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.text; + +import java.math.BigInteger; + +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.service.CustomFieldDefinitionData; +import org.mantisbt.connect.service.ObjectRef; + +import junit.framework.TestCase; + +/** + * @author Peter Lanser, pl...@us... + */ +public class StringCustomFieldFormatTest extends TestCase { + + private CustomFieldDefinitionData definition; + + public void setUp() { + definition = new CustomFieldDefinitionData(); + definition.setField(new ObjectRef(BigInteger.ONE, "AStringField")); + definition.setType(BigInteger.valueOf(ISession.CF_TYPE_STRING)); + } + + public void testFormat() { + StringCustomFieldFormat format = new StringCustomFieldFormat(definition); + try { + assertEquals("AA", format.format("AA")); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + + public void testParse() { + StringCustomFieldFormat format = new StringCustomFieldFormat(definition); + try { + assertEquals("AA", format.parse("AA")); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + + public void testFormatInvalidLength() { + definition.setLength_min(BigInteger.valueOf(2)); + definition.setLength_max(BigInteger.valueOf(3)); + StringCustomFieldFormat format = new StringCustomFieldFormat(definition); + try { + format.format("A"); + fail("CustomFieldFormatException expected."); + } catch (CustomFieldFormatException e) { + // pass + } + try { + format.format("AAAA"); + fail("CustomFieldFormatException expected."); + } catch (CustomFieldFormatException e) { + // pass + } + try { + format.format("AA"); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + try { + format.format("AAA"); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + + public void testFormatInvalidValue() { + definition.setPossible_values("A"); + StringCustomFieldFormat format = new StringCustomFieldFormat(definition); + try { + format.format("B"); + fail("CustomFieldFormatException expected."); + } catch (CustomFieldFormatException e) { + // pass + } + try { + format.format("A"); + } catch (CustomFieldFormatException e) { + fail("Unexpected CustomFieldFormatException occurred."); + } + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 20:02:19
|
Revision: 60 http://svn.sourceforge.net/mantisconnect/?rev=60&view=rev Author: planser Date: 2006-10-17 13:02:09 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Added Paths: ----------- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/IssueSubmitTaskTest.java mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/IssueSubmitTaskTest.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/IssueSubmitTaskTest.java (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/IssueSubmitTaskTest.java 2006-10-17 20:02:09 UTC (rev 60) @@ -0,0 +1,330 @@ +/* + * Copyright 2006 Peter Lanser + * + * MantisConnect is copyrighted to Victor Boctor + * + * This program is distributed under the terms and conditions of the GPL + * See LICENSE file for details. + * + * For commercial applications to link with or modify MantisConnect, they + * require the purchase of a MantisConnect commercial license. + */ +package org.mantisbt.connect.ant.taskdefs; + +import java.math.BigInteger; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.StringTokenizer; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.BuildFileTest; +import org.mantisbt.connect.ISession; +import org.mantisbt.connect.ISessionFactory; +import org.mantisbt.connect.JMTException; +import org.mantisbt.connect.SessionFactory; +import org.mantisbt.connect.service.IssueData; +import org.mantisbt.connect.service.ProjectData; + +/** + * @author Peter Lanser, pl...@us... + */ +public class IssueSubmitTaskTest extends BuildFileTest { + + private final static String TEST_SUMMARY = "Added by MantisConnect Ant Task (Summary)"; + + private final static String TEST_DESCRIPTION = "Added by MantisConnect Ant Task (Description)"; + + private ISession session; + + public IssueSubmitTaskTest(String name) { + super(name); + } + + public void setUp() { + configureProject("src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml"); + } + + public void testMandatory1() { + expectBuildException("testMandatory1", + "required arguments not specified"); + } + + public void testMandatory2() { + expectBuildException("testMandatory2", + "required arguments not specified"); + } + + public void testMandatory3() { + expectBuildException("testMandatory3", + "required arguments not specified"); + } + + public void testMandatory4() { + expectBuildException("testMandatory4", + "required arguments not specified"); + } + + public void testMandatory5() { + expectBuildException("testMandatory5", + "required arguments not specified"); + } + + public void testMandatory6() { + expectBuildException("testMandatory6", + "required arguments not specified"); + } + + public void testInvalidProxySettings1() { + expectBuildException("testInvalidProxySettings1", + "required argument (proxyPort) not specified"); + } + + public void testInvalidProxySettings2() { + expectBuildException("testInvalidProxySettings2", + "required argument (proxyHost) not specified"); + } + + public void testInvalidProxySettings3() { + expectBuildException("testInvalidProxySettings3", + "proxyPort argument must be of type integer"); + } + + public void testInvalidUrl() { + expectBuildException("testInvalidUrl", "url argument is invalid"); + } + + public void testValid1() { + try { + ProjectData projectData = getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.category", + getFirstProjectCategory()); + project.setProperty("test.summary", TEST_SUMMARY); + project.setProperty("test.description", TEST_DESCRIPTION); + executeTarget("testValid1"); + long id = getIdFromLogLine(getLog()); + try { + IssueData issue = session.getIssue(id); + assertEquals(projectData.getName(), issue.getProject() + .getName()); + assertEquals(getFirstProjectCategory(), issue.getCategory()); + assertEquals(TEST_SUMMARY, issue.getSummary()); + assertEquals(TEST_DESCRIPTION, issue.getDescription()); + } catch (JMTException e) { + fail(e.getMessage()); + } + deleteIssue(id); + } catch (BuildException e) { + fail(e.getMessage()); + } + } + + public void testValid2() { + try { + ProjectData projectData = getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.category", + getFirstProjectCategory()); + project.setProperty("test.summary", TEST_SUMMARY); + project.setProperty("test.description", TEST_DESCRIPTION); + project.setProperty("test.project.version", + getFirstProjectReleasedVersion()); + executeTarget("testValid2"); + long id = getIdFromLogLine(getLog()); + try { + IssueData issue = session.getIssue(id); + assertEquals(projectData.getName(), issue.getProject() + .getName()); + assertEquals(getFirstProjectCategory(), issue.getCategory()); + assertEquals(TEST_SUMMARY, issue.getSummary()); + assertEquals(TEST_DESCRIPTION, issue.getDescription()); + assertEquals(getFirstProjectReleasedVersion(), issue + .getVersion()); + assertEquals(IssueSubmitTask.REPRODUCIBILITY_SOMETIMES_NUM, + issue.getReproducibility().getId().longValue()); + assertEquals(IssueSubmitTask.SEVERITY_BLOCK_NUM, issue + .getSeverity().getId().longValue()); + assertEquals(IssueSubmitTask.PRIORITY_HIGH_NUM, issue + .getPriority().getId().longValue()); + assertEquals("AdditionalInfo", issue + .getAdditional_information()); + assertEquals("APlatform", issue.getPlatform()); + assertEquals("AnOs", issue.getOs()); + assertEquals("AnOsVersion", issue.getOs_build()); + assertEquals("AProductBuild", issue.getBuild()); + assertEquals("StepsToReproduce", issue.getSteps_to_reproduce()); + assertEquals(ISession.VS_PRIVATE, issue.getView_state().getId() + .longValue()); + } catch (JMTException e) { + fail(e.getMessage()); + } + deleteIssue(id); + } catch (BuildException e) { + fail(e.getMessage()); + } + } + + public void testValid3() { + try { + ProjectData projectData = getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.category", + getFirstProjectCategory()); + project.setProperty("test.summary", TEST_SUMMARY); + project.setProperty("test.description", TEST_DESCRIPTION); + executeTarget("testValid3"); + long id = getIdFromLogLine(getLog()); + try { + IssueData issue = session.getIssue(id); + assertEquals(projectData.getName(), issue.getProject() + .getName()); + assertEquals(getFirstProjectCategory(), issue.getCategory()); + assertEquals(TEST_SUMMARY, issue.getSummary()); + assertEquals(TEST_DESCRIPTION, issue.getDescription()); + assertEquals(IssueSubmitTask.REPRODUCIBILITY_ALWAYS_NUM, issue + .getReproducibility().getId().longValue()); + assertEquals(IssueSubmitTask.SEVERITY_CRASH_NUM, issue + .getSeverity().getId().longValue()); + assertEquals(IssueSubmitTask.PRIORITY_IMMEDIATE_NUM, issue + .getPriority().getId().longValue()); + } catch (JMTException e) { + fail(e.getMessage()); + } + deleteIssue(id); + } catch (BuildException e) { + fail(e.getMessage()); + } + } + + public void testValid4() { + try { + ProjectData projectData = getAccessibleProject(); + project.setProperty("test.project.name", projectData.getName()); + project.setProperty("test.project.category", + getFirstProjectCategory()); + project.setProperty("test.summary", TEST_SUMMARY); + project.setProperty("test.description", TEST_DESCRIPTION); + project.setProperty("test.project.customfield.name", + getCustomFieldName()); + project.setProperty("test.project.customfield.value", + getCustomFieldValue()); + project.setProperty("test.project.customfield.format", + getCustomFieldFormat()); + executeTarget("testValid4"); + long id = getIdFromLogLine(getLog()); + try { + IssueData issue = session.getIssue(id); + assertEquals(projectData.getName(), issue.getProject() + .getName()); + assertEquals(getFirstProjectCategory(), issue.getCategory()); + assertEquals(TEST_SUMMARY, issue.getSummary()); + assertEquals(TEST_DESCRIPTION, issue.getDescription()); + } catch (JMTException e) { + fail(e.getMessage()); + } + deleteIssue(id); + } catch (BuildException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + private void deleteIssue(long id) { + try { + getSession().deleteIssue(id); + } catch (JMTException e) { + } + } + + private long getIdFromLogLine(String log) { + try { + return Long.parseLong(log.substring(log.lastIndexOf(" ") + 1, log + .lastIndexOf(")"))); + } catch (Exception e) { + return -1; + } + } + + private URL getUrl() { + try { + return new URL(System.getProperty("test.url")); + } catch (MalformedURLException e) { + return null; + } + } + + private String getUser() { + return System.getProperty("test.user"); + } + + private String getPassword() { + return System.getProperty("test.password"); + } + + private BigInteger getAccessibleProjectId() { + return BigInteger.valueOf(Long.parseLong(System + .getProperty("test.project.id"))); + } + + private ISession getSession() { + if (session == null) { + try { + ISessionFactory factory = SessionFactory.getInstance(); + String proxyHost = System.getProperty("test.http.proxyHost"); + String proxyPort = System.getProperty("test.http.proxyPort"); + if (!isEmpty(proxyHost) && !isEmpty(proxyPort)) { + factory.setProxy(proxyHost, Integer.parseInt(proxyPort)); + } + session = factory + .newSession(getUrl(), getUser(), getPassword()); + } catch (JMTException e) { + session = null; + } + } + return session; + } + + private boolean isEmpty(String string) { + return string == null || string.trim().length() == 0; + } + + private ProjectData getAccessibleProject() { + try { + ProjectData[] projects = getSession().getAccessibleProjects(); + if (projects != null) { + for (int i = 0; i < projects.length; i++) { + if (projects[i].getId().equals(getAccessibleProjectId())) { + return projects[i]; + } + } + } + } catch (JMTException e) { + return null; + } + return null; + } + + private String getFirstProjectCategory() { + return new StringTokenizer(System + .getProperty("test.project.categories"), ";").nextToken(); + } + + private String getFirstProjectReleasedVersion() { + return new StringTokenizer(System + .getProperty("test.project.versions.released"), ";") + .nextToken(); + } + + private String getCustomFieldName() { + return System.getProperty("test.project.customfield.name"); + } + + private String getCustomFieldValue() { + return System.getProperty("test.project.customfield.value"); + } + + private String getCustomFieldFormat() { + return System.getProperty("test.project.customfield.format"); + } + +} Added: mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml (rev 0) +++ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/issuesubmit.xml 2006-10-17 20:02:09 UTC (rev 60) @@ -0,0 +1,106 @@ +<?xml version="1.0"?> + +<project name="issuesubmit-test"> + + <taskdef name="submit" classname="org.mantisbt.connect.ant.taskdefs.IssueSubmitTask"/> + + <target name="testMandatory1"> + <submit/> + </target> + + <target name="testMandatory2"> + <submit url="http://localhost/"/> + </target> + + <target name="testMandatory3"> + <submit url="http://localhost/" username="AUsername"/> + </target> + + <target name="testMandatory4"> + <submit url="http://localhost/" username="AUsername" password="APassword"/> + </target> + + <target name="testMandatory5"> + <submit url="http://localhost/" username="AUsername" password="APassword" + project="AProject"/> + </target> + + <target name="testMandatory6"> + <submit url="http://localhost/" username="AUsername" password="APassword" + project="AProject" summary="ASummary"/> + </target> + + <target name="testInvalidProxySettings1"> + <submit proxyHost="AProxyHost" + url="http://localhost/" username="AUsername" password="APassword" + project="AProject" summary="ASummary" description="ADescription"/> + </target> + + <target name="testInvalidProxySettings2"> + <submit proxyPort="8080" + url="http://localhost/" username="AUsername" password="APassword" + project="AProject" summary="ASummary" description="ADescription"/> + </target> + + <target name="testInvalidProxySettings3"> + <submit proxyHost="AProxyHost" proxyPort="APort" + url="http://localhost/" username="AUsername" password="APassword" + project="AProject" summary="ASummary" description="ADescription"/> + </target> + + <target name="testInvalidUrl"> + <submit url="AnInvalidUrl" username="AUsername" password="APassword" + project="AProject" summary="ASummary" description="ADescription"/> + </target> + + <target name="testValid1"> + <submit url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + category="${test.project.category}" + summary="${test.summary}" + description="${test.description}"/> + </target> + + <target name="testValid2"> + <submit url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + category="${test.project.category}" + summary="${test.summary}" + description="${test.description}" + version="${test.project.version}" + reproducibility="sometimes" + severity="block" + priority="high" + additionalInfo="AdditionalInfo" + platform="APlatform" + os="AnOs" + osVersion="AnOsVersion" + productBuild="AProductBuild" + stepsToReproduce="StepsToReproduce" + private="true" + /> + </target> + + <target name="testValid3"> + <submit url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + category="${test.project.category}" + summary="${test.summary}" + description="${test.description}" + reproducibility="10" + severity="70" + priority="60" + /> + </target> + + <target name="testValid4"> + <submit url="${test.url}" username="${test.user}" password="${test.password}" + project="${test.project.name}" + category="${test.project.category}" + summary="${test.summary}" + description="${test.description}"> + <customfield name="${test.project.customfield.name}" value="${test.project.customfield.value}" format="${test.project.customfield.format}"/> + </submit> + </target> + +</project> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 19:25:42
|
Revision: 59 http://svn.sourceforge.net/mantisconnect/?rev=59&view=rev Author: planser Date: 2006-10-17 12:25:35 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Modified Paths: -------------- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ISession.java Modified: mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ISession.java =================================================================== --- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ISession.java 2006-10-17 19:18:13 UTC (rev 58) +++ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ISession.java 2006-10-17 19:25:35 UTC (rev 59) @@ -31,22 +31,40 @@ public final static int VS_PRIVATE = 50; - public final static int ANYBODY = 0; + public final static int AL_ANYBODY = 0; - public final static int VIEWER = 10; + public final static int AL_VIEWER = 10; - public final static int REPORTER = 25; + public final static int AL_REPORTER = 25; - public final static int UPDATER = 40; + public final static int AL_UPDATER = 40; - public final static int DEVELOPER = 55; + public final static int AL_DEVELOPER = 55; - public final static int MANAGER = 70; + public final static int AL_MANAGER = 70; - public final static int ADMINISTRATOR = 90; + public final static int AL_ADMINISTRATOR = 90; - public final static int NOBODY = 100; + public final static int AL_NOBODY = 100; + + public final static int CF_TYPE_STRING = 0; + public final static int CF_TYPE_NUMERIC = 1; + + public final static int CF_TYPE_FLOAT = 2; + + public final static int CF_TYPE_ENUM = 3; + + public final static int CF_TYPE_EMAIL = 4; + + public final static int CF_TYPE_CHECKBOX = 5; + + public final static int CF_TYPE_LIST = 6; + + public final static int CF_TYPE_MULTILIST = 7; + + public final static int CF_TYPE_DATE = 8; + /** * Flush cached information */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 19:18:47
|
Revision: 58 http://svn.sourceforge.net/mantisconnect/?rev=58&view=rev Author: planser Date: 2006-10-17 12:18:13 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Added Paths: ----------- mantisconnect/trunk/clients/java/client-api/lib/ant-launcher.jar mantisconnect/trunk/clients/java/client-api/lib/ant-testutil.jar mantisconnect/trunk/clients/java/client-api/lib/ant.jar Added: mantisconnect/trunk/clients/java/client-api/lib/ant-launcher.jar =================================================================== (Binary files differ) Property changes on: mantisconnect/trunk/clients/java/client-api/lib/ant-launcher.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: mantisconnect/trunk/clients/java/client-api/lib/ant-testutil.jar =================================================================== (Binary files differ) Property changes on: mantisconnect/trunk/clients/java/client-api/lib/ant-testutil.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: mantisconnect/trunk/clients/java/client-api/lib/ant.jar =================================================================== (Binary files differ) Property changes on: mantisconnect/trunk/clients/java/client-api/lib/ant.jar ___________________________________________________________________ Name: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-17 19:16:16
|
Revision: 57 http://svn.sourceforge.net/mantisconnect/?rev=57&view=rev Author: planser Date: 2006-10-17 12:15:21 -0700 (Tue, 17 Oct 2006) Log Message: ----------- Added Ant support (submitting issues) Added Paths: ----------- mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/ant/taskdefs/ mantisconnect/trunk/clients/java/client-api/src/main/org/mantisbt/connect/text/ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/ant/taskdefs/ mantisconnect/trunk/clients/java/client-api/src/test/org/mantisbt/connect/text/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-14 18:11:57
|
Revision: 56 http://svn.sourceforge.net/mantisconnect/?rev=56&view=rev Author: planser Date: 2006-10-14 11:11:48 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Removed workardound for i18n issue (resolved by #269: I18n of enum strings) Modified Paths: -------------- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/DetailSection.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/IssuePart.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/MainAttributesSection.java Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/DetailSection.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/DetailSection.java 2006-10-14 18:04:33 UTC (rev 55) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/DetailSection.java 2006-10-14 18:11:48 UTC (rev 56) @@ -99,18 +99,17 @@ } public void refresh() { - projection.setText(getIssue().getProjection() != null ? getNameFromObjectRef( - Enumeration.PROJECTIONS, getIssue().getProjection()) : ""); - eta.setText(getIssue().getEta() != null ? getNameFromObjectRef(Enumeration.ETAS, getIssue() - .getEta()) : ""); + projection.setText(getIssue().getProjection() != null ? getIssue().getProjection() + .getName() : ""); + eta.setText(getIssue().getEta() != null ? getIssue().getEta().getName() : ""); fixedInVersion.setText(getIssue().getFixed_in_version() != null ? getIssue() .getFixed_in_version() : ""); platform.setText(getIssue().getPlatform() != null ? getIssue().getPlatform() : ""); os.setText(getIssue().getOs() != null ? getIssue().getOs() : ""); osVersion.setText(getIssue().getOs_build() != null ? getIssue().getOs_build() : ""); productBuild.setText(getIssue().getBuild() != null ? getIssue().getBuild() : ""); - viewState.setText(getIssue().getView_state() != null ? getNameFromObjectRef( - Enumeration.VIEW_STATES, getIssue().getView_state()) : ""); + viewState.setText(getIssue().getView_state() != null ? getIssue().getView_state().getName() + : ""); super.refresh(); } Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/IssuePart.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/IssuePart.java 2006-10-14 18:04:33 UTC (rev 55) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/IssuePart.java 2006-10-14 18:11:48 UTC (rev 56) @@ -187,6 +187,8 @@ * Names of Enums are serviced in english language by the MantisConnect WebService. * ObjectRefs of issues may contain translated texts. * This method can be used to get the native name of a translated ObjectRef. + * + * @deprecated Resolved by Issue #269 */ protected String getNameFromObjectRef(Enumeration enumName, ObjectRef objectRef) { ObjectRef[] objectRefs; Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/MainAttributesSection.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/MainAttributesSection.java 2006-10-14 18:04:33 UTC (rev 55) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/editors/MainAttributesSection.java 2006-10-14 18:11:48 UTC (rev 56) @@ -192,17 +192,16 @@ } public void refresh() { - severity.setText(getIssue().getSeverity() != null ? getNameFromObjectRef(Enumeration.SEVERITIES, - getIssue().getSeverity()) : ""); + severity + .setText(getIssue().getSeverity() != null ? getIssue().getSeverity().getName() : ""); category.setText(getIssue().getCategory() != null ? getIssue().getCategory() : ""); - reproducibility.setText(getIssue().getReproducibility() != null ? getNameFromObjectRef( - Enumeration.REPRODUCIBILITIES, getIssue().getReproducibility()) : ""); - priority.setText(getIssue().getPriority() != null ? getNameFromObjectRef(Enumeration.PRIORITIES, - getIssue().getPriority()) : ""); - status.setText(getIssue().getStatus() != null ? getNameFromObjectRef(Enumeration.STATUS, - getIssue().getStatus()) : ""); - resolution.setText(getIssue().getResolution() != null ? getNameFromObjectRef( - Enumeration.RESOLUTIONS, getIssue().getResolution()) : ""); + reproducibility.setText(getIssue().getReproducibility() != null ? getIssue() + .getReproducibility().getName() : ""); + priority + .setText(getIssue().getPriority() != null ? getIssue().getPriority().getName() : ""); + status.setText(getIssue().getStatus() != null ? getIssue().getStatus().getName() : ""); + resolution.setText(getIssue().getResolution() != null ? getIssue().getResolution() + .getName() : ""); if (getIssue().getReporter() != null) { reporter.setSelection(new StructuredSelection(getIssue().getReporter())); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-10-14 18:04:50
|
Revision: 55 http://svn.sourceforge.net/mantisconnect/?rev=55&view=rev Author: planser Date: 2006-10-14 11:04:33 -0700 (Sat, 14 Oct 2006) Log Message: ----------- Fixed #269: I18n of enum strings Modified Paths: -------------- mantisconnect/trunk/webservice/mc/mc_api.php mantisconnect/trunk/webservice/mc/mc_enum_api.php mantisconnect/trunk/webservice/mc/mc_filter_api.php mantisconnect/trunk/webservice/mc/mc_issue_api.php mantisconnect/trunk/webservice/mc/mc_project_api.php Modified: mantisconnect/trunk/webservice/mc/mc_api.php =================================================================== --- mantisconnect/trunk/webservice/mc/mc_api.php 2006-09-19 10:38:08 UTC (rev 54) +++ mantisconnect/trunk/webservice/mc/mc_api.php 2006-10-14 18:04:33 UTC (rev 55) @@ -120,6 +120,15 @@ return $t_user_id; } + # -------------------- + function mci_get_user_lang( $p_user_id ) { + $t_lang = user_pref_get_pref( $p_user_id, 'language' ); + if ( $t_lang == 'auto' ) { + $t_lang = config_get( 'fallback_language' ); + } + return $t_lang; + } + # -------------------- function mci_get_status_id( $p_status ) { return mci_get_enum_id_from_objectref( 'status', $p_status ); @@ -191,4 +200,24 @@ return $t_path; } + + # -------------------- + # Given a enum string and num, return the appropriate localized string + function mci_get_enum_element( $p_enum_name, $p_val, $p_lang ) { + $config_var = config_get( $p_enum_name.'_enum_string' ); + $string_var = lang_get( $p_enum_name.'_enum_string', $p_lang ); + + # use the global enum string to search + $t_arr = explode_enum_string( $config_var ); + $t_arr_count = count( $t_arr ); + for ( $i=0; $i < $t_arr_count ;$i++ ) { + $elem_arr = explode_enum_arr( $t_arr[$i] ); + if ( $elem_arr[0] == $p_val ) { + # now get the appropriate translation + return get_enum_to_string( $string_var, $p_val ); + } + } + return '@' . $p_val . '@'; + } + ?> \ No newline at end of file Modified: mantisconnect/trunk/webservice/mc/mc_enum_api.php =================================================================== --- mantisconnect/trunk/webservice/mc/mc_enum_api.php 2006-09-19 10:38:08 UTC (rev 54) +++ mantisconnect/trunk/webservice/mc/mc_enum_api.php 2006-10-14 18:04:33 UTC (rev 55) @@ -159,7 +159,8 @@ if ( !mci_has_readonly_access( $t_user_id ) ) { return new soap_fault( 'Client', '', 'Access Denied' ); } - return config_get( $p_enumeration . '_enum_string' ); + $t_lang = mci_get_user_lang( $t_user_id ); + return lang_get( $p_enumeration . '_enum_string', $t_lang ); } /** @@ -184,16 +185,17 @@ } /** - * Get an enumeration element. + * Get a localized enumeration element. * * @param integer $p_enum_id The id of the enumeration element to retrieve. * @param String $p_enum_type The type of the enumeration element (e.g. 'status', 'reproducibility' etc.). + * @param String $p_lang The language for the name field. * @return Array an Array containing the id and the name of the enumeration element. */ - function mci_enum_get_array_by_id( $p_enum_id, $p_enum_type ) { + function mci_enum_get_array_by_id( $p_enum_id, $p_enum_type, $p_lang ) { $t_result = array(); $t_result['id'] = $p_enum_id; - $t_result['name'] = get_enum_element( $p_enum_type, $p_enum_id ); + $t_result['name'] = mci_get_enum_element( $p_enum_type, $p_enum_id, $p_lang ); return $t_result; } Modified: mantisconnect/trunk/webservice/mc/mc_filter_api.php =================================================================== --- mantisconnect/trunk/webservice/mc/mc_filter_api.php 2006-09-19 10:38:08 UTC (rev 54) +++ mantisconnect/trunk/webservice/mc/mc_filter_api.php 2006-10-14 18:04:33 UTC (rev 55) @@ -53,6 +53,7 @@ */ function mc_filter_get_issues( $p_username, $p_password, $p_project_id, $p_filter_id, $p_page_number, $p_per_page ) { $t_user_id = mci_check_login( $p_username, $p_password ); + $t_lang = mci_get_user_lang( $t_user_id ); if ( $t_user_id === false ) { return new soap_fault( 'Client', '', 'Access Denied' ); } @@ -77,14 +78,14 @@ $t_issue = array(); $t_issue['id'] = $t_id; - $t_issue['view_state'] = mci_enum_get_array_by_id( $t_issue_data['view_state'], 'view_state'); + $t_issue['view_state'] = mci_enum_get_array_by_id( $t_issue_data['view_state'], 'view_state', $t_lang); $t_issue['last_updated'] = timestamp_to_iso8601( $t_issue_data['last_updated'] ); $t_issue['project'] = mci_project_as_array_by_id( $t_issue_data['project_id'] ); $t_issue['category'] = mci_null_if_empty( $t_issue_data['category'] ); - $t_issue['priority'] = mci_enum_get_array_by_id( $t_issue_data['priority'], 'priority' ); - $t_issue['severity'] = mci_enum_get_array_by_id( $t_issue_data['severity'], 'severity' ); - $t_issue['status'] = mci_enum_get_array_by_id( $t_issue_data['status'], 'status' ); + $t_issue['priority'] = mci_enum_get_array_by_id( $t_issue_data['priority'], 'priority', $t_lang ); + $t_issue['severity'] = mci_enum_get_array_by_id( $t_issue_data['severity'], 'severity', $t_lang ); + $t_issue['status'] = mci_enum_get_array_by_id( $t_issue_data['status'], 'status', $t_lang ); $t_issue['reporter'] = mci_account_get_array_by_id( $t_issue_data['reporter_id'] ); $t_issue['summary'] = $t_issue_data['summary']; @@ -93,17 +94,17 @@ $t_issue['platform'] = mci_null_if_empty( $t_issue_data['platform'] ); $t_issue['os'] = mci_null_if_empty( $t_issue_data['os'] ); $t_issue['os_build'] = mci_null_if_empty( $t_issue_data['os_build'] ); - $t_issue['reproducibility'] = mci_enum_get_array_by_id( $t_issue_data['reproducibility'], 'reproducibility' ); + $t_issue['reproducibility'] = mci_enum_get_array_by_id( $t_issue_data['reproducibility'], 'reproducibility', $t_lang ); $t_issue['date_submitted'] = timestamp_to_iso8601( $t_issue_data['date_submitted'] ); $t_issue['sponsorship_total'] = $t_issue_data['sponsorship_total']; if( !empty( $t_issue_data['handler_id'] ) ) { $t_issue['handler'] = mci_account_get_array_by_id( $t_issue_data['handler_id'] ); } - $t_issue['projection'] = mci_enum_get_array_by_id( $t_issue_data['projection'], 'projection' ); - $t_issue['eta'] = mci_enum_get_array_by_id( $t_issue_data['eta'], 'eta' ); + $t_issue['projection'] = mci_enum_get_array_by_id( $t_issue_data['projection'], 'projection', $t_lang ); + $t_issue['eta'] = mci_enum_get_array_by_id( $t_issue_data['eta'], 'eta', $t_lang ); - $t_issue['resolution'] = mci_enum_get_array_by_id( $t_issue_data['resolution'], 'resolution' ); + $t_issue['resolution'] = mci_enum_get_array_by_id( $t_issue_data['resolution'], 'resolution', $t_lang ); $t_issue['fixed_in_version'] = mci_null_if_empty( $t_issue_data['fixed_in_version'] ); $t_issue['description'] = bug_get_text_field( $t_id, 'description' ); Modified: mantisconnect/trunk/webservice/mc/mc_issue_api.php =================================================================== --- mantisconnect/trunk/webservice/mc/mc_issue_api.php 2006-09-19 10:38:08 UTC (rev 54) +++ mantisconnect/trunk/webservice/mc/mc_issue_api.php 2006-10-14 18:04:33 UTC (rev 55) @@ -49,6 +49,7 @@ */ function mc_issue_get( $p_username, $p_password, $p_issue_id ) { $t_user_id = mci_check_login( $p_username, $p_password ); + $t_lang = mci_get_user_lang( $t_user_id ); if ( $t_user_id === false ) { return new soap_fault( 'Client', '', 'Access Denied' ); } @@ -66,14 +67,14 @@ $t_issue_data = array(); $t_issue_data['id'] = $p_issue_id; - $t_issue_data['view_state'] = mci_enum_get_array_by_id( $t_bug['view_state'], 'view_state' ); + $t_issue_data['view_state'] = mci_enum_get_array_by_id( $t_bug['view_state'], 'view_state', $t_lang ); $t_issue_data['last_updated'] = timestamp_to_iso8601( $t_bug['last_updated'] ); $t_issue_data['project'] = mci_project_as_array_by_id( $t_bug['project_id'] ); $t_issue_data['category'] = mci_null_if_empty( $t_bug['category'] ); - $t_issue_data['priority'] = mci_enum_get_array_by_id( $t_bug['priority'], 'priority' ); - $t_issue_data['severity'] = mci_enum_get_array_by_id( $t_bug['severity'], 'severity' ); - $t_issue_data['status'] = mci_enum_get_array_by_id( $t_bug['status'], 'status' ); + $t_issue_data['priority'] = mci_enum_get_array_by_id( $t_bug['priority'], 'priority', $t_lang ); + $t_issue_data['severity'] = mci_enum_get_array_by_id( $t_bug['severity'], 'severity', $t_lang ); + $t_issue_data['status'] = mci_enum_get_array_by_id( $t_bug['status'], 'status', $t_lang ); $t_issue_data['reporter'] = mci_account_get_array_by_id( $t_bug['reporter_id'] ); $t_issue_data['summary'] = $t_bug['summary']; @@ -82,7 +83,7 @@ $t_issue_data['platform'] = mci_null_if_empty( $t_bug['platform'] ); $t_issue_data['os'] = mci_null_if_empty( $t_bug['os'] ); $t_issue_data['os_build'] = mci_null_if_empty( $t_bug['os_build'] ); - $t_issue_data['reproducibility'] = mci_enum_get_array_by_id( $t_bug['reproducibility'], 'reproducibility' ); + $t_issue_data['reproducibility'] = mci_enum_get_array_by_id( $t_bug['reproducibility'], 'reproducibility', $t_lang ); $t_issue_data['date_submitted'] = timestamp_to_iso8601( $t_bug['date_submitted'] ); $t_issue_data['sponsorship_total'] = $t_bug['sponsorship_total']; @@ -90,10 +91,10 @@ if( !empty( $t_bug['handler_id'] ) ) { $t_issue_data['handler'] = mci_account_get_array_by_id( $t_bug['handler_id'] ); } - $t_issue_data['projection'] = mci_enum_get_array_by_id( $t_bug['projection'], 'projection' ); - $t_issue_data['eta'] = mci_enum_get_array_by_id( $t_bug['eta'], 'eta' ); + $t_issue_data['projection'] = mci_enum_get_array_by_id( $t_bug['projection'], 'projection', $t_lang ); + $t_issue_data['eta'] = mci_enum_get_array_by_id( $t_bug['eta'], 'eta', $t_lang ); - $t_issue_data['resolution'] = mci_enum_get_array_by_id( $t_bug['resolution'], 'resolution' ); + $t_issue_data['resolution'] = mci_enum_get_array_by_id( $t_bug['resolution'], 'resolution', $t_lang ); $t_issue_data['fixed_in_version'] = mci_null_if_empty( $t_bug['fixed_in_version'] ); $t_issue_data['description'] = $t_bug['description']; @@ -246,6 +247,7 @@ */ function mci_issue_get_notes( $p_issue_id ) { $t_user_id = auth_get_current_user_id(); + $t_lang = mci_get_user_lang( $t_user_id ); $t_project_id = bug_get_field( $p_issue_id, 'project_id' ); $t_user_access_level = user_get_access_level( $t_user_id, $t_project_id ); $t_user_bugnote_order = 'ASC'; // always get the notes in ascending order for consistency to the calling application. @@ -258,7 +260,7 @@ $t_bugnote['date_submitted'] = timestamp_to_iso8601( $t_value->date_submitted ); $t_bugnote['last_modified'] = timestamp_to_iso8601( $t_value->last_modified ); $t_bugnote['text'] = $t_value->note; - $t_bugnote['view_state'] = mci_enum_get_array_by_id( $t_value->view_state, 'view_state' ); + $t_bugnote['view_state'] = mci_enum_get_array_by_id( $t_value->view_state, 'view_state', $t_lang ); $t_result[] = $t_bugnote; } Modified: mantisconnect/trunk/webservice/mc/mc_project_api.php =================================================================== --- mantisconnect/trunk/webservice/mc/mc_project_api.php 2006-09-19 10:38:08 UTC (rev 54) +++ mantisconnect/trunk/webservice/mc/mc_project_api.php 2006-10-14 18:04:33 UTC (rev 55) @@ -12,6 +12,7 @@ function mc_project_get_issues( $p_username, $p_password, $p_project_id , $p_page_number, $p_per_page ) { $t_user_id = mci_check_login( $p_username, $p_password ); + $t_lang = mci_get_user_lang( $t_user_id ); if ( $t_user_id === false ) { return new soap_fault( 'Client', '', 'Access Denied' ); } @@ -34,14 +35,14 @@ $t_issue = array(); $t_issue['id'] = $t_id; - $t_issue['view_state'] = mci_enum_get_array_by_id( $t_issue_data['view_state'], 'view_state'); + $t_issue['view_state'] = mci_enum_get_array_by_id( $t_issue_data['view_state'], 'view_state', $t_lang ); $t_issue['last_updated'] = timestamp_to_iso8601( $t_issue_data['last_updated'] ); $t_issue['project'] = mci_project_as_array_by_id( $t_issue_data['project_id'] ); $t_issue['category'] = mci_null_if_empty( $t_issue_data['category'] ); - $t_issue['priority'] = mci_enum_get_array_by_id( $t_issue_data['priority'], 'priority' ); - $t_issue['severity'] = mci_enum_get_array_by_id( $t_issue_data['severity'], 'severity' ); - $t_issue['status'] = mci_enum_get_array_by_id( $t_issue_data['status'], 'status' ); + $t_issue['priority'] = mci_enum_get_array_by_id( $t_issue_data['priority'], 'priority', $t_lang ); + $t_issue['severity'] = mci_enum_get_array_by_id( $t_issue_data['severity'], 'severity', $t_lang ); + $t_issue['status'] = mci_enum_get_array_by_id( $t_issue_data['status'], 'status', $t_lang ); $t_issue['reporter'] = mci_account_get_array_by_id( $t_issue_data['reporter_id'] ); $t_issue['summary'] = $t_issue_data['summary']; @@ -50,17 +51,17 @@ $t_issue['platform'] = mci_null_if_empty( $t_issue_data['platform'] ); $t_issue['os'] = mci_null_if_empty( $t_issue_data['os'] ); $t_issue['os_build'] = mci_null_if_empty( $t_issue_data['os_build'] ); - $t_issue['reproducibility'] = mci_enum_get_array_by_id( $t_issue_data['reproducibility'], 'reproducibility' ); + $t_issue['reproducibility'] = mci_enum_get_array_by_id( $t_issue_data['reproducibility'], 'reproducibility', $t_lang ); $t_issue['date_submitted'] = timestamp_to_iso8601( $t_issue_data['date_submitted'] ); $t_issue['sponsorship_total'] = $t_issue_data['sponsorship_total']; if( !empty( $t_issue_data['handler_id'] ) ) { $t_issue['handler'] = mci_account_get_array_by_id( $t_issue_data['handler_id'] ); } - $t_issue['projection'] = mci_enum_get_array_by_id( $t_issue_data['projection'], 'projection' ); - $t_issue['eta'] = mci_enum_get_array_by_id( $t_issue_data['eta'], 'eta' ); + $t_issue['projection'] = mci_enum_get_array_by_id( $t_issue_data['projection'], 'projection', $t_lang ); + $t_issue['eta'] = mci_enum_get_array_by_id( $t_issue_data['eta'], 'eta', $t_lang ); - $t_issue['resolution'] = mci_enum_get_array_by_id( $t_issue_data['resolution'], 'resolution' ); + $t_issue['resolution'] = mci_enum_get_array_by_id( $t_issue_data['resolution'], 'resolution', $t_lang ); $t_issue['fixed_in_version'] = mci_null_if_empty( $t_issue_data['fixed_in_version'] ); $t_issue['description'] = bug_get_text_field( $t_id, 'description' ); @@ -88,6 +89,7 @@ */ function mc_projects_get_user_accessible( $p_username, $p_password ) { $t_user_id = mci_check_login( $p_username, $p_password ); + $t_lang = mci_get_user_lang( $t_user_id ); if ( $t_user_id === false ) { return new soap_fault( 'Client', '', 'Access Denied' ); } @@ -102,10 +104,10 @@ $t_project = array(); $t_project['id'] = $t_project_id; $t_project['name'] = $t_project_row['name']; - $t_project['status'] = mci_enum_get_array_by_id( $t_project_row['status'], 'project_status' ); + $t_project['status'] = mci_enum_get_array_by_id( $t_project_row['status'], 'project_status', $t_lang ); $t_project['enabled'] = $t_project_row['enabled']; - $t_project['view_state'] = mci_enum_get_array_by_id( $t_project_row['view_state'], 'project_view_state' ); - $t_project['access_min'] = mci_enum_get_array_by_id( $t_project_row['access_min'], 'access_levels' ); + $t_project['view_state'] = mci_enum_get_array_by_id( $t_project_row['view_state'], 'project_view_state', $t_lang ); + $t_project['access_min'] = mci_enum_get_array_by_id( $t_project_row['access_min'], 'access_levels', $t_lang ); $t_project['file_path'] = array_key_exists( 'file_path', $t_project_row ) ? $t_project_row['file_path'] : ""; $t_project['description'] = This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 54 http://svn.sourceforge.net/mantisconnect/?rev=54&view=rev Author: planser Date: 2006-09-19 03:38:08 -0700 (Tue, 19 Sep 2006) Log Message: ----------- Made support for browser page more generic Added Paths: ----------- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/BrowserUrlVariableDialog.java Added: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/BrowserUrlVariableDialog.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/BrowserUrlVariableDialog.java (rev 0) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/BrowserUrlVariableDialog.java 2006-09-19 10:38:08 UTC (rev 54) @@ -0,0 +1,88 @@ +package org.mantisbt.connect.eclipse.dialogs; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.dialogs.StatusDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseAdapter; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.List; +import org.eclipse.swt.widgets.Shell; +import org.mantisbt.connect.eclipse.ConnectionSettings; +import org.mantisbt.connect.eclipse.MantisConnectPlugin; +import org.mantisbt.connect.eclipse.StatusInfo; +import org.mantisbt.connect.eclipse.ConnectionSettings.BrowserUrlVariable; + +public class BrowserUrlVariableDialog extends StatusDialog { + + private List list; + + private ConnectionSettings.BrowserUrlVariable variable; + + public BrowserUrlVariableDialog(Shell parent) { + super(parent); + } + + @Override + protected void configureShell(Shell shell) { + super.configureShell(shell); + shell.setText("Variables"); + shell.setImage(MantisConnectPlugin.getDefault().getImageRegistry().get( + MantisConnectPlugin.IMG_MANTIS_16)); + } + + @Override + protected Control createDialogArea(Composite parent) { + Composite composite = (Composite) super.createDialogArea(parent); + list = new List(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE); + list.setLayoutData(new GridData(GridData.FILL_BOTH)); + BrowserUrlVariable[] variables = ConnectionSettings.BrowserUrlVariable.values(); + for (int i = 0; i < variables.length; i++) { + list.add(variables[i].toString()); + } + list.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + validate(); + } + }); + list.addMouseListener(new MouseAdapter() { + @Override + public void mouseDoubleClick(MouseEvent e) { + okPressed(); + } + }); + validate(); + return composite; + } + + private void validate() { + if (list.getSelectionCount() > 0) { + updateStatus(StatusInfo.OK); + } else { + updateStatus(new StatusInfo(IStatus.ERROR, "No item selected.")); + } + } + + @Override + protected void okPressed() { + if (list.getSelectionCount() > 0) { + String selection = list.getSelection()[0]; + variable = ConnectionSettings.BrowserUrlVariable.fromVariableString(selection); + } else { + variable = null; + } + super.okPressed(); + } + + public ConnectionSettings.BrowserUrlVariable getVariable() { + return variable; + } + + + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <pl...@us...> - 2006-09-19 10:37:51
|
Revision: 53 http://svn.sourceforge.net/mantisconnect/?rev=53&view=rev Author: planser Date: 2006-09-19 03:37:42 -0700 (Tue, 19 Sep 2006) Log Message: ----------- Made support for browser page more generic Modified Paths: -------------- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ConnectionSettings.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ConnectionSettingsRegistry.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/MantisConnectPlugin.java mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/ConnectionSettingsDialog.java Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ConnectionSettings.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ConnectionSettings.java 2006-09-19 10:37:08 UTC (rev 52) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ConnectionSettings.java 2006-09-19 10:37:42 UTC (rev 53) @@ -22,18 +22,51 @@ import org.mantisbt.connect.eclipse.dialogs.LoginDialog; import org.mantisbt.connect.service.IssueData; import org.mantisbt.connect.service.IssueHeaderData; +import org.mantisbt.connect.service.ObjectRef; +import org.mantisbt.connect.service.ProjectData; /** * @author Peter Lanser, pl...@us... */ public class ConnectionSettings implements Cloneable { + + public enum BrowserUrlVariable { + + ISSUE_ID, PROJECT_ID, PROJECT_NAME; + + public static BrowserUrlVariable fromVariableString(String string) { + if (string.equals("${issue_id}")) { + return ISSUE_ID; + } else if (string.equals("${project_id}")) { + return PROJECT_ID; + } else if (string.equals("${project_name}")) { + return PROJECT_NAME; + } else { + return null; + } + } + + public String toString() { + switch (this) { + case ISSUE_ID: + return "${issue_id}"; + case PROJECT_ID: + return "${project_id}"; + case PROJECT_NAME: + return "${project_name}"; + default: + return ""; + } + } + + } private String name; private URL mantisConnectUrl; - private URL mantisUrl; + private URL browserUrl; private String user; @@ -53,11 +86,11 @@ this(name, mantisConnectUrl, null, null, null, false, -1, new HashMap<Integer, Integer>()); } - public ConnectionSettings(String name, URL mantisConnectUrl, URL mantisUrl, String user, + public ConnectionSettings(String name, URL mantisConnectUrl, URL browserUrl, String user, String password, boolean savePassword, int lastProjectId, Map<Integer, Integer> filters) { this.name = name; this.mantisConnectUrl = mantisConnectUrl; - this.mantisUrl = mantisUrl; + this.browserUrl = browserUrl; this.user = user; this.password = password; this.savePassword = savePassword; @@ -77,8 +110,8 @@ return mantisConnectUrl; } - public URL getMantisUrl() { - return mantisUrl; + public URL getBrowserUrl() { + return browserUrl; } public String getUser() { @@ -114,8 +147,8 @@ mantisConnectUrl = string; } - public void setMantisUrl(URL string) { - mantisUrl = string; + public void setBrowserUrl(URL string) { + browserUrl = string; } public void setUser(String string) { @@ -200,36 +233,49 @@ } public Object clone() { - return new ConnectionSettings(getName(), getMantisConnectUrl(), getMantisUrl(), getUser(), + return new ConnectionSettings(getName(), getMantisConnectUrl(), getBrowserUrl(), getUser(), getPassword(), isSavePassword(), getLastProjectId(), getFilters()); } - public URL getUrlForIssue(IssueHeaderData issue) { - return getUrlForIssue(issue.getId().longValue()); + public URL getUrlForIssue(IssueHeaderData issue, ProjectData project) { + return getUrlForIssue(issue.getId().longValue(), project.getId().longValue(), project + .getName()); } public URL getUrlForIssue(IssueData issue) { - return getUrlForIssue(issue.getId().longValue()); + ObjectRef project = issue.getProject(); + return getUrlForIssue(issue.getId().longValue(), project.getId().longValue(), project + .getName()); } - public URL getUrlForIssue(long issueId) { - if (mantisUrl != null) { - String base = mantisUrl.toString(); - if (base.endsWith(MantisConnectPlugin.MANTIS_INDEX_FILENAME)) { - base = base.substring(0, base.length() - MantisConnectPlugin.MANTIS_INDEX_FILENAME.length()); - } - if (! base.endsWith("/")) { - base += "/"; - } + public URL getUrlForIssue(long issueId, long projectId, String projectName) { + if (browserUrl != null) { try { - return new URL(base + MantisConnectPlugin.MANTIS_VIEW_ISSUE_FILENAME + "?id=" + issueId); + String result = replace(browserUrl.toString(), BrowserUrlVariable.ISSUE_ID, String + .valueOf(issueId)); + result = replace(result, BrowserUrlVariable.PROJECT_ID, String.valueOf(projectId)); + result = replace(result, BrowserUrlVariable.PROJECT_NAME, projectName); + return new URL(result); } catch (MalformedURLException e) { - MantisConnectPlugin.getDefault().error("Invalid URL for Issue " + issueId, e, false); + MantisConnectPlugin.getDefault() + .error("Invalid URL for Issue " + issueId, e, false); return null; } } else { return null; } } + + private String replace(String base, BrowserUrlVariable variable, String value) { + StringBuffer buffer = new StringBuffer(); + int start = 0; + int end = -1; + while ((end = base.indexOf(variable.toString(), start)) >= 0) { + buffer.append(base.substring(start, end)); + buffer.append(value); + start = end + variable.toString().length(); + } + return buffer.append(base.substring(start)).toString(); + } } Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ConnectionSettingsRegistry.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ConnectionSettingsRegistry.java 2006-09-19 10:37:08 UTC (rev 52) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/ConnectionSettingsRegistry.java 2006-09-19 10:37:42 UTC (rev 53) @@ -40,7 +40,7 @@ private static final String TAG_MANTISCONNECT_URL = "url"; - private static final String TAG_MANTIS_URL = "mantis-url"; + private static final String TAG_BROWSER_URL = "browser-url"; private static final String TAG_USER = "user"; @@ -72,7 +72,7 @@ for (int i = 0; i < connections.length; i++) { String name = connections[i].getString(TAG_NAME); URL mantisConnectUrl = new URL(connections[i].getString(TAG_MANTISCONNECT_URL)); - String mantisUrl = connections[i].getString(TAG_MANTIS_URL); + String mantisUrl = connections[i].getString(TAG_BROWSER_URL); String user = connections[i].getString(TAG_USER); String password = connections[i].getString(TAG_PASSWORD); Integer lastProjectId = connections[i].getInteger(TAG_LAST_PROJECT_ID); @@ -105,8 +105,8 @@ ConnectionSettings connection = (ConnectionSettings) map.get(name); memento.putString(TAG_NAME, name); memento.putString(TAG_MANTISCONNECT_URL, connection.getMantisConnectUrl().toString()); - if (connection.getMantisUrl() != null) { - memento.putString(TAG_MANTIS_URL, connection.getMantisUrl().toString()); + if (connection.getBrowserUrl() != null) { + memento.putString(TAG_BROWSER_URL, connection.getBrowserUrl().toString()); } memento.putString(TAG_USER, connection.getUser()); memento.putInteger(TAG_LAST_PROJECT_ID, connection.getLastProjectId()); Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/MantisConnectPlugin.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/MantisConnectPlugin.java 2006-09-19 10:37:08 UTC (rev 52) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/MantisConnectPlugin.java 2006-09-19 10:37:42 UTC (rev 53) @@ -96,6 +96,8 @@ public final static String MANTIS_INDEX_FILENAME = "index.php"; public final static String MANTIS_VIEW_ISSUE_FILENAME = "view.php"; + + public final static String MC_ENDPOINT_DEFAULT_PATH = "mc"; private static MantisConnectPlugin plugin; Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/ConnectionSettingsDialog.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/ConnectionSettingsDialog.java 2006-09-19 10:37:08 UTC (rev 52) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/ConnectionSettingsDialog.java 2006-09-19 10:37:42 UTC (rev 53) @@ -15,7 +15,6 @@ import java.net.URL; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialog; @@ -41,6 +40,7 @@ import org.mantisbt.connect.eclipse.ConnectionSettings; import org.mantisbt.connect.eclipse.MantisConnectPlugin; import org.mantisbt.connect.eclipse.StatusInfo; +import org.mantisbt.connect.eclipse.ConnectionSettings.BrowserUrlVariable; import org.mantisbt.connect.eclipse.util.StatusUtil; /** @@ -60,7 +60,7 @@ private Text mantisConnectUrl; - private Text mantisUrl; + private Text browserUrl; private Text user; @@ -72,8 +72,6 @@ private StatusInfo mantisConnectUrlStatus; - private StatusInfo mantisUrlStatus; - private StatusInfo userStatus; private StatusInfo passwordStatus; @@ -84,7 +82,7 @@ private ConnectionSettings connection; - private boolean guessMantisUrl; + private boolean guessBrowserUrl; public ConnectionSettingsDialog(IConnectionSettingsDialogRequestor requestor, Shell shell, ConnectionSettings connection) { super(shell); @@ -92,7 +90,6 @@ this.connection = connection; nameStatus = StatusInfo.OK; mantisConnectUrlStatus = StatusInfo.OK; - mantisUrlStatus = StatusInfo.OK; userStatus = StatusInfo.OK; passwordStatus = StatusInfo.OK; } @@ -134,17 +131,31 @@ mantisConnectUrl.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { - guessMantisUrl = isEmpty(mantisUrl.getText()); + guessBrowserUrl = isEmpty(browserUrl.getText()); } }); mantisConnectUrl.addModifyListener(validateListener); - mantisConnectUrl.addModifyListener(new GuessMantisUrlListener()); - new Label(composite, SWT.NONE).setText("Mantis Site Url:"); - mantisUrl = new Text(composite, SWT.BORDER); + mantisConnectUrl.addModifyListener(new GuessBrowserUrlListener()); + new Label(composite, SWT.NONE).setText("Browser Url:"); + browserUrl = new Text(composite, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; - mantisUrl.setLayoutData(gd); - mantisUrl.addModifyListener(validateListener); + browserUrl.setLayoutData(gd); + browserUrl.addModifyListener(validateListener); + Button variables = new Button(composite, SWT.PUSH); + variables.setText("Variables"); + gd = new GridData(GridData.HORIZONTAL_ALIGN_END); + gd.horizontalSpan = 3; + variables.setLayoutData(gd); + variables.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + BrowserUrlVariableDialog dialog = new BrowserUrlVariableDialog(getShell()); + if (dialog.open() == BrowserUrlVariableDialog.OK) { + browserUrl.insert(dialog.getVariable().toString()); + } + } + }); new Label(composite, SWT.NONE).setText("User:"); user = new Text(composite, SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL); @@ -169,33 +180,17 @@ test = createButton(parent, TEST_BUTTON_ID, TEST_BUTTON_LABEL, false); test.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { - IStatus mantisConnectUrlTest = testMantisConnectUrl(); - IStatus mantisUrlTest = testMantisUrl(); - if (mantisConnectUrlTest.isOK() == false || mantisUrlTest.isOK() == false) { - MultiStatus status = new MultiStatus(MantisConnectPlugin.getPluginId(), - IStatus.OK, "At least one URL is invalid.", null); - status.add(mantisConnectUrlTest); - status.add(mantisUrlTest); - ErrorDialog.openError(getShell(), "Connection Test", "Test failed.", status); + IStatus status = testMantisConnectUrl(); + if (status.isOK()) { + MessageDialog.openInformation(getShell(), "Connection Test", status.getMessage()); } else { - MessageDialog.openInformation(getShell(), "Connection Test", - "Both MantisConnect URL and Mantis Site URL are valid.\n" - + mantisConnectUrlTest.getMessage()); + ErrorDialog.openError(getShell(), "Connection Test", "Test failed.", status); } } }); super.createButtonsForButtonBar(parent); } - private IStatus testMantisUrl() { - try { - new URL(mantisUrl.getText()).openConnection().getContent(); - return new StatusInfo(IStatus.OK, "Mantis Site URL is valid."); - } catch (Exception e) { - return new StatusInfo("Test for Mantis Site URL failed.", e); - } - } - private IStatus testMantisConnectUrl() { try { URL url = new URL(ConnectionSettingsDialog.this.mantisConnectUrl @@ -270,7 +265,7 @@ private void updateUiFromConnection(ConnectionSettings connection) { name.setText(connection.getName() == null ? "" : connection.getName()); mantisConnectUrl.setText(connection.getMantisConnectUrl() == null ? "" : connection.getMantisConnectUrl().toString()); - mantisUrl.setText(connection.getMantisUrl() == null ? "" : connection.getMantisUrl().toString()); + browserUrl.setText(connection.getBrowserUrl() == null ? "" : connection.getBrowserUrl().toString()); user.setText(connection.getUser() == null ? "" : connection.getUser()); password.setText(connection.getPassword() == null ? "" : connection .getPassword()); @@ -287,9 +282,9 @@ connection.setMantisConnectUrl(null); } try { - connection.setMantisUrl(new URL(mantisUrl.getText())); + connection.setBrowserUrl(new URL(browserUrl.getText())); } catch (MalformedURLException e) { - connection.setMantisUrl(null); + connection.setBrowserUrl(null); } if (anonymous.getSelection()) { connection.setUser(null); @@ -306,11 +301,10 @@ private void updateValidState() { nameStatus = validateName(); mantisConnectUrlStatus = validateMantisConnectUrl(); - mantisUrlStatus = validateMantisUrl(); userStatus = validateUser(); passwordStatus = validatePassword(); - updateStatus(StatusUtil.getMostSevere(new IStatus[] { nameStatus, mantisConnectUrlStatus, - mantisUrlStatus, userStatus, passwordStatus })); + updateStatus(StatusUtil.getMostSevere(new IStatus[] { nameStatus, + mantisConnectUrlStatus, userStatus, passwordStatus })); } private StatusInfo validateName() { @@ -336,16 +330,6 @@ return StatusInfo.OK; } - private StatusInfo validateMantisUrl() { - try { - new URL(mantisUrl.getText().trim()); - } catch (MalformedURLException e) { - return new StatusInfo(IStatus.ERROR, - "URL of Mantis site is empty or invalid."); - } - return StatusInfo.OK; - } - private StatusInfo validateUser() { if (isEmpty(user.getText()) && !anonymous.getSelection()) { return new StatusInfo(IStatus.ERROR, "Username is empty."); @@ -369,20 +353,31 @@ } - public class GuessMantisUrlListener implements ModifyListener { + public class GuessBrowserUrlListener implements ModifyListener { public void modifyText(ModifyEvent e) { - if (guessMantisUrl) { - mantisUrl.setText(guessMantisUrl()); + if (guessBrowserUrl) { + browserUrl.setText(guessBrowserUrl()); } } - private String guessMantisUrl() { + private String guessBrowserUrl() { String mcUrl = mantisConnectUrl.getText().trim(); if (mcUrl.endsWith(MantisConnectPlugin.MC_ENDPOINT_FILENAME)) { - return mcUrl.substring(0, mcUrl.length() - - MantisConnectPlugin.MC_ENDPOINT_FILENAME.length()) - + MantisConnectPlugin.MANTIS_INDEX_FILENAME; + String result = mcUrl.substring(0, mcUrl.length() + - MantisConnectPlugin.MC_ENDPOINT_FILENAME.length()); + if (result.endsWith("/")) { + result = result.substring(0, result.length() - 1); + } + if (result + .endsWith(MantisConnectPlugin.MC_ENDPOINT_DEFAULT_PATH)) { + result = result.substring(0, result.length() + - MantisConnectPlugin.MC_ENDPOINT_DEFAULT_PATH + .length()); + } + result += MantisConnectPlugin.MANTIS_VIEW_ISSUE_FILENAME + "?id=" + + BrowserUrlVariable.ISSUE_ID; + return result; } else { return mcUrl; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
Revision: 52 http://svn.sourceforge.net/mantisconnect/?rev=52&view=rev Author: planser Date: 2006-09-19 03:37:08 -0700 (Tue, 19 Sep 2006) Log Message: ----------- Renamed label Modified Paths: -------------- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/LoginDialog.java Modified: mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/LoginDialog.java =================================================================== --- mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/LoginDialog.java 2006-09-19 10:36:15 UTC (rev 51) +++ mantisconnect/trunk/clients/java/eclipse/org.mantisbt.connect.eclipse/src/org/mantisbt/connect/eclipse/dialogs/LoginDialog.java 2006-09-19 10:37:08 UTC (rev 52) @@ -61,7 +61,7 @@ protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); ((GridLayout) composite.getLayout()).numColumns = 3; - new Label(composite, SWT.NONE).setText("ConnectionSettings:"); + new Label(composite, SWT.NONE).setText("Connection:"); Label ConnectionSettingsLabel = new Label(composite, SWT.NONE); FontData fd = ConnectionSettingsLabel.getFont().getFontData()[0]; fd.setStyle(fd.getStyle() | SWT.BOLD); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |