CascadingSelectCFType

Megha K Y October 29, 2013

How to find whether customfieldType is of type CascadingSelectCFType or not.

Regards,

Megha

5 answers

0 votes
Megha K Y October 30, 2013

Hello,

Can anyone help me in the following code.

Here i am casting the object type to collection but it is throwing the error.

Collection<Version> parentIssueSwgPlannedFixVersions = (Collection<Version>) parentIssue.getCustomFieldValue(swgPlannedFixVersionsCustomField);
parentIssueSwgPlannedFixVersions = removeSubTaskFixVersionsFromParentIssueSwgPlannedFixVersions(currentIssue,
parentIssueSwgPlannedFixVersions,
subTaskFixVersions);
parentIssueSwgPlannedFixVersions = addSubTaskFixVersionsToParentIssueSwgPlannedFixVersions(parentIssueSwgPlannedFixVersions,
subTaskFixVersions);

private Collection<Version>
removeSubTaskFixVersionsFromParentIssueSwgPlannedFixVersions(final Issue subTask,
final Collection<Version> parentIssueSwgPlannedFixVersions,
final Collection<Version> subTaskFixVersions) {
if (CollectionUtils.isEmpty(parentIssueSwgPlannedFixVersions)) {
return parentIssueSwgPlannedFixVersions;
}

if (CollectionUtils.isEmpty(subTaskFixVersions)) {
return parentIssueSwgPlannedFixVersions;
}

for (Iterator<Version> parentIssuePlannedFixVersionIterator = parentIssueSwgPlannedFixVersions.iterator(); parentIssuePlannedFixVersionIterator.hasNext();) {
Version parentIssuePlannedFixVersion = parentIssuePlannedFixVersionIterator.next();

if (subTaskFixVersions.contains(parentIssuePlannedFixVersion)) {
parentIssuePlannedFixVersionIterator.remove();
}
}

return parentIssueSwgPlannedFixVersions;
}

private Collection<Version>
addSubTaskFixVersionsToParentIssueSwgPlannedFixVersions(
Collection<Version> parentIssueSwgPlannedFixVersions,
final Collection<Version> subTaskFixVersions) {
if (CollectionUtils.isEmpty(subTaskFixVersions)) {
return parentIssueSwgPlannedFixVersions;
}

if (parentIssueSwgPlannedFixVersions == null) {
parentIssueSwgPlannedFixVersions = new LinkedList<Version>();
}

parentIssueSwgPlannedFixVersions.addAll(subTaskFixVersions);

return parentIssueSwgPlannedFixVersions;
}

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 30, 2013

What error is it throwing, and what line of your code does it tell you the error is happening?

Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 30, 2013

Thanks God Java has a 64k identifier length and that IDEs nowadays have autocomplete. The actual value depends on the custom field being queried, in your case 'swgPlannedFixVersionsCustomField'. Put some debug lines on the actual values classes, i.e. on the returned value of the .getCustomFieldValue(swgPlannedFixVersionsCustomField) call.

I sincerely do not understand why somebody would 'removeSubTaskFixVersionsFromParentIssueSwgPlannedFixVersions()' and immediately after that 'addSubTaskFixVersionsToParentIssueSwgPlannedFixVersions()'. Anyway, it's your stuff.

I will stop here before I would be slammed as not being nice (and it happened before).

0 votes
Radu Dumitriu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2013

1/ instanceof ? 2/ key of the cfType ?

0 votes
Megha K Y October 29, 2013

Thank you so much.

i'll try with the above code.

Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 30, 2013

do you get what you want?

Megha K Y October 30, 2013

Hello Bharadwaj,

Thank you so much for your help.

I haven't tried yet as i am stuck with another plugin activity.

i let you know the status.

0 votes
Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2013

hello Megha,

go to Admin->Issues->Fields->Custom Fields->{see the type of your customfield, it shows Cascading Select}

programmatically try to get as:

ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("<your cascadings select customfield name>").getCustomFieldType().getName()


Megha K Y October 29, 2013

Thank you so much.

in the code i used

String str = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("PLANNED_FIX_VERSIONS_CUSTOM_FIELD_NAME").getCustomFieldType().getName();

But how to check whether str is equal to "Cascading Select Type" or of different type.

Bharadwaj Jannu
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 29, 2013

if(str.equals("Cascading Select"))

{

<do some thing>

}

else

{

<do some other thing>

}

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2013

In what context? Code? Plugin or REST or something else?

Megha K Y October 29, 2013

i am developing a plugin for jira 5.2.5

so i need the java code for jira 5.2.5

Suggest an answer

Log in or Sign up to answer