blob: ab2f0d54aae3969b46033c9cb08767eebd6cd99d (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
/*******************************************************************************
* Copyright (c) 2010 Frank Becker and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Frank Becker - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.bugzilla.core;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
import org.eclipse.mylyn.tasks.core.data.TaskData;
public class BugzillaUtil {
public static void addAttributeIfUsed(BugzillaAttribute constant, String propertyName,
TaskRepository taskRepository, TaskData existingReport, boolean createWhenNull) {
String useParam = taskRepository.getProperty(propertyName);
if (createWhenNull) {
if (useParam == null || (useParam != null && useParam.equals("true"))) { //$NON-NLS-1$
BugzillaTaskDataHandler.createAttribute(existingReport, constant);
}
} else {
if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
BugzillaTaskDataHandler.createAttribute(existingReport, constant);
}
}
}
public static void createAttributeWithKindDefaultIfUsed(String parsedText, BugzillaAttribute tag,
TaskData repositoryTaskData, String propertyName, boolean defaultWhenNull) {
TaskAttribute attribute = repositoryTaskData.getRoot().getMappedAttribute(tag.getKey());
if (attribute == null) {
attribute = BugzillaTaskDataHandler.createAttribute(repositoryTaskData, tag);
attribute.setValue(parsedText);
} else {
attribute.addValue(parsedText);
}
String useParam = repositoryTaskData.getAttributeMapper().getTaskRepository().getProperty(propertyName);
if (defaultWhenNull) {
if (useParam == null || (useParam != null && useParam.equals("true"))) { //$NON-NLS-1$
attribute.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
} else {
attribute.getMetaData().setKind(null);
}
} else {
if (useParam != null && useParam.equals("true")) { //$NON-NLS-1$
attribute.getMetaData().setKind(TaskAttribute.KIND_DEFAULT);
} else {
attribute.getMetaData().setKind(null);
}
}
}
}
|