[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 21 ++++++++--
1 file changed, 18 insertions(+), 3 deletions(-)
New commits:
commit a512a512e3277135e1e789a6ffbdbf61fb964b25
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Dec 15 23:03:41 2010 -0500
more forgiving parsing of criteria objects from the request
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index 629a4df..de8e667 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -424,21 +424,36 @@ public abstract class RPCDataSource<T> extends DataSource {
if (value == null) {
// nothing to do, result is already null
} else if (type == Integer.class) {
- int[] intermediates = criteria.getAttributeAsIntArray(paramName);
+ int[] intermediates;
+ if (type.getClass().isArray()) {
+ intermediates = criteria.getAttributeAsIntArray(paramName);
+ } else { // want array return, but only single instance of the type in the request
+ intermediates = new int[] { criteria.getAttributeAsInt(paramName) };
+ }
resultArray = (S[]) new Integer[intermediates.length];
int index = 0;
for (int next : intermediates) {
resultArray[index++] = (S) Integer.valueOf(next);
}
} else if (type == String.class) {
- String[] intermediates = criteria.getAttributeAsStringArray(paramName);
+ String[] intermediates;
+ if (type.getClass().isArray()) {
+ intermediates = criteria.getAttributeAsStringArray(paramName);
+ } else { // want array return, but only single instance of the type in the request
+ intermediates = new String[] { criteria.getAttributeAsString(paramName) };
+ }
resultArray = (S[]) new String[intermediates.length];
int index = 0;
for (String next : intermediates) {
resultArray[index++] = (S) next;
}
} else if (type.isEnum()) {
- String[] intermediates = criteria.getAttributeAsStringArray(paramName);
+ String[] intermediates;
+ if (type.getClass().isArray()) {
+ intermediates = criteria.getAttributeAsStringArray(paramName);
+ } else { // want array return, but only single instance of the type in the request
+ intermediates = new String[] { criteria.getAttributeAsString(paramName) };
+ }
List<S> buffer = new ArrayList<S>();
for (String next : intermediates) {
buffer.add((S) Enum.valueOf((Class<? extends Enum>) type, next));
13 years, 6 months
[rhq] pom.xml
by mazz
pom.xml | 1 +
1 file changed, 1 insertion(+)
New commits:
commit b37f3e2278ca08f5eddb43e275e300642fa9d850
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Dec 15 22:22:46 2010 -0500
BZ 663517 which fixes BZ 663236 also. cobertura should be at test scope so it and its ant dep don't go in the server
diff --git a/pom.xml b/pom.xml
index bf46232..9d8537b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -455,6 +455,7 @@
<groupId>net.sourceforge.cobertura</groupId>
<artifactId>cobertura</artifactId>
<version>1.9.4.1</version>
+ <scope>test</scope>
</dependency>
</dependencies>
13 years, 6 months
[rhq] modules/enterprise
by Joseph Marques
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java | 34 +++++-----
1 file changed, 17 insertions(+), 17 deletions(-)
New commits:
commit b6394f410395f0dc6b2afda52ba7cab9644e1f09
Author: Joseph Marques <joseph(a)redhat.com>
Date: Wed Dec 15 18:33:21 2010 -0500
eliminate EnumSet usage, which bombs during serialization for GWT
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
index 25e34b7..1da673c 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/authz/AuthorizationManagerBean.java
@@ -20,7 +20,7 @@ package org.rhq.enterprise.server.authz;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.EnumSet;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -56,15 +56,15 @@ public class AuthorizationManagerBean implements AuthorizationManagerLocal {
public Set<Permission> getExplicitGlobalPermissions(Subject subject) {
Query query = entityManager.createNamedQuery(Subject.QUERY_GET_GLOBAL_PERMISSIONS);
query.setParameter("subject", subject);
- List<Permission> results = query.getResultList();
- EnumSet permissions = EnumSet.noneOf(Permission.class);
- for (Permission permission : results) {
+ List<Permission> intermediate = query.getResultList();
+ Set<Permission> results = new HashSet<Permission>();
+ for (Permission permission : intermediate) {
if (permission.getTarget() == Target.GLOBAL) {
- permissions.add(permission);
+ results.add(permission);
}
}
- return permissions;
+ return results;
}
@SuppressWarnings("unchecked")
@@ -72,13 +72,13 @@ public class AuthorizationManagerBean implements AuthorizationManagerLocal {
Query query = entityManager.createNamedQuery(Subject.QUERY_GET_PERMISSIONS_BY_GROUP_ID);
query.setParameter("subject", subject);
query.setParameter("groupId", groupId);
- List<Permission> results = query.getResultList();
- EnumSet permissions = EnumSet.noneOf(Permission.class);
- for (Permission permission : results) {
- permissions.add(permission);
+ List<Permission> intermediate = query.getResultList();
+ Set<Permission> results = new HashSet<Permission>();
+ for (Permission permission : intermediate) {
+ results.add(permission);
}
- return permissions;
+ return results;
}
public Set<Permission> getImplicitGroupPermissions(Subject subject, int groupId) {
@@ -92,13 +92,13 @@ public class AuthorizationManagerBean implements AuthorizationManagerLocal {
Query query = entityManager.createNamedQuery(Subject.QUERY_GET_PERMISSIONS_BY_RESOURCE_ID);
query.setParameter("subject", subject);
query.setParameter("resourceId", resourceId);
- List<Permission> results = query.getResultList();
- EnumSet permissions = EnumSet.noneOf(Permission.class);
- for (Permission permission : results) {
- permissions.add(permission);
+ List<Permission> intermediate = query.getResultList();
+ Set<Permission> results = new HashSet<Permission>();
+ for (Permission permission : intermediate) {
+ results.add(permission);
}
- return permissions;
+ return results;
}
public Set<Permission> getImplicitResourcePermissions(Subject subject, int resourceId) {
@@ -285,5 +285,5 @@ public class AuthorizationManagerBean implements AuthorizationManagerLocal {
return (subject.getId() == SUBJECT_ID_OVERLORD);
}
-
+
}
\ No newline at end of file
13 years, 6 months
[rhq] 2 commits - modules/core modules/enterprise
by Joseph Marques
modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java | 8 +--
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java | 12 +++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java | 25 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java | 3 +
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java | 2
8 files changed, 45 insertions(+), 11 deletions(-)
New commits:
commit 30ccb523e40086b01d852d6af79fa08d2dcbf720
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Dec 13 18:41:02 2010 -0500
add new test page to showcase filtering resources
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
index 92823f9..95bfaa5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/TestTopView.java
@@ -35,6 +35,7 @@ import org.rhq.enterprise.gui.coregui.client.test.configuration.TestConfiguratio
import org.rhq.enterprise.gui.coregui.client.test.configuration.TestGroupConfigurationView;
import org.rhq.enterprise.gui.coregui.client.test.i18n.TestPluralizationView;
import org.rhq.enterprise.gui.coregui.client.test.i18n.TestRemoteServiceStatisticsView;
+import org.rhq.enterprise.gui.coregui.client.test.inventory.TestSearchBarView;
/**
* The Test top-level view. This view is "hidden", i.e. there are no links to it, so the user must go to the URL
@@ -47,13 +48,12 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
// view IDs for Inventory section
private static final ViewName INVENTORY_SECTION_VIEW_ID = new ViewName("Inventory");
-
private static final ViewName PAGE_RESOURCE_SELECTOR = new ViewName("ResourceSelector");
private static final ViewName PAGE_TYPE_TREE = new ViewName("TypeTree");
+ private static final ViewName PAGE_SEARCH_BAR = new ViewName("SearchBar");
// view IDs for Configuration section
private static final ViewName CONFIGURATION_SECTION_VIEW_ID = new ViewName("Configuration");
-
private static final ViewName PAGE_CONFIG_EDITOR = new ViewName("ConfigEditor");
private static final ViewName PAGE_GROUP_CONFIG_EDITOR = new ViewName("GroupConfigEditor");
@@ -103,7 +103,13 @@ public class TestTopView extends AbstractSectionedLeftNavigationView {
}
});
- return new NavigationSection(INVENTORY_SECTION_VIEW_ID, resourceSelectorItem, typeTreeItem);
+ NavigationItem searchBarItem = new NavigationItem(PAGE_SEARCH_BAR, null, new ViewFactory() {
+ public Canvas createView() {
+ return new TestSearchBarView(extendLocatorId(PAGE_SEARCH_BAR.getName()));
+ }
+ });
+
+ return new NavigationSection(INVENTORY_SECTION_VIEW_ID, resourceSelectorItem, typeTreeItem, searchBarItem);
}
private NavigationSection buildConfigurationSection() {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java
new file mode 100644
index 0000000..b372b93
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/test/inventory/TestSearchBarView.java
@@ -0,0 +1,25 @@
+package org.rhq.enterprise.gui.coregui.client.test.inventory;
+
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.CATEGORY;
+import static org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceDataSourceField.NAME;
+
+import com.smartgwt.client.widgets.form.fields.TextItem;
+
+import org.rhq.core.domain.resource.ResourceCategory;
+import org.rhq.enterprise.gui.coregui.client.components.form.EnumSelectItem;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
+
+public class TestSearchBarView extends ResourceSearchView {
+ public TestSearchBarView(String locatorId) {
+ super(locatorId);
+ }
+
+ @Override
+ protected void configureTableFilters() {
+ final TextItem nameFilter = new TextItem(NAME.propertyName(), NAME.title());
+ final EnumSelectItem categoryFilter = new EnumSelectItem(CATEGORY.propertyName(), CATEGORY.title(),
+ ResourceCategory.class);
+
+ setFilterFormItems(nameFilter, categoryFilter);
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
index c0e8695..629a4df 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/util/RPCDataSource.java
@@ -45,6 +45,7 @@ import com.smartgwt.client.widgets.grid.ListGridRecord;
import org.rhq.core.domain.alert.AlertPriority;
import org.rhq.core.domain.event.EventSeverity;
+import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.util.PageControl;
import org.rhq.core.domain.util.PageList;
import org.rhq.core.domain.util.PageOrdering;
@@ -460,6 +461,8 @@ public abstract class RPCDataSource<T> extends DataSource {
return (S[]) new AlertPriority[size];
} else if (genericEnumType == EventSeverity.class) {
return (S[]) new EventSeverity[size];
+ } else if (genericEnumType == ResourceCategory.class) {
+ return (S[]) new ResourceCategory[size];
} else {
throw new IllegalArgumentException(MSG.dataSource_rpc_error_unsupportedEnumType(genericEnumType.getName()));
}
commit 708cbe1099f406d92304832a9451b84120902b46
Author: Joseph Marques <joseph(a)redhat.com>
Date: Mon Dec 13 18:37:03 2010 -0500
improve ResourceCriteria to be able to filter on multiple ResourceCategory enums
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
index 0fd3a0a..5ecec8c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/criteria/ResourceCriteria.java
@@ -52,7 +52,7 @@ public class ResourceCriteria extends TaggedCriteria {
private String filterDescription;
private Integer filterResourceTypeId; // needs overrides
private String filterResourceTypeName; // needs overrides
- private ResourceCategory filterResourceCategory; // needs overrides
+ private List<ResourceCategory> filterResourceCategories; // needs overrides
private String filterPluginName; // needs overrides
private Integer filterParentResourceId; // needs overrides
private String filterParentResourceName; // needs overrides
@@ -104,7 +104,7 @@ public class ResourceCriteria extends TaggedCriteria {
public ResourceCriteria() {
filterOverrides.put("resourceTypeId", "resourceType.id = ?");
filterOverrides.put("resourceTypeName", "resourceType.name like ?");
- filterOverrides.put("resourceCategory", "resourceType.category = ?");
+ filterOverrides.put("resourceCategories", "resourceType.category IN ( ? )");
filterOverrides.put("pluginName", "resourceType.plugin like ?");
filterOverrides.put("parentResourceId", "parentResource.id = ?");
filterOverrides.put("parentResourceName", "parentResource.name like ?");
@@ -172,8 +172,8 @@ public class ResourceCriteria extends TaggedCriteria {
this.filterResourceTypeName = filterResourceTypeName;
}
- public void addFilterResourceCategory(ResourceCategory filterResourceCategory) {
- this.filterResourceCategory = filterResourceCategory;
+ public void addFilterResourceCategories(ResourceCategory... filterResourceCategories) {
+ this.filterResourceCategories = CriteriaUtils.getListIgnoringNulls(filterResourceCategories);
}
public void addFilterPluginName(String filterPluginName) {
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
index bf6d251..1b44b53 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceCompositeDataSource.java
@@ -128,7 +128,7 @@ public class ResourceCompositeDataSource extends RPCDataSource<ResourceComposite
criteria.addFilterId(getFilter(request, "id", Integer.class));
criteria.addFilterParentResourceId(getFilter(request, "parentId", Integer.class));
criteria.addFilterCurrentAvailability(getFilter(request, AVAILABILITY.propertyName(), AvailabilityType.class));
- criteria.addFilterResourceCategory(getFilter(request, CATEGORY.propertyName(), ResourceCategory.class));
+ criteria.addFilterResourceCategories(getArrayFilter(request, CATEGORY.propertyName(), ResourceCategory.class));
criteria.addFilterIds(getArrayFilter(request, "resourceIds", Integer.class));
criteria.addFilterImplicitGroupIds(getFilter(request, "groupId", Integer.class));
criteria.addFilterName(getFilter(request, NAME.propertyName(), String.class));
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
index 0b3ef89..8d0ac24 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/ResourceDatasource.java
@@ -168,7 +168,7 @@ public class ResourceDatasource extends RPCDataSource<Resource> {
criteria.addFilterId(getFilter(request, "id", Integer.class));
criteria.addFilterParentResourceId(getFilter(request, "parentId", Integer.class));
criteria.addFilterCurrentAvailability(getFilter(request, AVAILABILITY.propertyName(), AvailabilityType.class));
- criteria.addFilterResourceCategory(getFilter(request, CATEGORY.propertyName(), ResourceCategory.class));
+ criteria.addFilterResourceCategories(getArrayFilter(request, CATEGORY.propertyName(), ResourceCategory.class));
criteria.addFilterIds(getArrayFilter(request, "resourceIds", Integer.class));
criteria.addFilterImplicitGroupIds(getFilter(request, "groupId", Integer.class));
criteria.addFilterName(getFilter(request, NAME.propertyName(), String.class));
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
index f927357..0d473a6 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/browse/BrowseResourcesUIBean.java
@@ -83,7 +83,7 @@ public class BrowseResourcesUIBean extends PagedDataTableUIBean {
ResourceCriteria criteria = new ResourceCriteria();
criteria.setPageControl(pc);
- criteria.addFilterResourceCategory(category);
+ criteria.addFilterResourceCategories(category);
if (search != null && !search.trim().equals("")) {
criteria.setSearchExpression(search);
}
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
index 06fdfb0..32c6950 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/util/CriteriaQueryGenerator.java
@@ -846,7 +846,7 @@ public final class CriteriaQueryGenerator {
public static void testResourceCriteria() {
ResourceCriteria resourceCriteria = new ResourceCriteria();
- resourceCriteria.addFilterResourceCategory(ResourceCategory.SERVER);
+ resourceCriteria.addFilterResourceCategories(ResourceCategory.SERVER);
resourceCriteria.addFilterName("marques");
resourceCriteria.fetchAgent(true);
resourceCriteria.addSortResourceTypeName(PageOrdering.ASC);
13 years, 6 months
[rhq] modules/core
by ips
modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java | 34 +++++++++-
1 file changed, 31 insertions(+), 3 deletions(-)
New commits:
commit 32e6e65b458760a74ae2a99be476a817ac6eee1f
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Dec 15 14:15:54 2010 -0500
add more Javadoc to Trigger class
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java b/modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java
index 116ec06..6f6756c 100644
--- a/modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java
@@ -34,7 +34,7 @@ public class Trigger {
// For the remaining fields in this class, only those that apply to the trigger's type will have non-null values.
private StartType startType;
private RecurrenceType recurrenceType;
- // Note, this field will be null when recurrenceType=NONE, since is not applicable in that case.
+ // Note, this field will be null when recurrenceType=NONE, since it's not applicable in that case.
private EndType endType;
// Fields used by startType=DATETIME triggers
@@ -51,19 +51,45 @@ public class Trigger {
private String cronExpression;
public enum StartType {
+ /**
+ * Start the initial run now.
+ */
NOW,
+ /**
+ * Start the initial run at a specified date-time in the future.
+ */
DATETIME;
}
public enum RecurrenceType {
+ /**
+ * No recurrence - just run once.
+ */
NONE,
+ /**
+ * Run every n seconds, starting at the start time of the initial run.
+ */
REPEAT_INTERVAL,
+ /**
+ * Run on a schedule based on the specified cron expression. The expression must follow
+ * <a href="http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html">Quartz
+ * cron expression syntax</a>, which is a bit different than Unix cron expression syntax.
+ */
CRON_EXPRESSION;
}
public enum EndType {
+ /**
+ * No end - recurrence is indefinite.
+ */
NEVER,
+ /**
+ * End recurrence at a specified date/time in the future.
+ */
DATETIME,
+ /**
+ * End recurrence after n repetitions.
+ */
REPEAT_COUNT;
}
@@ -172,9 +198,11 @@ public class Trigger {
}
/**
- * Create a trigger that will run on the schedule specified by cron expression
+ * Create a trigger that will run on the schedule specified by a cron expression. The expression must follow
+ * <a href="http://www.quartz-scheduler.org/docs/tutorials/crontrigger.html">Quartz
+ * cron expression syntax</a>, which is a bit different than Unix cron expression syntax.
*
- * @return a trigger that will run on the schedule specified by cron expression
+ * @return a trigger that will run on the schedule specified by a cron expression
*/
public static Trigger createCronTrigger(String cronExpression) {
return new Trigger(cronExpression);
13 years, 6 months
[rhq] modules/core modules/enterprise
by ips
modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java | 251 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java | 1
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java | 188 ++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java | 117 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java | 259 ++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ExecutionSchedule.java | 311 +++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationCreateWizard.java | 157 +++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationParametersStep.java | 72 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleCompositeDataSource.java | 74 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java | 77 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationSchedulingStep.java | 418 ++++++++++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java | 21
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java | 19
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java | 2
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java | 145 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java | 254 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationWizard.java | 61 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/ExecutionSchedule.java | 311 -------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java | 157 ---
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationParametersStep.java | 72 -
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationSchedulingStep.java | 418 ----------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java | 259 ------
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java | 67 +
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java | 93 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java | 7
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java | 84 ++
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java | 4
29 files changed, 2197 insertions(+), 1706 deletions(-)
New commits:
commit a871ff65733324da91e392b702e80ae9957614f2
Author: Ian Springer <ian.springer(a)redhat.com>
Date: Wed Dec 15 13:57:28 2010 -0500
add new Trigger POJO to core-domain; extract base classes to be used by Resource and group Operations subtabs, as well as Recent Operations subsystem view; start on GWT-based Resource Operations>Schedule subtab
diff --git a/modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java b/modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java
new file mode 100644
index 0000000..116ec06
--- /dev/null
+++ b/modules/core/domain/src/main/java/org/rhq/core/domain/common/Trigger.java
@@ -0,0 +1,251 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.core.domain.common;
+
+import java.util.Date;
+
+/**
+ * Indicates when a particular job (e.g. invocation of an RHQ Agent plugin operation) should execute.
+ * Note, all constructors of this class are private - the create*Trigger() static factory methods
+ * must be used to create instances.
+ *
+ * @author Ian Springer
+ */
+public class Trigger {
+
+ // Together, the startType, recurrenceType, and endType define what type of trigger this is.
+ // For the remaining fields in this class, only those that apply to the trigger's type will have non-null values.
+ private StartType startType;
+ private RecurrenceType recurrenceType;
+ // Note, this field will be null when recurrenceType=NONE, since is not applicable in that case.
+ private EndType endType;
+
+ // Fields used by startType=DATETIME triggers
+ private Date startDate;
+
+ // Fields used by recurrenceType=REPEAT_INTERVAL triggers
+ private Long repeatInterval;
+ // endDate and repeatCount are mutually exclusive - only one can have a non-null value;
+ // if both are null, the repetition is indefinite.
+ private Date endDate;
+ private Integer repeatCount;
+
+ // Fields used by recurrenceType=CRON_EXPRESSION triggers
+ private String cronExpression;
+
+ public enum StartType {
+ NOW,
+ DATETIME;
+ }
+
+ public enum RecurrenceType {
+ NONE,
+ REPEAT_INTERVAL,
+ CRON_EXPRESSION;
+ }
+
+ public enum EndType {
+ NEVER,
+ DATETIME,
+ REPEAT_COUNT;
+ }
+
+ public StartType getStartType() {
+ return startType;
+ }
+
+ public EndType getEndType() {
+ return endType;
+ }
+
+ public RecurrenceType getRecurrenceType() {
+ return recurrenceType;
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public Long getRepeatInterval() {
+ return repeatInterval;
+ }
+
+ public String getCronExpression() {
+ return cronExpression;
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public Integer getRepeatCount() {
+ return repeatCount;
+ }
+
+ /**
+ * Create a trigger that will run now, once.
+ *
+ * @return a trigger that will run now, once
+ */
+ public static Trigger createNowTrigger() {
+ return new Trigger();
+ }
+
+ /**
+ * Create a trigger that will run now and repeat on interval indefinitely.
+ *
+ * @return a trigger that will run now and repeat on interval indefinitely
+ */
+ public static Trigger createNowAndRepeatTrigger(long repeatInterval) {
+ return new Trigger(repeatInterval);
+ }
+
+ /**
+ * Create a trigger that will run now and repeat on interval until end date/time.
+ *
+ * @return a trigger that will run now and repeat on interval until end date/time
+ */
+ public static Trigger createNowAndRepeatTrigger(long repeatInterval, Date endDate) {
+ return new Trigger(repeatInterval, endDate);
+ }
+
+ /**
+ * Create a trigger that will run now and repeat on interval n times.
+ *
+ * @return a trigger that will run now and repeat on interval n times
+ */
+ public static Trigger createNowAndRepeatTrigger(long repeatInterval, int repeatCount) {
+ return new Trigger(repeatInterval, repeatCount);
+ }
+
+ /**
+ * Create a trigger that will run at specified date/time, once.
+ *
+ * @return a trigger that will run at specified date/time, once
+ */
+ public static Trigger createLaterTrigger(Date startDate) {
+ return new Trigger(startDate);
+ }
+
+ /**
+ * Create a trigger that will run at specified date/time and then repeat on interval indefinitely.
+ *
+ * @return a trigger that will run at specified date/time and then repeat on interval indefinitely
+ */
+ public static Trigger createLaterAndRepeatTrigger(Date startDate, long repeatInterval) {
+ return new Trigger(startDate, repeatInterval);
+ }
+
+ /**
+ * Create a trigger that will run at specified date/time and then repeat on interval until end date/time.
+ *
+ * @return a trigger that will run at specified date/time and then repeat on interval until end date/time
+ */
+ public static Trigger createLaterAndRepeatTrigger(Date startDate, long repeatInterval, Date endDate) {
+ return new Trigger(startDate, repeatInterval, endDate);
+ }
+
+ /**
+ * Create a trigger that will run at specified date/time and then repeat on interval n times.
+ *
+ * @return a trigger that will run at specified date/time and then repeat on interval n times
+ */
+ public static Trigger createLaterAndRepeatTrigger(Date startDate, long repeatInterval, int repeatCount) {
+ return new Trigger(startDate, repeatInterval, repeatCount);
+ }
+
+ /**
+ * Create a trigger that will run on the schedule specified by cron expression
+ *
+ * @return a trigger that will run on the schedule specified by cron expression
+ */
+ public static Trigger createCronTrigger(String cronExpression) {
+ return new Trigger(cronExpression);
+ }
+
+
+ private Trigger(StartType startType, RecurrenceType recurrenceType, EndType endType) {
+ this.startType = startType;
+ this.recurrenceType = recurrenceType;
+ this.endType = endType;
+ }
+
+ // run now, once
+ private Trigger() {
+ this(StartType.NOW, RecurrenceType.NONE, null);
+ }
+
+ // run now and repeat on interval indefinitely
+ private Trigger(long repeatInterval) {
+ this(StartType.NOW, RecurrenceType.REPEAT_INTERVAL, EndType.REPEAT_COUNT);
+ this.repeatInterval = repeatInterval;
+ }
+
+ // run now and repeat on interval until end date/time
+ private Trigger(long repeatInterval, Date endDate) {
+ this(StartType.NOW, RecurrenceType.REPEAT_INTERVAL, EndType.DATETIME);
+ this.repeatInterval = repeatInterval;
+ this.endDate = endDate;
+ }
+
+ // run now and repeat on interval n times
+ private Trigger(long repeatInterval, int repeatCount) {
+ this(StartType.NOW, RecurrenceType.REPEAT_INTERVAL, EndType.REPEAT_COUNT);
+ this.repeatInterval = repeatInterval;
+ this.repeatCount = repeatCount;
+ }
+
+ // run at specified date/time, once
+ private Trigger(Date startDate) {
+ this(StartType.DATETIME, RecurrenceType.NONE, EndType.REPEAT_COUNT);
+ this.startDate = startDate;
+ this.repeatCount = 1;
+ }
+
+ // run at specified date/time and then repeat on interval indefinitely
+ private Trigger(Date startDate, long repeatInterval) {
+ this(StartType.DATETIME, RecurrenceType.REPEAT_INTERVAL, EndType.NEVER);
+ this.startDate = startDate;
+ this.repeatInterval = repeatInterval;
+ }
+
+ // run at specified date/time and then repeat on interval until end date/time
+ private Trigger(Date startDate, long repeatInterval, Date endDate) {
+ this(StartType.DATETIME, RecurrenceType.REPEAT_INTERVAL, EndType.DATETIME);
+ this.startDate = startDate;
+ this.repeatInterval = repeatInterval;
+ this.endDate = endDate;
+ }
+
+ // run at specified date/time and then repeat on interval n times
+ private Trigger(Date startDate, long repeatInterval, int repeatCount) {
+ this(StartType.DATETIME, RecurrenceType.REPEAT_INTERVAL, EndType.REPEAT_COUNT);
+ this.startDate = startDate;
+ this.repeatInterval = repeatInterval;
+ this.repeatCount = repeatCount;
+ }
+
+ // run on the schedule specified by cron expression
+ private Trigger(String cronExpression) {
+ this(StartType.NOW, RecurrenceType.CRON_EXPRESSION, EndType.NEVER);
+ this.cronExpression = cronExpression;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
index eeb428b..92548b5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/components/table/Table.java
@@ -26,7 +26,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import com.allen_sauer.gwt.log.client.Log;
import com.smartgwt.client.data.Criteria;
import com.smartgwt.client.data.DSCallback;
import com.smartgwt.client.data.DSRequest;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
new file mode 100644
index 0000000..bc22921
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/AbstractOperationHistoryListView.java
@@ -0,0 +1,188 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.types.DateDisplayFormat;
+import com.smartgwt.client.types.ListGridFieldType;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.HoverCustomizer;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
+import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
+
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+/**
+ * @author Greg Hinkle
+ * @author John Mazzitelli
+ */
+public abstract class AbstractOperationHistoryListView extends TableSection<OperationHistoryDataSource> {
+
+ private static final String HEADER_ICON = "subsystems/control/Operation_24.png";
+
+ public AbstractOperationHistoryListView(String locatorId, OperationHistoryDataSource dataSource, String title) {
+ super(locatorId, title);
+ setDataSource(dataSource);
+ setHeaderIcon(HEADER_ICON);
+ }
+
+ public AbstractOperationHistoryListView(String locatorId, OperationHistoryDataSource dataSource, String title,
+ Criteria criteria) {
+ super(locatorId, title, criteria);
+ setDataSource(dataSource);
+ }
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ List<ListGridField> fields = createFields();
+ setListGridFields(fields.toArray(new ListGridField[fields.size()]));
+ }
+
+ protected List<ListGridField> createFields() {
+ List<ListGridField> fields = new ArrayList<ListGridField>();
+
+ ListGridField idField = new ListGridField(OperationHistoryDataSource.Field.ID, MSG.common_title_id());
+ idField.setWidth(38);
+ fields.add(idField);
+
+ ListGridField opNameField = new ListGridField(OperationHistoryDataSource.Field.OPERATION_NAME,
+ MSG.dataSource_operationHistory_operationName());
+ opNameField.setWidth("34%");
+ fields.add(opNameField);
+
+ ListGridField subjectField = new ListGridField(OperationHistoryDataSource.Field.SUBJECT,
+ MSG.common_title_user());
+ subjectField.setWidth("33%");
+ fields.add(subjectField);
+
+ ListGridField statusField = new ListGridField(OperationHistoryDataSource.Field.STATUS,
+ MSG.common_title_status());
+ statusField.setAlign(Alignment.CENTER);
+ statusField.setCellAlign(Alignment.CENTER);
+ statusField.setShowHover(true);
+ statusField.setHoverCustomizer(new HoverCustomizer() {
+ @Override
+ public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
+ String statusStr = record.getAttribute(OperationHistoryDataSource.Field.STATUS);
+ OperationRequestStatus status = OperationRequestStatus.valueOf(statusStr);
+ switch (status) {
+ case SUCCESS: {
+ return MSG.common_status_success();
+ }
+ case FAILURE: {
+ return MSG.common_status_failed();
+ }
+ case INPROGRESS: {
+ return MSG.common_status_inprogress();
+ }
+ case CANCELED: {
+ return MSG.common_status_canceled();
+ }
+ }
+ return "unknown"; // should never get here
+ }
+ });
+ statusField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ OperationRequestStatus status = OperationRequestStatus.valueOf((String) o);
+ String icon = ImageManager.getOperationResultsIcon(status);
+ return Canvas.imgHTML(icon, 16, 16);
+ }
+ });
+ statusField.addRecordClickHandler(new RecordClickHandler() {
+ @Override
+ public void onRecordClick(RecordClickEvent event) {
+ Record record = event.getRecord();
+ String statusStr = record.getAttribute(OperationHistoryDataSource.Field.STATUS);
+ OperationRequestStatus status = OperationRequestStatus.valueOf(statusStr);
+ if (status == OperationRequestStatus.FAILURE) {
+ final Window winModal = new LocatableWindow(AbstractOperationHistoryListView.this
+ .extendLocatorId("statusDetailsWin"));
+ winModal.setTitle(MSG.common_title_details());
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setShowMaximizeButton(true);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane(AbstractOperationHistoryListView.this
+ .extendLocatorId("statusDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultHeight(400);
+ String errorMsg = record.getAttribute(OperationHistoryDataSource.Field.ERROR_MESSAGE);
+ if (errorMsg == null) {
+ errorMsg = MSG.common_status_failed();
+ }
+ htmlPane.setContents("<pre>" + errorMsg + "</pre>");
+ winModal.addItem(htmlPane);
+ winModal.show();
+ }
+ }
+ });
+ statusField.setWidth(44);
+ fields.add(statusField);
+
+ ListGridField startedTimeField = new ListGridField(OperationHistoryDataSource.Field.STARTED_TIME,
+ MSG.dataSource_operationHistory_startedTime());
+ startedTimeField.setType(ListGridFieldType.DATE);
+ startedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
+ startedTimeField.setAlign(Alignment.LEFT);
+ startedTimeField.setCellAlign(Alignment.LEFT);
+ startedTimeField.setWidth("33%");
+ fields.add(startedTimeField);
+
+ return fields;
+ }
+
+ @Override
+ protected String getDetailsLinkColumnName() {
+ return OperationHistoryDataSource.Field.OPERATION_NAME;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
new file mode 100644
index 0000000..1152459
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/OperationHistoryDataSource.java
@@ -0,0 +1,117 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
+
+import java.util.Date;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.Record;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Greg Hinkle
+ */
+public abstract class OperationHistoryDataSource extends RPCDataSource<ResourceOperationHistory> {
+
+ public static abstract class Field {
+ public static final String ID = "id";
+ public static final String OPERATION_NAME = "operationName";
+ public static final String RESOURCE = "resource";
+ public static final String STATUS = "status";
+ public static final String STARTED_TIME = "startedTime";
+ public static final String CREATED_TIME = "createdTime";
+ public static final String DURATION = "duration";
+ public static final String SUBJECT = "subject";
+ public static final String OPERATION_DEFINITION = "operationDefinition";
+ public static final String ERROR_MESSAGE = "errorMessage";
+ public static final String PARAMETERS = "parameters";
+ }
+
+ protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
+
+ public OperationHistoryDataSource() {
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ /*
+ DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID);
+ idField.setPrimaryKey(true);
+ fields.add(idField);
+ */
+
+ DataSourceTextField nameField = new DataSourceTextField(Field.OPERATION_NAME);
+ fields.add(nameField);
+
+ /*
+ DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE);
+ fields.add(resourceField);
+
+ DataSourceTextField statusField = new DataSourceTextField(Field.STATUS);
+ fields.add(statusField);
+
+ DataSourceTextField startedField = new DataSourceTextField(Field.STARTED_TIME);
+ startedField.setType(FieldType.DATETIME);
+ fields.add(startedField);
+ */
+
+ return fields;
+ }
+
+ @Override
+ public ResourceOperationHistory copyValues(Record from) {
+ throw new UnsupportedOperationException("ResourceOperationHistory is read only.");
+ }
+
+ @Override
+ public ListGridRecord copyValues(ResourceOperationHistory from) {
+ ListGridRecord record = new ListGridRecord();
+ record.setAttribute(Field.ID, from.getId());
+ record.setAttribute(Field.CREATED_TIME, from.getCreatedTime());
+ record.setAttribute(Field.STARTED_TIME, new Date(from.getStartedTime()));
+ record.setAttribute(Field.DURATION, from.getDuration());
+ record.setAttribute(Field.RESOURCE, from.getResource());
+ record.setAttribute(Field.SUBJECT, from.getSubjectName());
+ record.setAttribute(Field.OPERATION_DEFINITION, from.getOperationDefinition());
+ record.setAttribute(Field.OPERATION_NAME, from.getOperationDefinition().getDisplayName());
+ record.setAttribute(Field.ERROR_MESSAGE, from.getErrorMessage());
+ record.setAttribute(Field.STATUS, from.getStatus().name());
+ record.setAttribute(Field.PARAMETERS, from.getParameters());
+
+ return record;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
new file mode 100644
index 0000000..208404f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/history/ResourceOperationHistoryDetailsView.java
@@ -0,0 +1,259 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history;
+
+import java.util.Date;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.types.Overflow;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.Window;
+import com.smartgwt.client.widgets.events.CloseClickHandler;
+import com.smartgwt.client.widgets.events.CloseClientEvent;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.fields.LinkItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
+import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
+
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.operation.OperationRequestStatus;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.ImageManager;
+import org.rhq.enterprise.gui.coregui.client.ViewPath;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ResourceOperationHistoryDetailsView extends LocatableVLayout implements BookmarkableView {
+
+ private OperationDefinition definition;
+ private ResourceOperationHistory operationHistory;
+
+ private DynamicForm form;
+
+ public ResourceOperationHistoryDetailsView(String locatorId) {
+ super(locatorId);
+ }
+
+ public ResourceOperationHistoryDetailsView(String locatorId, OperationDefinition definition,
+ ResourceOperationHistory operationHistory) {
+ super(locatorId);
+
+ this.definition = definition;
+ this.operationHistory = operationHistory;
+ }
+
+ @Override
+ protected void onDraw() {
+ super.onDraw();
+
+ for (Canvas child : getMembers()) {
+ child.destroy();
+ }
+
+ if (this.operationHistory != null) {
+ displayDetails(operationHistory);
+ }
+ }
+
+ private void displayDetails(final ResourceOperationHistory operationHistory) {
+
+ for (Canvas child : getMembers()) {
+ removeChild(child);
+ }
+
+ this.definition = operationHistory.getOperationDefinition();
+ this.operationHistory = operationHistory;
+
+ // Information Form
+
+ form = new DynamicForm();
+ form.setWidth100();
+ form.setWrapItemTitles(false);
+
+ OperationRequestStatus status = operationHistory.getStatus();
+
+ StaticTextItem operationItem = new StaticTextItem(OperationHistoryDataSource.Field.OPERATION_NAME, MSG
+ .view_operationHistoryDetails_operation());
+ operationItem.setValue(definition.getDisplayName());
+
+ StaticTextItem submittedItem = new StaticTextItem(OperationHistoryDataSource.Field.STARTED_TIME, MSG
+ .view_operationHistoryDetails_dateSubmitted());
+ submittedItem.setValue(new Date(operationHistory.getStartedTime()));
+
+ StaticTextItem completedItem = new StaticTextItem("completed", MSG.view_operationHistoryDetails_dateCompleted());
+ if (status == OperationRequestStatus.INPROGRESS) {
+ completedItem.setValue(MSG.common_val_na());
+ } else if (status == OperationRequestStatus.CANCELED) {
+ completedItem.setValue(MSG.common_val_never());
+ } else {
+ completedItem.setValue(new Date(operationHistory.getStartedTime() + operationHistory.getDuration()));
+ }
+
+ StaticTextItem requesterItem = new StaticTextItem(OperationHistoryDataSource.Field.SUBJECT, MSG
+ .view_operationHistoryDetails_requestor());
+ requesterItem.setValue(operationHistory.getSubjectName());
+
+ LinkItem errorLinkItem = null;
+
+ StaticTextItem statusItem = new StaticTextItem(OperationHistoryDataSource.Field.STATUS, MSG
+ .view_operationHistoryDetails_status());
+ String icon = ImageManager.getFullImagePath(ImageManager.getOperationResultsIcon(status));
+ statusItem.setValue("<img src='" + icon + "'/>");
+ switch (status) {
+ case SUCCESS:
+ statusItem.setTooltip(MSG.common_status_success());
+ break;
+ case FAILURE:
+ statusItem.setTooltip(MSG.common_status_failed());
+ errorLinkItem = new LinkItem("errorLink");
+ errorLinkItem.setTitle(MSG.common_title_error());
+ errorLinkItem.setLinkTitle(getShortErrorMessage(operationHistory));
+ errorLinkItem.addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(ClickEvent event) {
+ final Window winModal = new LocatableWindow(ResourceOperationHistoryDetailsView.this.extendLocatorId("errorWin"));
+ winModal.setTitle(MSG.common_title_details());
+ winModal.setOverflow(Overflow.VISIBLE);
+ winModal.setShowMinimizeButton(false);
+ winModal.setShowMaximizeButton(true);
+ winModal.setIsModal(true);
+ winModal.setShowModalMask(true);
+ winModal.setAutoSize(true);
+ winModal.setAutoCenter(true);
+ winModal.setShowResizer(true);
+ winModal.setCanDragResize(true);
+ winModal.centerInPage();
+ winModal.addCloseClickHandler(new CloseClickHandler() {
+ @Override
+ public void onCloseClick(CloseClientEvent event) {
+ winModal.markForDestroy();
+ }
+ });
+
+ LocatableHTMLPane htmlPane = new LocatableHTMLPane(ResourceOperationHistoryDetailsView.this
+ .extendLocatorId("statusDetailsPane"));
+ htmlPane.setMargin(10);
+ htmlPane.setDefaultWidth(500);
+ htmlPane.setDefaultHeight(400);
+ String errorMsg = operationHistory.getErrorMessage();
+ if (errorMsg == null) {
+ errorMsg = MSG.common_status_failed();
+ }
+ htmlPane.setContents("<pre>" + errorMsg + "</pre>");
+ winModal.addItem(htmlPane);
+ winModal.show();
+ }
+ });
+
+ break;
+ case INPROGRESS:
+ statusItem.setTooltip(MSG.common_status_inprogress());
+ break;
+ case CANCELED:
+ statusItem.setTooltip(MSG.common_status_canceled());
+ break;
+ }
+
+ /*
+ Operation: View Process List
+ Date Submitted: 3/11/10, 12:24:02 PM, EST
+ Date Completed: 3/11/10, 12:24:03 PM, EST
+ Requester: rhqadmin
+ Status: Failure
+ Error Message: __Exception: Cannot connect...__
+ */
+
+ if (errorLinkItem != null) {
+ form.setItems(operationItem, submittedItem, completedItem, requesterItem, statusItem, errorLinkItem);
+ } else {
+ form.setItems(operationItem, submittedItem, completedItem, requesterItem, statusItem);
+ }
+
+ addMember(form);
+
+ // params/results
+
+ if (operationHistory.getParameters() != null) {
+ ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("params"), definition
+ .getParametersConfigurationDefinition(), operationHistory.getParameters());
+ editor.setReadOnly(true);
+ editor.setStructuredConfigTabTitle(MSG.view_operationHistoryDetails_parameters());
+ addMember(editor);
+ }
+
+ if (status == OperationRequestStatus.SUCCESS && operationHistory.getResults() != null) {
+ ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("results"), definition
+ .getResultsConfigurationDefinition(), operationHistory.getResults());
+ editor.setReadOnly(true);
+ editor.setStructuredConfigTabTitle(MSG.view_operationHistoryDetails_results());
+ addMember(editor);
+ }
+ }
+
+ private void lookupDetails(int historyId) {
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+
+ criteria.addFilterId(historyId);
+
+ criteria.fetchOperationDefinition(true);
+ criteria.fetchParameters(true);
+ criteria.fetchResults(true);
+
+ GWTServiceLookup.getOperationService().findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler()
+ .handleError(MSG.view_operationHistoryDetails_error_fetchFailure(), caught);
+ }
+
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ ResourceOperationHistory item = result.get(0);
+ displayDetails(item);
+ }
+ });
+ }
+
+ @Override
+ public void renderView(ViewPath viewPath) {
+ int historyId = viewPath.getCurrentAsInt();
+ lookupDetails(historyId);
+ }
+
+ private String getShortErrorMessage(ResourceOperationHistory operationHistory) {
+ String errMsg = operationHistory.getErrorMessage();
+ if (errMsg == null) {
+ errMsg = MSG.common_status_failed();
+ } else if (errMsg.length() > 80) {
+ errMsg = errMsg.substring(0, 80) + "...";
+ }
+ return errMsg;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ExecutionSchedule.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ExecutionSchedule.java
new file mode 100644
index 0000000..26d53a8
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/ExecutionSchedule.java
@@ -0,0 +1,311 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+
+import java.io.Serializable;
+import java.util.Date;
+import java.util.HashSet;
+
+import com.google.gwt.i18n.client.DateTimeFormat;
+
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.Messages;
+
+/**
+ * @author Greg Hinkle
+ */
+public class ExecutionSchedule implements Serializable {
+
+ private static final Messages MSG = CoreGUI.getMessages();
+
+ public enum Start {
+ Immediately, Future
+ };
+
+ public enum End {
+ Never, EndOn
+ };
+
+ public enum Recurr {
+ Once, EveryNMinutes, Hourly, Daily, Weekly, Monthly
+ };
+
+ public enum DayOfWeek {
+ Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
+ };
+
+ private Start start = Start.Immediately;
+
+ // start.Future
+ private Recurr recurr = Recurr.Once;
+
+ // Once
+ private Date onceDateTime;
+
+
+ // EveryNMinutes
+ private Integer minuteInterval;
+
+
+ // Hourly
+ private Integer minuteInHour;
+
+
+ // Daily
+ private Date timeOfDay;
+
+
+ // Weekly
+ // Time of Day above
+ private HashSet<DayOfWeek> daysOfWeek; // Can't use EnumSet because it doesn't have default instantiator
+
+
+ // Monthly
+ // Time of Day above
+ private Integer dayOfMonth;
+
+
+ // Used for all start.Future except for once
+ private Date startDate;
+
+ private Date endDate;
+
+
+ public Start getStart() {
+ return start;
+ }
+
+ public void setStart(Start start) {
+ this.start = start;
+ }
+
+ public Recurr getRecurr() {
+ return recurr;
+ }
+
+ public void setRecurr(Recurr recurr) {
+ this.recurr = recurr;
+ }
+
+ public Date getOnceDateTime() {
+ return onceDateTime;
+ }
+
+ public void setOnceDateTime(Date onceDateTime) {
+ this.onceDateTime = onceDateTime;
+ }
+
+ public Integer getMinuteInterval() {
+ return minuteInterval;
+ }
+
+ public void setMinuteInterval(Integer minuteInterval) {
+ this.minuteInterval = minuteInterval;
+ }
+
+ public Integer getMinuteInHour() {
+ return minuteInHour;
+ }
+
+ public void setMinuteInHour(Integer minuteInHour) {
+ this.minuteInHour = minuteInHour;
+ }
+
+ public HashSet<DayOfWeek> getDaysOfWeek() {
+ return daysOfWeek;
+ }
+
+ public void setDaysOfWeek(HashSet<DayOfWeek> daysOfWeek) {
+ this.daysOfWeek = daysOfWeek;
+ }
+
+ public Integer getDayOfMonth() {
+ return dayOfMonth;
+ }
+
+ public void setDayOfMonth(Integer dayOfMonth) {
+ this.dayOfMonth = dayOfMonth;
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public void setStartDate(Date startDate) {
+ this.startDate = startDate;
+ }
+
+ public Date getEndDate() {
+ return endDate;
+ }
+
+ public void setEndDate(Date endDate) {
+ this.endDate = endDate;
+ }
+
+ public Date getTimeOfDay() {
+ return timeOfDay;
+ }
+
+ public void setTimeOfDay(Date timeOfDay) {
+ this.timeOfDay = timeOfDay;
+ }
+
+ public String getMessage() {
+ DateTimeFormat dateFormat = DateTimeFormat.getMediumDateFormat();
+ DateTimeFormat timeFormat = DateTimeFormat.getMediumTimeFormat();
+
+ String message;
+ switch (start) {
+
+ case Immediately:
+ message = MSG.view_operationCreateWizard_executionSchedule_willExecuteOnce(
+ MSG.view_operationCreateWizard_executionSchedule_immediately());
+ break;
+
+ case Future:
+ if (recurr == Recurr.Once) {
+ message = MSG.view_operationCreateWizard_executionSchedule_willExecuteOnce(
+ MSG.view_operationCreateWizard_executionSchedule_onceAtGivenTime(onceDateTime.toString()));
+ } else {
+ String recurrenceMessage;
+ switch (recurr) {
+ case EveryNMinutes:
+ recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyNMinutes(minuteInterval.toString());
+ break;
+ case Hourly:
+ recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyHourOnNthMinute(suffix(minuteInHour));
+ break;
+ case Daily:
+ recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyDayAtGivenTime(timeFormat.format(timeOfDay));
+ break;
+ case Weekly:
+ recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyWeekOnGivenDayAtGivenTime(daysOfWeek.toString(), timeFormat.format(timeOfDay));
+ break;
+ case Monthly:
+ recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyMonthOnNthDayAtGivenTime(suffix(dayOfMonth), timeFormat.format(timeOfDay));
+ break;
+ default:
+ recurrenceMessage = "";
+ }
+
+ if (endDate != null) {
+ message = MSG.view_operationCreateWizard_executionSchedule_willExecuteRecurringWithEnd(
+ recurrenceMessage, dateFormat.format(startDate), dateFormat.format(endDate));
+ } else {
+ message = MSG.view_operationCreateWizard_executionSchedule_willExecuteRecurring(
+ recurrenceMessage, dateFormat.format(startDate));
+ }
+ }
+ break;
+
+ default:
+ message = "";
+
+ }
+
+ return message;
+ }
+
+
+ public String getCronString() {
+
+ /* Cron fields
+ 1. Seconds
+ 2. Minutes
+ 3. Hours
+ 4. Day-of-Month
+ 5. Month
+ 6. Day-of-Week
+ 7. Year (optional field)
+ */
+
+ String cseconds, cminutes = null, chours = null, cdayOfMonth = null, cmonth = null, cdayOfWeek = null;
+
+ cseconds = "0";
+
+ switch (start) {
+
+ case Immediately:
+ return null; // No cron string for immediate execution
+
+ case Future:
+
+ if (recurr == Recurr.Once) {
+ return null; // No cron string for non recurring
+ } else {
+ switch (recurr) {
+ case EveryNMinutes:
+ cminutes = "0/" + minuteInterval;
+ chours = cdayOfMonth = cmonth = "*";
+ cdayOfWeek = "?";
+ break;
+ case Hourly:
+ cminutes = "" + minuteInHour;
+ chours = "*";
+ cdayOfMonth = cmonth = cdayOfWeek = "*";
+ break;
+ case Daily:
+ cminutes = "" + timeOfDay.getMinutes();
+ chours = "" + timeOfDay.getHours();
+ cdayOfMonth = cmonth = cdayOfWeek = "*";
+ break;
+ case Weekly:
+ cminutes = "" + timeOfDay.getMinutes();
+ chours = "" + timeOfDay.getHours();
+ cdayOfMonth = "?";
+ cmonth = "*";
+ cdayOfWeek = daysOfWeek.toString();
+ break;
+ case Monthly:
+ cminutes = "" + timeOfDay.getMinutes();
+ chours = "" + timeOfDay.getHours();
+ cdayOfMonth = "" + dayOfMonth;
+ cmonth = "*";
+ cdayOfWeek = "?";
+ break;
+ }
+ }
+ break;
+ }
+ return cseconds + " " + cminutes + " " + chours + " " + cdayOfMonth + " " + cmonth + " " + cdayOfWeek;
+
+ }
+
+ public static String suffix(int number) {
+ String result;
+ String numberAsString = String.valueOf(number);
+ int last = number % 10;
+ switch (last) {
+ case 1:
+ result = MSG.common_val_n1st(numberAsString);
+ break;
+ case 2:
+ result = MSG.common_val_n2nd(numberAsString);
+ break;
+ case 3:
+ result = MSG.common_val_n3rd(numberAsString);
+ break;
+ default:
+ result = MSG.common_val_nth(numberAsString);
+ }
+ return result;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationCreateWizard.java
new file mode 100644
index 0000000..fc3c6f2
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationCreateWizard.java
@@ -0,0 +1,157 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.widgets.IButton;
+import com.smartgwt.client.widgets.events.ClickEvent;
+import com.smartgwt.client.widgets.events.ClickHandler;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardView;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.util.message.Message;
+
+/**
+ * @author Greg Hinkle
+ */
+public class OperationCreateWizard extends AbstractWizard {
+
+ private Resource resource;
+ private OperationDefinition operationDefinition;
+
+ private OperationParametersStep parametersStep;
+ private OperationSchedulingStep schedulingStep;
+
+ private WizardView view;
+
+ private IButton executeNowButton;
+ private IButton executeButton;
+
+ public OperationCreateWizard(Resource resource, OperationDefinition operationDefinition) {
+ this.resource = resource;
+ this.operationDefinition = operationDefinition;
+ }
+
+ public void startOperationWizard() {
+
+ parametersStep = new OperationParametersStep(operationDefinition);
+ schedulingStep = new OperationSchedulingStep();
+
+ ArrayList<WizardStep> steps = new ArrayList<WizardStep>();
+ steps.add(parametersStep);
+ steps.add(schedulingStep);
+ setSteps(steps);
+
+ executeNowButton = new IButton(MSG.view_operationCreateWizard_button_executeImmediately());
+ executeNowButton.setAutoFit(true);
+ executeNowButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ execute();
+ }
+ });
+
+ executeButton = new IButton(MSG.view_operationCreateWizard_button_execute());
+ executeButton.addClickHandler(new ClickHandler() {
+ public void onClick(ClickEvent clickEvent) {
+ execute();
+ }
+ });
+
+ view = new WizardView(this);
+ view.displayDialog();
+ }
+
+ public String getWindowTitle() {
+ return MSG.view_operationCreateWizard_title();
+ }
+
+ public String getTitle() {
+ return MSG.view_operationCreateWizard_header(operationDefinition.getDisplayName(), resource.getName());
+ }
+
+ public String getSubtitle() {
+ return operationDefinition.getDescription();
+ }
+
+ public List<IButton> getCustomButtons(int step) {
+ switch (step) {
+ case 0:
+ return Arrays.asList(executeNowButton);
+ case 1:
+ return Arrays.asList(executeButton);
+ default:
+ return Collections.emptyList();
+ }
+ }
+
+ private void execute() {
+ Configuration parameters = parametersStep.getParameterConfiguration();
+ final ExecutionSchedule schedule = schedulingStep.getExecutionSchedule();
+
+ // TODO: get the description and timeout from user input
+ String description = "";
+ int timeout = 0;
+
+ AsyncCallback<Void> operationCallback = new AsyncCallback<Void>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.view_operationCreateWizard_error_scheduleOperationFailure(),
+ caught);
+ }
+
+ public void onSuccess(Void result) {
+ String opName = operationDefinition.getDisplayName();
+ String cron = schedule.getCronString();
+ if (cron == null) {
+ cron = MSG.common_val_na();
+ }
+ String concise = MSG.view_operationCreateWizard_message_scheduleOperationSuccess_short(opName);
+ String message = MSG.view_operationCreateWizard_message_scheduleOperationSuccess(opName, String
+ .valueOf(resource.getId()), cron);
+
+ CoreGUI.getMessageCenter().notify(new Message(concise, message, Message.Severity.Info));
+ }
+ };
+
+ if (schedule.getStart() == ExecutionSchedule.Start.Immediately) {
+ GWTServiceLookup.getOperationService().invokeResourceOperation(resource.getId(),
+ operationDefinition.getName(), parameters, description, timeout, operationCallback);
+ } else {
+ GWTServiceLookup.getOperationService().scheduleResourceOperation(resource.getId(),
+ operationDefinition.getName(), parameters, description, timeout, schedule.getCronString(),
+ operationCallback);
+ }
+
+ view.closeDialog();
+ }
+
+ public void cancel() {
+ // TODO: revert back to original state
+ }
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationParametersStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationParametersStep.java
new file mode 100644
index 0000000..91fae90
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationParametersStep.java
@@ -0,0 +1,72 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.HTMLFlow;
+
+import org.rhq.core.domain.configuration.Configuration;
+import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
+import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
+
+/**
+ * @author Greg Hinkle
+ */
+public class OperationParametersStep extends AbstractWizardStep {
+
+ private OperationDefinition definition;
+
+ private ConfigurationEditor configurationEditor;
+
+ public OperationParametersStep(OperationDefinition operationDefinition) {
+ super();
+ this.definition = operationDefinition;
+ }
+
+ public Canvas getCanvas() {
+ if (definition.getParametersConfigurationDefinition() != null) {
+ if (configurationEditor == null) {
+ ConfigurationDefinition configurationDefinition = definition.getParametersConfigurationDefinition();
+ Configuration defaultConfiguration = configurationDefinition.getDefaultTemplate() != null ? configurationDefinition
+ .getDefaultTemplate().createConfiguration()
+ : new Configuration();
+ configurationEditor = new ConfigurationEditor("OperationParams", configurationDefinition,
+ defaultConfiguration);
+ }
+ return configurationEditor;
+ } else {
+ return new HTMLFlow(MSG.view_operationCreateWizard_parametersStep_noParameters());
+ }
+ }
+
+ public boolean nextPage() {
+ return true; // TODO: Implement this method.
+ }
+
+ public String getName() {
+ return MSG.view_operationCreateWizard_parametersStep_name();
+ }
+
+ public Configuration getParameterConfiguration() {
+ return configurationEditor != null ? configurationEditor.getConfiguration() : null;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleCompositeDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleCompositeDataSource.java
new file mode 100644
index 0000000..88df113
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleCompositeDataSource.java
@@ -0,0 +1,74 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+
+import java.util.List;
+
+import com.smartgwt.client.data.DataSourceField;
+import com.smartgwt.client.data.fields.DataSourceIntegerField;
+import com.smartgwt.client.data.fields.DataSourceTextField;
+
+import org.rhq.core.domain.operation.composite.OperationScheduleComposite;
+import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
+import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
+import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public abstract class OperationScheduleCompositeDataSource extends RPCDataSource<OperationScheduleComposite> {
+
+ public static abstract class Field {
+
+ public static final String OPERATION_JOB_ID = "operationJobId";
+ public static final String OPERATION_NAME = "operationName";
+ public static final String OPERATION_NEXT_FIRE_TIME = "operationNextFireTime";
+ }
+
+ protected OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
+
+ public OperationScheduleCompositeDataSource() {
+ super();
+ List<DataSourceField> fields = addDataSourceFields();
+ addFields(fields);
+ }
+
+ @Override
+ protected List<DataSourceField> addDataSourceFields() {
+ List<DataSourceField> fields = super.addDataSourceFields();
+
+ // TODO: i18n
+ DataSourceIntegerField idField = new DataSourceIntegerField(Field.OPERATION_JOB_ID, "ID");
+ idField.setPrimaryKey(true);
+ idField.setCanEdit(false);
+ fields.add(idField);
+
+ DataSourceTextField nameField = createTextField(Field.OPERATION_NAME, MSG.common_title_name(), 3, 100, true);
+ fields.add(nameField);
+
+ // TODO: i18n
+ DataSourceTextField nextFireTimeField = createTextField(Field.OPERATION_NEXT_FIRE_TIME, "Next Fire Time", null,
+ 100, false);
+ fields.add(nextFireTimeField);
+
+ return fields;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
new file mode 100644
index 0000000..29d0136
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationScheduleListView.java
@@ -0,0 +1,77 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.enterprise.gui.coregui.client.components.table.TableAction;
+import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
+
+/**
+ * @author Ian Springer
+ */
+public abstract class OperationScheduleListView extends TableSection<OperationScheduleCompositeDataSource> {
+
+ private static final String HEADER_ICON = "subsystems/control/Operation_24.png";
+
+ public OperationScheduleListView(String locatorId, OperationScheduleCompositeDataSource dataSource, String title) {
+ super(locatorId, title);
+
+ setDataSource(dataSource);
+ setHeaderIcon(HEADER_ICON);
+ }
+
+ protected abstract boolean hasControlPermission();
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ ListGridField nameField = new ListGridField(OperationScheduleCompositeDataSource.Field.OPERATION_NAME, 150);
+
+ ListGridField nextFireTimeField = new ListGridField(OperationScheduleCompositeDataSource.Field.OPERATION_NEXT_FIRE_TIME);
+
+ setListGridFields(nameField, nextFireTimeField);
+
+ addTableAction(extendLocatorId("New"), MSG.common_button_new(), new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ return hasControlPermission();
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ // TODO: wizard or details view
+ }
+ });
+
+ addTableAction(extendLocatorId("Unschedule"), MSG.common_button_delete(), getDeleteConfirmMessage(),
+ new TableAction() {
+ public boolean isEnabled(ListGridRecord[] selection) {
+ int count = selection.length;
+ return ((count >= 1) && hasControlPermission());
+ }
+
+ public void executeAction(ListGridRecord[] selection, Object actionValue) {
+ // TODO: unschedule the selected schedule items
+ }
+ });
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationSchedulingStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationSchedulingStep.java
new file mode 100644
index 0000000..ec0e40f
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/detail/operation/schedule/OperationSchedulingStep.java
@@ -0,0 +1,418 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2010 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.EnumSet;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.List;
+
+import com.smartgwt.client.types.FormErrorOrientation;
+import com.smartgwt.client.types.TimeFormatter;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.form.DynamicForm;
+import com.smartgwt.client.widgets.form.FormItemIfFunction;
+import com.smartgwt.client.widgets.form.ValuesManager;
+import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
+import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
+import com.smartgwt.client.widgets.form.fields.CanvasItem;
+import com.smartgwt.client.widgets.form.fields.CheckboxItem;
+import com.smartgwt.client.widgets.form.fields.DateItem;
+import com.smartgwt.client.widgets.form.fields.FormItem;
+import com.smartgwt.client.widgets.form.fields.HeaderItem;
+import com.smartgwt.client.widgets.form.fields.IntegerItem;
+import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
+import com.smartgwt.client.widgets.form.fields.SpacerItem;
+import com.smartgwt.client.widgets.form.fields.StaticTextItem;
+import com.smartgwt.client.widgets.form.fields.TimeItem;
+import com.smartgwt.client.widgets.form.validator.CustomValidator;
+
+import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
+
+/**
+ * @author Greg Hinkle
+ */
+public class OperationSchedulingStep extends AbstractWizardStep implements ItemChangedHandler {
+
+ private DynamicForm form;
+ private ValuesManager valuesManager;
+
+ private ExecutionSchedule executionSchedule = new ExecutionSchedule();
+
+ public Canvas getCanvas() {
+
+ if (form == null) {
+ valuesManager = new ValuesManager();
+ form = new LocatableDynamicForm("OperationScheduling");
+ form.setValuesManager(valuesManager);
+ form.setWrapItemTitles(false);
+ form.setErrorOrientation(FormErrorOrientation.RIGHT);
+ form.setWidth100();
+ form.setPadding(10);
+ form.setNumCols(3);
+ // form.setColWidths("15%", "35%", "15%", "*");
+ form.setValidateOnChange(true);
+
+ final RadioGroupItem start = new RadioGroupItem("start",
+ MSG.view_operationCreateWizard_schedulingStep_name());
+ start.setColSpan(3);
+ start.setValueMap(enumValueMap(ExecutionSchedule.Start.class)); // "Immediately", "Future"
+ start.setRedrawOnChange(true);
+ start.setValue("Immediately");
+
+ HeaderItem scheduleHeader = new HeaderItem("scheduleHeader");
+ scheduleHeader.setValue(MSG.view_operationCreateWizard_schedulingStep_label_schedule());
+ scheduleHeader.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !"Immediately".equals(form.getValueAsString("start"));
+ }
+ });
+
+ RadioGroupItem recurr = new RadioGroupItem("recurr",
+ MSG.view_operationCreateWizard_schedulingStep_label_recurrence());
+ recurr.setValueMap(enumValueMap(ExecutionSchedule.Recurr.class)); // "Once", "EveryNMinutes", "Hourly", "Daily", "Weekly", "Monthly");
+ recurr.setRedrawOnChange(true);
+ recurr.setValue(ExecutionSchedule.Recurr.Once.name());
+ recurr.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"));
+ }
+ });
+
+ CanvasItem onceForm = new CanvasItem("once", MSG.view_operationCreateWizard_schedulingStep_label_onceAt());
+ onceForm.setShowTitle(false);
+ onceForm.setCanvas(getOnceForm());
+ onceForm.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && ExecutionSchedule.Recurr.Once.name().equals(form.getValueAsString("recurr"));
+ }
+ });
+
+ CanvasItem everyNMinuteForm = new CanvasItem("everyNMinutesForm",
+ MSG.view_operationCreateWizard_schedulingStep_label_everyNMinutes());
+ everyNMinuteForm.setShowTitle(false);
+ everyNMinuteForm.setCanvas(getEveryNMinutesForm());
+ everyNMinuteForm.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && ExecutionSchedule.Recurr.EveryNMinutes.name().equals(form.getValueAsString("recurr"));
+ }
+ });
+
+ CanvasItem hourlyForm = new CanvasItem("hourlyForm", MSG.view_operationCreateWizard_schedulingStep_label_hourly());
+ hourlyForm.setShowTitle(false);
+ hourlyForm.setCanvas(getHourlyForm());
+ hourlyForm.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !"Immediately".equals(form.getValueAsString("start"))
+ && ExecutionSchedule.Recurr.Hourly.name().equals(form.getValueAsString("recurr"));
+ }
+ });
+
+ CanvasItem dailyForm = new CanvasItem("daily", MSG.view_operationCreateWizard_schedulingStep_label_daily());
+ dailyForm.setShowTitle(false);
+ dailyForm.setCanvas(getDailyForm());
+ dailyForm.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && ExecutionSchedule.Recurr.Daily.name().equals(form.getValueAsString("recurr"));
+ }
+ });
+
+ CanvasItem weeklyForm = new CanvasItem("weekly", MSG.view_operationCreateWizard_schedulingStep_label_weekly());
+ weeklyForm.setShowTitle(false);
+ weeklyForm.setCanvas(getWeeklyForm());
+ weeklyForm.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && ExecutionSchedule.Recurr.Weekly.name().equals(form.getValueAsString("recurr"));
+ }
+ });
+
+ CanvasItem monthlyForm = new CanvasItem("monthly", MSG.view_operationCreateWizard_schedulingStep_label_monthly());
+ monthlyForm.setShowTitle(false);
+ monthlyForm.setCanvas(getMonthlyForm());
+ monthlyForm.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && ExecutionSchedule.Recurr.Monthly.name().equals(form.getValueAsString("recurr"));
+ }
+ });
+
+ HeaderItem rangeHeader = new HeaderItem("timePeriod");
+ rangeHeader.setValue(MSG.view_operationCreateWizard_schedulingStep_label_timePeriod());
+ rangeHeader.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && !ExecutionSchedule.Recurr.Once.name().equals(form.getValueAsString("recurr"));
+ }
+ });
+
+ DateItem startDate = new DateItem("startDate", MSG.view_operationCreateWizard_schedulingStep_label_startDate());
+ startDate.setStartRow(true);
+ startDate.setStartDate(new Date());
+ startDate.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && !"Once".equals(form.getValueAsString("recurr"));
+ }
+ });
+
+ final RadioGroupItem end = new RadioGroupItem("endType", MSG.view_operationCreateWizard_schedulingStep_label_endDate());
+ end.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && !"Once".equals(form.getValueAsString("recurr"));
+ }
+ });
+ end.setStartRow(true);
+ // TODO: i18n
+ end.setValueMap("Never", "End On");
+ end.setRedrawOnChange(true);
+ end.setValue("Never");
+
+ DateItem endDate = new DateItem("endDate", MSG.view_operationCreateWizard_schedulingStep_label_endDate());
+ endDate.setStartRow(true);
+ endDate.setStartDate(new Date());
+ endDate.setShowIfCondition(new FormItemIfFunction() {
+ public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
+ return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
+ && !"Once".equals(form.getValueAsString("recurr"))
+ && !"Never".equals(form.getValueAsString("endType"));
+ }
+ });
+ endDate.setValidators(new CustomValidator() {
+ @Override
+ protected boolean condition(Object o) {
+ return (((Date) form.getValue("startDate")).before((Date) o));
+ }
+ });
+
+ StaticTextItem messageItem = new StaticTextItem("message");
+ messageItem.setValue(MSG.view_operationCreateWizard_schedulingStep_label_willExecuteImmediately());
+ messageItem.setStartRow(true);
+ messageItem.setColSpan(3);
+ messageItem.setShowTitle(false);
+ messageItem.setCellStyle("HeaderLabel");
+
+ form.setItems(start, scheduleHeader, recurr, onceForm, everyNMinuteForm, hourlyForm, dailyForm, weeklyForm,
+ monthlyForm, rangeHeader, startDate, end, endDate, new SpacerItem(), messageItem);
+
+ form.addItemChangedHandler(this);
+ }
+
+ return form;
+ }
+
+ private DynamicForm getOnceForm() {
+ DynamicForm form = new DynamicForm();
+ form.setValuesManager(valuesManager);
+ form.setPadding(10);
+ form.setIsGroup(true);
+ form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_onceAt());
+ form.addItemChangedHandler(this);
+
+ form.setWrapItemTitles(false);
+ form.setNumCols(2);
+
+ DateItem startDate = new DateItem("onceStartDate", MSG.view_operationCreateWizard_schedulingStep_label_startDate());
+ startDate.setValue(new Date());
+
+ TimeItem startTime = new TimeItem("onceStartDate", MSG.view_operationCreateWizard_schedulingStep_label_startDate());
+ startTime.setValue(new Date());
+ startTime.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
+ startTime.setUseMask(true);
+ form.setItems(startDate, startTime);
+ return form;
+ }
+
+ private DynamicForm getEveryNMinutesForm() {
+ DynamicForm form = new DynamicForm();
+ form.setValuesManager(valuesManager);
+ form.setPadding(10);
+ form.setIsGroup(true);
+ form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_everyNMinutes());
+ form.addItemChangedHandler(this);
+
+ form.setWrapItemTitles(false);
+ form.setNumCols(2);
+
+ IntegerItem everyNMinutes = new IntegerItem();
+ everyNMinutes.setName("minuteInterval");
+ everyNMinutes.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_minuteInterval());
+ everyNMinutes.setValue(60);
+
+ form.setItems(everyNMinutes);
+ return form;
+ }
+
+ private DynamicForm getHourlyForm() {
+ DynamicForm form = new DynamicForm();
+ form.setValuesManager(valuesManager);
+ form.setPadding(10);
+ form.setIsGroup(true);
+ form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_hourly());
+ form.addItemChangedHandler(this);
+
+ form.setWrapItemTitles(false);
+ form.setNumCols(2);
+
+ IntegerItem minuteOfHour = new IntegerItem();
+ minuteOfHour.setName("minuteOfHour");
+ minuteOfHour.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_minuteOfHour());
+ minuteOfHour.setValue(5);
+
+ form.setItems(minuteOfHour);
+ return form;
+ }
+
+ private DynamicForm getDailyForm() {
+ DynamicForm form = new DynamicForm();
+ form.setValuesManager(valuesManager);
+ form.setPadding(10);
+ form.setWrapItemTitles(false);
+ form.setIsGroup(true);
+ form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_daily());
+ form.addItemChangedHandler(this);
+
+ TimeItem timeOfDay = new TimeItem("timeOfDay", MSG.view_operationCreateWizard_schedulingStep_label_timeOfDay());
+ timeOfDay.setValue(new Date());
+ timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
+ timeOfDay.setUseMask(true);
+
+ form.setItems(timeOfDay);
+ return form;
+ }
+
+ private DynamicForm getWeeklyForm() {
+ DynamicForm form = new DynamicForm();
+ form.setValuesManager(valuesManager);
+ form.setPadding(10);
+ form.setIsGroup(true);
+ form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_weekly());
+ form.addItemChangedHandler(this);
+
+ form.setWrapItemTitles(false);
+
+ TimeItem timeOfDay = new TimeItem("dayOfWeek", MSG.view_operationCreateWizard_schedulingStep_label_dayOfWeek());
+ timeOfDay.setValue(new Date());
+ timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
+ timeOfDay.setUseMask(true);
+
+ ExecutionSchedule.DayOfWeek[] daysOfWeek = ExecutionSchedule.DayOfWeek.values();
+ List<String> dayList = new ArrayList<String>();
+ for (ExecutionSchedule.DayOfWeek dayOfWeek : daysOfWeek) {
+ dayList.add(dayOfWeek.name());
+ }
+ FormItem[] items = new FormItem[8];
+ items[0] = timeOfDay;
+ int i = 1;
+ for (String day : dayList) {
+ CheckboxItem dayItem = new CheckboxItem(day);
+ dayItem.setShowTitle(false);
+ items[i++] = dayItem;
+ }
+ form.setItems(items);
+ return form;
+ }
+
+ private DynamicForm getMonthlyForm() {
+ DynamicForm form = new DynamicForm();
+ form.setValuesManager(valuesManager);
+ form.setPadding(10);
+ form.setWrapItemTitles(false);
+ form.setIsGroup(true);
+ form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_monthly());
+ form.addItemChangedHandler(this);
+
+ IntegerItem dayItem = new IntegerItem();
+ dayItem.setName("dayOfMonth");
+ dayItem.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_dayOfMonth());
+ dayItem.setValue(1);
+
+ TimeItem timeOfDay = new TimeItem("timeOfDay", MSG.view_operationCreateWizard_schedulingStep_label_timeOfDay());
+ timeOfDay.setValue(new Date());
+ timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
+ timeOfDay.setUseMask(true);
+
+ form.setItems(dayItem, timeOfDay);
+ return form;
+ }
+
+ public boolean nextPage() {
+ return true; // TODO: Implement this method.
+ }
+
+ public String getName() {
+ return MSG.view_operationCreateWizard_schedulingStep_name();
+ }
+
+ public void onItemChanged(ItemChangedEvent itemChangeEvent) {
+
+ executionSchedule.setStart(ExecutionSchedule.Start.valueOf(valuesManager.getValueAsString("start")));
+ executionSchedule.setRecurr(ExecutionSchedule.Recurr.valueOf(valuesManager.getValueAsString("recurr")));
+
+ Date onceDate = (Date) valuesManager.getValues().get("onceStartDate");
+ executionSchedule.setOnceDateTime(onceDate);
+
+ executionSchedule.setMinuteInterval(Integer.parseInt(valuesManager.getValueAsString("minuteInterval")));
+
+ executionSchedule.setMinuteInHour(Integer.parseInt(valuesManager.getValueAsString("minuteOfHour")));
+
+ executionSchedule.setTimeOfDay((Date) valuesManager.getValues().get("timeOfDay"));
+
+ HashSet<ExecutionSchedule.DayOfWeek> selectedDays = new HashSet<ExecutionSchedule.DayOfWeek>(); //.noneOf(ExecutionSchedule.DayOfWeek.class);
+ for (ExecutionSchedule.DayOfWeek d : EnumSet.allOf(ExecutionSchedule.DayOfWeek.class)) {
+ if (valuesManager.getValues().containsKey(d.name())) {
+ selectedDays.add(d);
+ }
+ }
+ executionSchedule.setDaysOfWeek(selectedDays);
+
+ executionSchedule.setDayOfMonth(Integer.parseInt(valuesManager.getValueAsString("dayOfMonth")));
+
+ executionSchedule.setStartDate((Date) valuesManager.getValues().get("startDate"));
+
+ if ("Never".equals(valuesManager.getValues().get("endType"))) {
+ executionSchedule.setEndDate(null);
+ } else {
+ executionSchedule.setEndDate((Date) valuesManager.getValues().get("endDate"));
+ }
+
+ form.setValue("message", executionSchedule.getMessage());
+ }
+
+ private LinkedHashMap<String, String> enumValueMap(Class<? extends Enum> e) {
+ LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
+ for (Object o : EnumSet.allOf(e)) {
+ Enum v = (Enum) o;
+ map.put(v.name(), v.name()); // localize
+ }
+ return map;
+ }
+
+ public ExecutionSchedule getExecutionSchedule() {
+ return executionSchedule;
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
index 1d1c754..9cd3ded 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/ResourceGroupDetailView.java
@@ -58,11 +58,10 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.inventory.M
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.monitoring.traits.TraitsView;
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.summary.ActivityView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSearchView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
/**
- * Right panel of the Resource view (#ResourceGroup/*).
+ * Right panel of the Resource Group view (#ResourceGroup/*).
*
* @author Jay Shaughnessy
* @author Ian Springer
@@ -94,8 +93,8 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
private SubTab inventoryMembers;
private SubTab inventoryConn;
private SubTab inventoryConnHistory;
- private SubTab opHistory;
- private SubTab opSched;
+ private SubTab operationsHistory;
+ private SubTab operationsSchedule;
private SubTab alertHistory;
private SubTab alertDef;
private SubTab configCurrent;
@@ -198,11 +197,11 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), new ViewName("Operations", MSG
.view_tabs_common_operations()), "/images/icons/Operation_grey_16.png");
- this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), new ViewName("History", MSG
+ this.operationsSchedule = new SubTab(operationsTab.extendLocatorId("Schedule"), new ViewName("Schedule", MSG
+ .view_tabs_common_schedule()), null);
+ this.operationsHistory = new SubTab(operationsTab.extendLocatorId("History"), new ViewName("History", MSG
.view_tabs_common_history()), null);
- this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), new ViewName("Scheduled", MSG
- .view_tabs_common_scheduled()), null);
- operationsTab.registerSubTabs(this.opHistory, this.opSched);
+ operationsTab.registerSubTabs(this.operationsHistory, this.operationsSchedule);
tabs.add(operationsTab);
configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), new ViewName("Configuration",
@@ -296,10 +295,10 @@ public class ResourceGroupDetailView extends AbstractTwoLevelTabSetView<Resource
private void updateOperationsTab(int groupId, GroupCategory groupCategory, Set<ResourceTypeFacet> facets) {
if (updateTab(this.operationsTab, groupCategory == GroupCategory.COMPATIBLE
&& facets.contains(ResourceTypeFacet.OPERATION), true)) {
- updateSubTab(this.operationsTab, this.opHistory, new FullHTMLPane(this.opHistory.extendLocatorId("View"),
- "/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true);
- updateSubTab(this.operationsTab, this.opSched, new FullHTMLPane(this.opSched.extendLocatorId("View"),
+ updateSubTab(this.operationsTab, this.operationsSchedule, new FullHTMLPane(this.operationsSchedule.extendLocatorId("View"),
"/rhq/group/operation/groupOperationSchedules-plain.xhtml?groupId=" + groupId), true, true);
+ updateSubTab(this.operationsTab, this.operationsHistory, new FullHTMLPane(this.operationsHistory.extendLocatorId("View"),
+ "/rhq/group/operation/groupOperationHistory-plain.xhtml?groupId=" + groupId), true, true);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java
index 93803a5..e957d7d 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/NewResourceTreeView.java
@@ -66,7 +66,7 @@ import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.gwt.ResourceTypeGWTServiceAsync;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.ResourceSelectListener;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationCreateWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.factory.ResourceFactoryCreateWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
index 5fab7c4..de120f5 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceDetailView.java
@@ -60,7 +60,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.inventory.ResourceResourceAgentView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.schedules.SchedulesView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.traits.TraitsView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.summary.ActivityView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
import org.rhq.enterprise.gui.coregui.client.util.message.Message;
@@ -72,6 +72,7 @@ import org.rhq.enterprise.gui.coregui.client.util.message.Message;
* @author Ian Springer
*/
public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceComposite, ResourceTitleBar> {
+
private static final String BASE_VIEW_PATH = "Resource";
private Integer resourceId;
@@ -103,8 +104,8 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
private SubTab inventoryConnHistory;
private SubTab inventoryGroups;
private SubTab inventoryAgent;
- private SubTab opHistory;
- private SubTab opSched;
+ private SubTab operationsHistory;
+ private SubTab operationsSchedule;
private SubTab alertHistory;
private SubTab alertDef;
private SubTab configCurrent;
@@ -186,11 +187,11 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
operationsTab = new TwoLevelTab(getTabSet().extendLocatorId("Operations"), new ViewName("Operations", MSG
.view_tabs_common_operations()), "/images/icons/Operation_grey_16.png");
- this.opHistory = new SubTab(operationsTab.extendLocatorId("History"), new ViewName("History", MSG
+ this.operationsSchedule = new SubTab(operationsTab.extendLocatorId("Schedule"), new ViewName("Schedule", MSG
+ .view_tabs_common_schedule()), null);
+ this.operationsHistory = new SubTab(operationsTab.extendLocatorId("History"), new ViewName("History", MSG
.view_tabs_common_history()), null);
- this.opSched = new SubTab(operationsTab.extendLocatorId("Scheduled"), new ViewName("Scheduled", MSG
- .view_tabs_common_scheduled()), null);
- operationsTab.registerSubTabs(this.opHistory, this.opSched);
+ operationsTab.registerSubTabs(this.operationsHistory, this.operationsSchedule);
tabs.add(operationsTab);
configurationTab = new TwoLevelTab(getTabSet().extendLocatorId("Configuration"), new ViewName("Configuration",
@@ -341,10 +342,10 @@ public class ResourceDetailView extends AbstractTwoLevelTabSetView<ResourceCompo
// 3) operation arguments/results become read-only configuration data in the history details pop-up
// 4) user can navigate to the group operation that spawned this resource operation history, if appropriate
// note: enabled operation execution/schedules from left-nav, if it doesn't already exist
- updateSubTab(this.operationsTab, this.opHistory, OperationHistoryView.getResourceHistoryView(operationsTab
+ updateSubTab(this.operationsTab, this.operationsHistory, new ResourceOperationHistoryListView(operationsTab
.extendLocatorId("HistoryView"), this.resourceComposite), true, true);
- updateSubTab(this.operationsTab, this.opSched, new FullHTMLPane(this.opSched.extendLocatorId("View"),
+ updateSubTab(this.operationsTab, this.operationsSchedule, new FullHTMLPane(this.operationsSchedule.extendLocatorId("View"),
"/rhq/resource/operation/resourceOperationSchedules-plain.xhtml?id=" + resource.getId()), true, true);
}
}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
index 35c6c21..dcbfaea 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/ResourceTreeView.java
@@ -82,7 +82,7 @@ import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGro
import org.rhq.enterprise.gui.coregui.client.inventory.groups.detail.ResourceGroupDetailView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.AutoGroupTreeNode;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.ResourceTreeDatasource.ResourceTreeNode;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationCreateWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.factory.ResourceFactoryCreateWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.factory.ResourceFactoryImportWizard;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
deleted file mode 100644
index a41e68a..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryDataSource.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation;
-
-import java.util.Date;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.data.DSRequest;
-import com.smartgwt.client.data.DSResponse;
-import com.smartgwt.client.data.DataSourceField;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.data.fields.DataSourceTextField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-
-import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.gwt.OperationGWTServiceAsync;
-import org.rhq.enterprise.gui.coregui.client.util.RPCDataSource;
-
-/**
- * @author Greg Hinkle
- */
-public class OperationHistoryDataSource extends RPCDataSource<ResourceOperationHistory> {
-
- public static abstract class Field {
- public static final String ID = "id";
- public static final String OPERATION_NAME = "operationName";
- public static final String RESOURCE = "resource";
- public static final String STATUS = "status";
- public static final String STARTED_TIME = "startedTime";
- public static final String CREATED_TIME = "createdTime";
- public static final String DURATION = "duration";
- public static final String SUBJECT = "subject";
- public static final String OPERATION_DEFINITION = "operationDefinition";
- public static final String ERROR_MESSAGE = "errorMessage";
- public static final String PARAMETERS = "parameters";
- }
-
- public static abstract class CriteriaField {
- public static final String RESOURCE_ID = "resourceId";
- }
-
- private OperationGWTServiceAsync operationService = GWTServiceLookup.getOperationService();
-
- public OperationHistoryDataSource() {
- List<DataSourceField> fields = addDataSourceFields();
- addFields(fields);
- }
-
- @Override
- protected List<DataSourceField> addDataSourceFields() {
- List<DataSourceField> fields = super.addDataSourceFields();
-
- /*
- DataSourceIntegerField idField = new DataSourceIntegerField(Field.ID);
- idField.setPrimaryKey(true);
- fields.add(idField);
- */
-
- DataSourceTextField nameField = new DataSourceTextField(Field.OPERATION_NAME);
- fields.add(nameField);
-
- /*
- DataSourceTextField resourceField = new DataSourceTextField(Field.RESOURCE);
- fields.add(resourceField);
-
- DataSourceTextField statusField = new DataSourceTextField(Field.STATUS);
- fields.add(statusField);
-
- DataSourceTextField startedField = new DataSourceTextField(Field.STARTED_TIME);
- startedField.setType(FieldType.DATETIME);
- fields.add(startedField);
- */
-
- return fields;
- }
-
- @Override
- protected void executeFetch(final DSRequest request, final DSResponse response) {
- ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
-
- if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
- criteria.addFilterResourceIds(Integer.parseInt((String) request.getCriteria().getValues().get(
- CriteriaField.RESOURCE_ID)));
- }
-
- criteria.setPageControl(getPageControl(request));
-
- operationService.findResourceOperationHistoriesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceOperationHistory>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(), caught);
- }
-
- public void onSuccess(PageList<ResourceOperationHistory> result) {
- response.setData(buildRecords(result));
- processResponse(request.getRequestId(), response);
- }
- });
- }
-
- @Override
- public ResourceOperationHistory copyValues(Record from) {
- throw new UnsupportedOperationException("ResourceOperationHistory is read only.");
- }
-
- @Override
- public ListGridRecord copyValues(ResourceOperationHistory from) {
- ListGridRecord record = new ListGridRecord();
- record.setAttribute(Field.ID, from.getId());
- record.setAttribute(Field.CREATED_TIME, from.getCreatedTime());
- record.setAttribute(Field.STARTED_TIME, new Date(from.getStartedTime()));
- record.setAttribute(Field.DURATION, from.getDuration());
- record.setAttribute(Field.RESOURCE, from.getResource());
- record.setAttribute(Field.SUBJECT, from.getSubjectName());
- record.setAttribute(Field.OPERATION_DEFINITION, from.getOperationDefinition());
- record.setAttribute(Field.OPERATION_NAME, from.getOperationDefinition().getDisplayName());
- record.setAttribute(Field.ERROR_MESSAGE, from.getErrorMessage());
- record.setAttribute(Field.STATUS, from.getStatus().name());
- record.setAttribute(Field.PARAMETERS, from.getParameters());
-
- return record;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
deleted file mode 100644
index fb649cc..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationHistoryView.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation;
-
-import java.util.EnumSet;
-
-import com.smartgwt.client.data.Criteria;
-import com.smartgwt.client.data.Record;
-import com.smartgwt.client.types.Alignment;
-import com.smartgwt.client.types.DateDisplayFormat;
-import com.smartgwt.client.types.ListGridFieldType;
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.events.CloseClientEvent;
-import com.smartgwt.client.widgets.grid.CellFormatter;
-import com.smartgwt.client.widgets.grid.HoverCustomizer;
-import com.smartgwt.client.widgets.grid.ListGridField;
-import com.smartgwt.client.widgets.grid.ListGridRecord;
-import com.smartgwt.client.widgets.grid.events.RecordClickEvent;
-import com.smartgwt.client.widgets.grid.events.RecordClickHandler;
-import com.smartgwt.client.widgets.menu.IMenuButton;
-import com.smartgwt.client.widgets.menu.Menu;
-import com.smartgwt.client.widgets.menu.MenuItem;
-import com.smartgwt.client.widgets.menu.events.ClickHandler;
-import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
-
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.operation.OperationRequestStatus;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.core.domain.resource.ResourceType;
-import org.rhq.core.domain.resource.composite.ResourceComposite;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.components.table.TableSection;
-import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create.OperationCreateWizard;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.detail.OperationDetailsView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-
-/**
- * @author Greg Hinkle
- * @author John Mazzitelli
- */
-public class OperationHistoryView extends TableSection<OperationHistoryDataSource> {
- public static final ViewName VIEW_ID = new ViewName("RecentOperations", MSG.common_title_recent_operations());
-
- private ResourceComposite composite;
-
- public OperationHistoryView(String locatorId) {
- super(locatorId, VIEW_ID.getTitle());
- setWidth100();
- setHeight100();
-
- setDataSource(new OperationHistoryDataSource());
- }
-
- public OperationHistoryView(String locatorId, ResourceComposite resourceComposite) {
- super(locatorId, VIEW_ID.getTitle(), new Criteria(OperationHistoryDataSource.CriteriaField.RESOURCE_ID,
- String.valueOf(resourceComposite.getResource().getId())));
- this.composite = resourceComposite;
-
- setDataSource(new OperationHistoryDataSource());
- }
-
- @Override
- protected void configureTable() {
- ListGridField idField = new ListGridField(OperationHistoryDataSource.Field.ID, MSG.common_title_id());
-
- ListGridField opNameField = new ListGridField(OperationHistoryDataSource.Field.OPERATION_NAME,
- MSG.dataSource_operationHistory_operationName());
-
- ListGridField subjectField = new ListGridField(OperationHistoryDataSource.Field.SUBJECT,
- MSG.common_title_user());
-
- ListGridField statusField = new ListGridField(OperationHistoryDataSource.Field.STATUS,
- MSG.common_title_status());
- statusField.setAlign(Alignment.CENTER);
- statusField.setCellAlign(Alignment.CENTER);
- statusField.setShowHover(true);
- statusField.setHoverCustomizer(new HoverCustomizer() {
- @Override
- public String hoverHTML(Object value, ListGridRecord record, int rowNum, int colNum) {
- String statusStr = record.getAttribute(OperationHistoryDataSource.Field.STATUS);
- OperationRequestStatus status = OperationRequestStatus.valueOf(statusStr);
- switch (status) {
- case SUCCESS: {
- return MSG.common_status_success();
- }
- case FAILURE: {
- return MSG.common_status_failed();
- }
- case INPROGRESS: {
- return MSG.common_status_inprogress();
- }
- case CANCELED: {
- return MSG.common_status_canceled();
- }
- }
- return "unknown"; // should never get here
- }
- });
- statusField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- OperationRequestStatus status = OperationRequestStatus.valueOf((String) o);
- String icon = ImageManager.getOperationResultsIcon(status);
- return Canvas.imgHTML(icon, 16, 16);
- }
- });
- statusField.addRecordClickHandler(new RecordClickHandler() {
- @Override
- public void onRecordClick(RecordClickEvent event) {
- Record record = event.getRecord();
- String statusStr = record.getAttribute(OperationHistoryDataSource.Field.STATUS);
- OperationRequestStatus status = OperationRequestStatus.valueOf(statusStr);
- if (status == OperationRequestStatus.FAILURE) {
- final Window winModal = new LocatableWindow(OperationHistoryView.this
- .extendLocatorId("statusDetailsWin"));
- winModal.setTitle(MSG.common_title_details());
- winModal.setOverflow(Overflow.VISIBLE);
- winModal.setShowMinimizeButton(false);
- winModal.setShowMaximizeButton(true);
- winModal.setIsModal(true);
- winModal.setShowModalMask(true);
- winModal.setAutoSize(true);
- winModal.setAutoCenter(true);
- winModal.setShowResizer(true);
- winModal.setCanDragResize(true);
- winModal.centerInPage();
- winModal.addCloseClickHandler(new CloseClickHandler() {
- @Override
- public void onCloseClick(CloseClientEvent event) {
- winModal.markForDestroy();
- }
- });
-
- LocatableHTMLPane htmlPane = new LocatableHTMLPane(OperationHistoryView.this
- .extendLocatorId("statusDetailsPane"));
- htmlPane.setMargin(10);
- htmlPane.setDefaultWidth(500);
- htmlPane.setDefaultHeight(400);
- String errorMsg = record.getAttribute(OperationHistoryDataSource.Field.ERROR_MESSAGE);
- if (errorMsg == null) {
- errorMsg = MSG.common_status_failed();
- }
- htmlPane.setContents("<pre>" + errorMsg + "</pre>");
- winModal.addItem(htmlPane);
- winModal.show();
- }
- }
- });
-
- ListGridField startedTimeField = new ListGridField(OperationHistoryDataSource.Field.STARTED_TIME,
- MSG.dataSource_operationHistory_startedTime());
- startedTimeField.setType(ListGridFieldType.DATE);
- startedTimeField.setDateFormatter(DateDisplayFormat.TOLOCALESTRING);
- startedTimeField.setAlign(Alignment.LEFT);
- startedTimeField.setCellAlign(Alignment.LEFT);
-
- final Resource resource = this.composite.getResource();
-
- if (resource == null) { // if null, we aren't viewing op history for a single resource
- ListGridField resourceField = new ListGridField(OperationHistoryDataSource.Field.RESOURCE,
- MSG.common_title_resource());
- resourceField.setAlign(Alignment.LEFT);
- resourceField.setCellAlign(Alignment.LEFT);
- resourceField.setCellFormatter(new CellFormatter() {
- public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
- Resource res = (Resource) o;
- return "<a href=\"#Resource/" + res.getId() + "\">" + res.getName() + "</a>";
- }
- });
-
- idField.setWidth(10);
- opNameField.setWidth("25%");
- subjectField.setWidth("25%");
- statusField.setWidth(50);
- startedTimeField.setWidth("25%");
- resourceField.setWidth("25%");
-
- setListGridFields(idField, opNameField, startedTimeField, subjectField, statusField, resourceField);
- } else {
- idField.setWidth(10);
- opNameField.setWidth("34%");
- subjectField.setWidth("33%");
- statusField.setWidth(50);
- startedTimeField.setWidth("33%");
-
- setListGridFields(idField, opNameField, startedTimeField, subjectField, statusField);
- }
-
- if (resource != null && composite.getResourcePermission().isControl()) {
- final Menu operationMenu = new LocatableMenu(this.extendLocatorId("Operation"));
- ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
- EnumSet.of(ResourceTypeRepository.MetadataType.operations),
- new ResourceTypeRepository.TypeLoadedCallback() {
- public void onTypesLoaded(ResourceType type) {
- for (final OperationDefinition od : type.getOperationDefinitions()) {
- MenuItem menuItem = new MenuItem(od.getDisplayName());
- operationMenu.addItem(menuItem);
- menuItem.addClickHandler(new ClickHandler() {
- public void onClick(MenuItemClickEvent event) {
- new OperationCreateWizard(resource, od).startOperationWizard();
- }
- });
- }
- }
- });
-
- IMenuButton operationsButton = new LocatableIMenuButton(this.extendLocatorId("Run"),
- MSG.view_operationHistoryList_button_runOperation(), operationMenu);
- operationsButton.setShowMenuBelow(false);
- operationsButton.setAutoFit(true);
- addExtraWidget(operationsButton);
- }
-
- }
-
- @Override
- protected String getDetailsLinkColumnName() {
- return OperationHistoryDataSource.Field.OPERATION_NAME;
- }
-
- @Override
- public Canvas getDetailsView(int id) {
- OperationDetailsView detailsView = new OperationDetailsView(this.extendLocatorId("Details"));
- return detailsView;
- }
-
- public static OperationHistoryView getResourceHistoryView(String locatorId, ResourceComposite resource) {
- return new OperationHistoryView(locatorId, resource);
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationWizard.java
deleted file mode 100644
index 47d7dae..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/OperationWizard.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation;
-
-import org.rhq.core.domain.resource.Resource;
-
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.events.CloseClientEvent;
-import com.smartgwt.client.widgets.layout.VLayout;
-
-/**
- * @author Greg Hinkle
- */
-// TODO (ips, 11/17/10): Can this class be deleted?
-public class OperationWizard extends VLayout{
-
- private Resource resource;
- private String operation;
-
- public OperationWizard(Resource resource, String operation) {
- this.resource = resource;
- this.operation = operation;
- }
-
- public static void startPopupOperationWizard(Resource resource, String operation) {
- final Window dialog = new Window();
- dialog.setTitle("Execute Operation");
- dialog.setWidth(800);
- dialog.setHeight(800);
- dialog.setIsModal(true);
- dialog.setShowModalMask(true);
- dialog.setCanDragResize(true);
- dialog.setShowResizer(true);
- dialog.centerInPage();
- dialog.addCloseClickHandler(new CloseClickHandler() {
- public void onCloseClick(CloseClientEvent closeClientEvent) {
- dialog.destroy();
- }
- });
- dialog.addItem(new OperationWizard(resource, operation));
- dialog.show();
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/ExecutionSchedule.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/ExecutionSchedule.java
deleted file mode 100644
index 6422174..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/ExecutionSchedule.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.HashSet;
-
-import com.google.gwt.i18n.client.DateTimeFormat;
-
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.Messages;
-
-/**
- * @author Greg Hinkle
- */
-public class ExecutionSchedule implements Serializable {
-
- private static final Messages MSG = CoreGUI.getMessages();
-
- public enum Start {
- Immediately, Future
- };
-
- public enum End {
- Never, EndOn
- };
-
- public enum Recurr {
- Once, EveryNMinutes, Hourly, Daily, Weekly, Monthly
- };
-
- public enum DayOfWeek {
- Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday
- };
-
- private Start start = Start.Immediately;
-
- // start.Future
- private Recurr recurr = Recurr.Once;
-
- // Once
- private Date onceDateTime;
-
-
- // EveryNMinutes
- private Integer minuteInterval;
-
-
- // Hourly
- private Integer minuteInHour;
-
-
- // Daily
- private Date timeOfDay;
-
-
- // Weekly
- // Time of Day above
- private HashSet<DayOfWeek> daysOfWeek; // Can't use EnumSet because it doesn't have default instantiator
-
-
- // Monthly
- // Time of Day above
- private Integer dayOfMonth;
-
-
- // Used for all start.Future except for once
- private Date startDate;
-
- private Date endDate;
-
-
- public Start getStart() {
- return start;
- }
-
- public void setStart(Start start) {
- this.start = start;
- }
-
- public Recurr getRecurr() {
- return recurr;
- }
-
- public void setRecurr(Recurr recurr) {
- this.recurr = recurr;
- }
-
- public Date getOnceDateTime() {
- return onceDateTime;
- }
-
- public void setOnceDateTime(Date onceDateTime) {
- this.onceDateTime = onceDateTime;
- }
-
- public Integer getMinuteInterval() {
- return minuteInterval;
- }
-
- public void setMinuteInterval(Integer minuteInterval) {
- this.minuteInterval = minuteInterval;
- }
-
- public Integer getMinuteInHour() {
- return minuteInHour;
- }
-
- public void setMinuteInHour(Integer minuteInHour) {
- this.minuteInHour = minuteInHour;
- }
-
- public HashSet<DayOfWeek> getDaysOfWeek() {
- return daysOfWeek;
- }
-
- public void setDaysOfWeek(HashSet<DayOfWeek> daysOfWeek) {
- this.daysOfWeek = daysOfWeek;
- }
-
- public Integer getDayOfMonth() {
- return dayOfMonth;
- }
-
- public void setDayOfMonth(Integer dayOfMonth) {
- this.dayOfMonth = dayOfMonth;
- }
-
- public Date getStartDate() {
- return startDate;
- }
-
- public void setStartDate(Date startDate) {
- this.startDate = startDate;
- }
-
- public Date getEndDate() {
- return endDate;
- }
-
- public void setEndDate(Date endDate) {
- this.endDate = endDate;
- }
-
- public Date getTimeOfDay() {
- return timeOfDay;
- }
-
- public void setTimeOfDay(Date timeOfDay) {
- this.timeOfDay = timeOfDay;
- }
-
- public String getMessage() {
- DateTimeFormat dateFormat = DateTimeFormat.getMediumDateFormat();
- DateTimeFormat timeFormat = DateTimeFormat.getMediumTimeFormat();
-
- String message;
- switch (start) {
-
- case Immediately:
- message = MSG.view_operationCreateWizard_executionSchedule_willExecuteOnce(
- MSG.view_operationCreateWizard_executionSchedule_immediately());
- break;
-
- case Future:
- if (recurr == Recurr.Once) {
- message = MSG.view_operationCreateWizard_executionSchedule_willExecuteOnce(
- MSG.view_operationCreateWizard_executionSchedule_onceAtGivenTime(onceDateTime.toString()));
- } else {
- String recurrenceMessage;
- switch (recurr) {
- case EveryNMinutes:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyNMinutes(minuteInterval.toString());
- break;
- case Hourly:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyHourOnNthMinute(suffix(minuteInHour));
- break;
- case Daily:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyDayAtGivenTime(timeFormat.format(timeOfDay));
- break;
- case Weekly:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyWeekOnGivenDayAtGivenTime(daysOfWeek.toString(), timeFormat.format(timeOfDay));
- break;
- case Monthly:
- recurrenceMessage = MSG.view_operationCreateWizard_executionSchedule_everyMonthOnNthDayAtGivenTime(suffix(dayOfMonth), timeFormat.format(timeOfDay));
- break;
- default:
- recurrenceMessage = "";
- }
-
- if (endDate != null) {
- message = MSG.view_operationCreateWizard_executionSchedule_willExecuteRecurringWithEnd(
- recurrenceMessage, dateFormat.format(startDate), dateFormat.format(endDate));
- } else {
- message = MSG.view_operationCreateWizard_executionSchedule_willExecuteRecurring(
- recurrenceMessage, dateFormat.format(startDate));
- }
- }
- break;
-
- default:
- message = "";
-
- }
-
- return message;
- }
-
-
- public String getCronString() {
-
- /* Cron fields
- 1. Seconds
- 2. Minutes
- 3. Hours
- 4. Day-of-Month
- 5. Month
- 6. Day-of-Week
- 7. Year (optional field)
- */
-
- String cseconds, cminutes = null, chours = null, cdayOfMonth = null, cmonth = null, cdayOfWeek = null;
-
- cseconds = "0";
-
- switch (start) {
-
- case Immediately:
- return null; // No cron string for immediate execution
-
- case Future:
-
- if (recurr == Recurr.Once) {
- return null; // No cron string for non recurring
- } else {
- switch (recurr) {
- case EveryNMinutes:
- cminutes = "0/" + minuteInterval;
- chours = cdayOfMonth = cmonth = "*";
- cdayOfWeek = "?";
- break;
- case Hourly:
- cminutes = "" + minuteInHour;
- chours = "*";
- cdayOfMonth = cmonth = cdayOfWeek = "*";
- break;
- case Daily:
- cminutes = "" + timeOfDay.getMinutes();
- chours = "" + timeOfDay.getHours();
- cdayOfMonth = cmonth = cdayOfWeek = "*";
- break;
- case Weekly:
- cminutes = "" + timeOfDay.getMinutes();
- chours = "" + timeOfDay.getHours();
- cdayOfMonth = "?";
- cmonth = "*";
- cdayOfWeek = daysOfWeek.toString();
- break;
- case Monthly:
- cminutes = "" + timeOfDay.getMinutes();
- chours = "" + timeOfDay.getHours();
- cdayOfMonth = "" + dayOfMonth;
- cmonth = "*";
- cdayOfWeek = "?";
- break;
- }
- }
- break;
- }
- return cseconds + " " + cminutes + " " + chours + " " + cdayOfMonth + " " + cmonth + " " + cdayOfWeek;
-
- }
-
- public static String suffix(int number) {
- String result;
- String numberAsString = String.valueOf(number);
- int last = number % 10;
- switch (last) {
- case 1:
- result = MSG.common_val_n1st(numberAsString);
- break;
- case 2:
- result = MSG.common_val_n2nd(numberAsString);
- break;
- case 3:
- result = MSG.common_val_n3rd(numberAsString);
- break;
- default:
- result = MSG.common_val_nth(numberAsString);
- }
- return result;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java
deleted file mode 100644
index 7afe889..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationCreateWizard.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.widgets.IButton;
-import com.smartgwt.client.widgets.events.ClickEvent;
-import com.smartgwt.client.widgets.events.ClickHandler;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.resource.Resource;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizard;
-import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardStep;
-import org.rhq.enterprise.gui.coregui.client.components.wizard.WizardView;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.util.message.Message;
-
-/**
- * @author Greg Hinkle
- */
-public class OperationCreateWizard extends AbstractWizard {
-
- private Resource resource;
- private OperationDefinition operationDefinition;
-
- private OperationParametersStep parametersStep;
- private OperationSchedulingStep schedulingStep;
-
- private WizardView view;
-
- private IButton executeNowButton;
- private IButton executeButton;
-
- public OperationCreateWizard(Resource resource, OperationDefinition operationDefinition) {
- this.resource = resource;
- this.operationDefinition = operationDefinition;
- }
-
- public void startOperationWizard() {
-
- parametersStep = new OperationParametersStep(operationDefinition);
- schedulingStep = new OperationSchedulingStep();
-
- ArrayList<WizardStep> steps = new ArrayList<WizardStep>();
- steps.add(parametersStep);
- steps.add(schedulingStep);
- setSteps(steps);
-
- executeNowButton = new IButton(MSG.view_operationCreateWizard_button_executeImmediately());
- executeNowButton.setAutoFit(true);
- executeNowButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- execute();
- }
- });
-
- executeButton = new IButton(MSG.view_operationCreateWizard_button_execute());
- executeButton.addClickHandler(new ClickHandler() {
- public void onClick(ClickEvent clickEvent) {
- execute();
- }
- });
-
- view = new WizardView(this);
- view.displayDialog();
- }
-
- public String getWindowTitle() {
- return MSG.view_operationCreateWizard_title();
- }
-
- public String getTitle() {
- return MSG.view_operationCreateWizard_header(operationDefinition.getDisplayName(), resource.getName());
- }
-
- public String getSubtitle() {
- return operationDefinition.getDescription();
- }
-
- public List<IButton> getCustomButtons(int step) {
- switch (step) {
- case 0:
- return Arrays.asList(executeNowButton);
- case 1:
- return Arrays.asList(executeButton);
- default:
- return Collections.emptyList();
- }
- }
-
- private void execute() {
- Configuration parameters = parametersStep.getParameterConfiguration();
- final ExecutionSchedule schedule = schedulingStep.getExecutionSchedule();
-
- // TODO: get the description and timeout from user input
- String description = "";
- int timeout = 0;
-
- AsyncCallback<Void> operationCallback = new AsyncCallback<Void>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler().handleError(MSG.view_operationCreateWizard_error_scheduleOperationFailure(),
- caught);
- }
-
- public void onSuccess(Void result) {
- String opName = operationDefinition.getDisplayName();
- String cron = schedule.getCronString();
- if (cron == null) {
- cron = MSG.common_val_na();
- }
- String concise = MSG.view_operationCreateWizard_message_scheduleOperationSuccess_short(opName);
- String message = MSG.view_operationCreateWizard_message_scheduleOperationSuccess(opName, String
- .valueOf(resource.getId()), cron);
-
- CoreGUI.getMessageCenter().notify(new Message(concise, message, Message.Severity.Info));
- }
- };
-
- if (schedule.getStart() == ExecutionSchedule.Start.Immediately) {
- GWTServiceLookup.getOperationService().invokeResourceOperation(resource.getId(),
- operationDefinition.getName(), parameters, description, timeout, operationCallback);
- } else {
- GWTServiceLookup.getOperationService().scheduleResourceOperation(resource.getId(),
- operationDefinition.getName(), parameters, description, timeout, schedule.getCronString(),
- operationCallback);
- }
-
- view.closeDialog();
- }
-
- public void cancel() {
- // TODO: revert back to original state
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationParametersStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationParametersStep.java
deleted file mode 100644
index 05489c8..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationParametersStep.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create;
-
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.HTMLFlow;
-
-import org.rhq.core.domain.configuration.Configuration;
-import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
-
-/**
- * @author Greg Hinkle
- */
-public class OperationParametersStep extends AbstractWizardStep {
-
- private OperationDefinition definition;
-
- private ConfigurationEditor configurationEditor;
-
- public OperationParametersStep(OperationDefinition operationDefinition) {
- super();
- this.definition = operationDefinition;
- }
-
- public Canvas getCanvas() {
- if (definition.getParametersConfigurationDefinition() != null) {
- if (configurationEditor == null) {
- ConfigurationDefinition configurationDefinition = definition.getParametersConfigurationDefinition();
- Configuration defaultConfiguration = configurationDefinition.getDefaultTemplate() != null ? configurationDefinition
- .getDefaultTemplate().createConfiguration()
- : new Configuration();
- configurationEditor = new ConfigurationEditor("OperationParams", configurationDefinition,
- defaultConfiguration);
- }
- return configurationEditor;
- } else {
- return new HTMLFlow(MSG.view_operationCreateWizard_parametersStep_noParameters());
- }
- }
-
- public boolean nextPage() {
- return true; // TODO: Implement this method.
- }
-
- public String getName() {
- return MSG.view_operationCreateWizard_parametersStep_name();
- }
-
- public Configuration getParameterConfiguration() {
- return configurationEditor != null ? configurationEditor.getConfiguration() : null;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationSchedulingStep.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationSchedulingStep.java
deleted file mode 100644
index f90fd69..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/create/OperationSchedulingStep.java
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.create;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-
-import com.smartgwt.client.types.FormErrorOrientation;
-import com.smartgwt.client.types.TimeFormatter;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.FormItemIfFunction;
-import com.smartgwt.client.widgets.form.ValuesManager;
-import com.smartgwt.client.widgets.form.events.ItemChangedEvent;
-import com.smartgwt.client.widgets.form.events.ItemChangedHandler;
-import com.smartgwt.client.widgets.form.fields.CanvasItem;
-import com.smartgwt.client.widgets.form.fields.CheckboxItem;
-import com.smartgwt.client.widgets.form.fields.DateItem;
-import com.smartgwt.client.widgets.form.fields.FormItem;
-import com.smartgwt.client.widgets.form.fields.HeaderItem;
-import com.smartgwt.client.widgets.form.fields.IntegerItem;
-import com.smartgwt.client.widgets.form.fields.RadioGroupItem;
-import com.smartgwt.client.widgets.form.fields.SpacerItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.TimeItem;
-import com.smartgwt.client.widgets.form.validator.CustomValidator;
-
-import org.rhq.enterprise.gui.coregui.client.components.wizard.AbstractWizardStep;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableDynamicForm;
-
-/**
- * @author Greg Hinkle
- */
-public class OperationSchedulingStep extends AbstractWizardStep implements ItemChangedHandler {
-
- private DynamicForm form;
- private ValuesManager valuesManager;
-
- private ExecutionSchedule executionSchedule = new ExecutionSchedule();
-
- public Canvas getCanvas() {
-
- if (form == null) {
- valuesManager = new ValuesManager();
- form = new LocatableDynamicForm("OperationScheduling");
- form.setValuesManager(valuesManager);
- form.setWrapItemTitles(false);
- form.setErrorOrientation(FormErrorOrientation.RIGHT);
- form.setWidth100();
- form.setPadding(10);
- form.setNumCols(3);
- // form.setColWidths("15%", "35%", "15%", "*");
- form.setValidateOnChange(true);
-
- final RadioGroupItem start = new RadioGroupItem("start",
- MSG.view_operationCreateWizard_schedulingStep_name());
- start.setColSpan(3);
- start.setValueMap(enumValueMap(ExecutionSchedule.Start.class)); // "Immediately", "Future"
- start.setRedrawOnChange(true);
- start.setValue("Immediately");
-
- HeaderItem scheduleHeader = new HeaderItem("scheduleHeader");
- scheduleHeader.setValue(MSG.view_operationCreateWizard_schedulingStep_label_schedule());
- scheduleHeader.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !"Immediately".equals(form.getValueAsString("start"));
- }
- });
-
- RadioGroupItem recurr = new RadioGroupItem("recurr",
- MSG.view_operationCreateWizard_schedulingStep_label_recurrence());
- recurr.setValueMap(enumValueMap(ExecutionSchedule.Recurr.class)); // "Once", "EveryNMinutes", "Hourly", "Daily", "Weekly", "Monthly");
- recurr.setRedrawOnChange(true);
- recurr.setValue(ExecutionSchedule.Recurr.Once.name());
- recurr.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"));
- }
- });
-
- CanvasItem onceForm = new CanvasItem("once", MSG.view_operationCreateWizard_schedulingStep_label_onceAt());
- onceForm.setShowTitle(false);
- onceForm.setCanvas(getOnceForm());
- onceForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Once.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem everyNMinuteForm = new CanvasItem("everyNMinutesForm",
- MSG.view_operationCreateWizard_schedulingStep_label_everyNMinutes());
- everyNMinuteForm.setShowTitle(false);
- everyNMinuteForm.setCanvas(getEveryNMinutesForm());
- everyNMinuteForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.EveryNMinutes.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem hourlyForm = new CanvasItem("hourlyForm", MSG.view_operationCreateWizard_schedulingStep_label_hourly());
- hourlyForm.setShowTitle(false);
- hourlyForm.setCanvas(getHourlyForm());
- hourlyForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !"Immediately".equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Hourly.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem dailyForm = new CanvasItem("daily", MSG.view_operationCreateWizard_schedulingStep_label_daily());
- dailyForm.setShowTitle(false);
- dailyForm.setCanvas(getDailyForm());
- dailyForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Daily.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem weeklyForm = new CanvasItem("weekly", MSG.view_operationCreateWizard_schedulingStep_label_weekly());
- weeklyForm.setShowTitle(false);
- weeklyForm.setCanvas(getWeeklyForm());
- weeklyForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Weekly.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- CanvasItem monthlyForm = new CanvasItem("monthly", MSG.view_operationCreateWizard_schedulingStep_label_monthly());
- monthlyForm.setShowTitle(false);
- monthlyForm.setCanvas(getMonthlyForm());
- monthlyForm.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && ExecutionSchedule.Recurr.Monthly.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- HeaderItem rangeHeader = new HeaderItem("timePeriod");
- rangeHeader.setValue(MSG.view_operationCreateWizard_schedulingStep_label_timePeriod());
- rangeHeader.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && !ExecutionSchedule.Recurr.Once.name().equals(form.getValueAsString("recurr"));
- }
- });
-
- DateItem startDate = new DateItem("startDate", MSG.view_operationCreateWizard_schedulingStep_label_startDate());
- startDate.setStartRow(true);
- startDate.setStartDate(new Date());
- startDate.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && !"Once".equals(form.getValueAsString("recurr"));
- }
- });
-
- final RadioGroupItem end = new RadioGroupItem("endType", MSG.view_operationCreateWizard_schedulingStep_label_endDate());
- end.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && !"Once".equals(form.getValueAsString("recurr"));
- }
- });
- end.setStartRow(true);
- // TODO: i18n
- end.setValueMap("Never", "End On");
- end.setRedrawOnChange(true);
- end.setValue("Never");
-
- DateItem endDate = new DateItem("endDate", MSG.view_operationCreateWizard_schedulingStep_label_endDate());
- endDate.setStartRow(true);
- endDate.setStartDate(new Date());
- endDate.setShowIfCondition(new FormItemIfFunction() {
- public boolean execute(FormItem formItem, Object o, DynamicForm dynamicForm) {
- return !ExecutionSchedule.Start.Immediately.name().equals(form.getValueAsString("start"))
- && !"Once".equals(form.getValueAsString("recurr"))
- && !"Never".equals(form.getValueAsString("endType"));
- }
- });
- endDate.setValidators(new CustomValidator() {
- @Override
- protected boolean condition(Object o) {
- return (((Date) form.getValue("startDate")).before((Date) o));
- }
- });
-
- StaticTextItem messageItem = new StaticTextItem("message");
- messageItem.setValue(MSG.view_operationCreateWizard_schedulingStep_label_willExecuteImmediately());
- messageItem.setStartRow(true);
- messageItem.setColSpan(3);
- messageItem.setShowTitle(false);
- messageItem.setCellStyle("HeaderLabel");
-
- form.setItems(start, scheduleHeader, recurr, onceForm, everyNMinuteForm, hourlyForm, dailyForm, weeklyForm,
- monthlyForm, rangeHeader, startDate, end, endDate, new SpacerItem(), messageItem);
-
- form.addItemChangedHandler(this);
- }
-
- return form;
- }
-
- private DynamicForm getOnceForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_onceAt());
- form.addItemChangedHandler(this);
-
- form.setWrapItemTitles(false);
- form.setNumCols(2);
-
- DateItem startDate = new DateItem("onceStartDate", MSG.view_operationCreateWizard_schedulingStep_label_startDate());
- startDate.setValue(new Date());
-
- TimeItem startTime = new TimeItem("onceStartDate", MSG.view_operationCreateWizard_schedulingStep_label_startDate());
- startTime.setValue(new Date());
- startTime.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
- startTime.setUseMask(true);
- form.setItems(startDate, startTime);
- return form;
- }
-
- private DynamicForm getEveryNMinutesForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_everyNMinutes());
- form.addItemChangedHandler(this);
-
- form.setWrapItemTitles(false);
- form.setNumCols(2);
-
- IntegerItem everyNMinutes = new IntegerItem();
- everyNMinutes.setName("minuteInterval");
- everyNMinutes.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_minuteInterval());
- everyNMinutes.setValue(60);
-
- form.setItems(everyNMinutes);
- return form;
- }
-
- private DynamicForm getHourlyForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_hourly());
- form.addItemChangedHandler(this);
-
- form.setWrapItemTitles(false);
- form.setNumCols(2);
-
- IntegerItem minuteOfHour = new IntegerItem();
- minuteOfHour.setName("minuteOfHour");
- minuteOfHour.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_minuteOfHour());
- minuteOfHour.setValue(5);
-
- form.setItems(minuteOfHour);
- return form;
- }
-
- private DynamicForm getDailyForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setWrapItemTitles(false);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_daily());
- form.addItemChangedHandler(this);
-
- TimeItem timeOfDay = new TimeItem("timeOfDay", MSG.view_operationCreateWizard_schedulingStep_label_timeOfDay());
- timeOfDay.setValue(new Date());
- timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
- timeOfDay.setUseMask(true);
-
- form.setItems(timeOfDay);
- return form;
- }
-
- private DynamicForm getWeeklyForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_weekly());
- form.addItemChangedHandler(this);
-
- form.setWrapItemTitles(false);
-
- TimeItem timeOfDay = new TimeItem("dayOfWeek", MSG.view_operationCreateWizard_schedulingStep_label_dayOfWeek());
- timeOfDay.setValue(new Date());
- timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
- timeOfDay.setUseMask(true);
-
- ExecutionSchedule.DayOfWeek[] daysOfWeek = ExecutionSchedule.DayOfWeek.values();
- List<String> dayList = new ArrayList<String>();
- for (ExecutionSchedule.DayOfWeek dayOfWeek : daysOfWeek) {
- dayList.add(dayOfWeek.name());
- }
- FormItem[] items = new FormItem[8];
- items[0] = timeOfDay;
- int i = 1;
- for (String day : dayList) {
- CheckboxItem dayItem = new CheckboxItem(day);
- dayItem.setShowTitle(false);
- items[i++] = dayItem;
- }
- form.setItems(items);
- return form;
- }
-
- private DynamicForm getMonthlyForm() {
- DynamicForm form = new DynamicForm();
- form.setValuesManager(valuesManager);
- form.setPadding(10);
- form.setWrapItemTitles(false);
- form.setIsGroup(true);
- form.setGroupTitle(MSG.view_operationCreateWizard_schedulingStep_label_monthly());
- form.addItemChangedHandler(this);
-
- IntegerItem dayItem = new IntegerItem();
- dayItem.setName("dayOfMonth");
- dayItem.setTitle(MSG.view_operationCreateWizard_schedulingStep_label_dayOfMonth());
- dayItem.setValue(1);
-
- TimeItem timeOfDay = new TimeItem("timeOfDay", MSG.view_operationCreateWizard_schedulingStep_label_timeOfDay());
- timeOfDay.setValue(new Date());
- timeOfDay.setDisplayFormat(TimeFormatter.TOSHORTPADDEDTIME);
- timeOfDay.setUseMask(true);
-
- form.setItems(dayItem, timeOfDay);
- return form;
- }
-
- public boolean nextPage() {
- return true; // TODO: Implement this method.
- }
-
- public String getName() {
- return MSG.view_operationCreateWizard_schedulingStep_name();
- }
-
- public void onItemChanged(ItemChangedEvent itemChangeEvent) {
-
- executionSchedule.setStart(ExecutionSchedule.Start.valueOf(valuesManager.getValueAsString("start")));
- executionSchedule.setRecurr(ExecutionSchedule.Recurr.valueOf(valuesManager.getValueAsString("recurr")));
-
- Date onceDate = (Date) valuesManager.getValues().get("onceStartDate");
- executionSchedule.setOnceDateTime(onceDate);
-
- executionSchedule.setMinuteInterval(Integer.parseInt(valuesManager.getValueAsString("minuteInterval")));
-
- executionSchedule.setMinuteInHour(Integer.parseInt(valuesManager.getValueAsString("minuteOfHour")));
-
- executionSchedule.setTimeOfDay((Date) valuesManager.getValues().get("timeOfDay"));
-
- HashSet<ExecutionSchedule.DayOfWeek> selectedDays = new HashSet<ExecutionSchedule.DayOfWeek>(); //.noneOf(ExecutionSchedule.DayOfWeek.class);
- for (ExecutionSchedule.DayOfWeek d : EnumSet.allOf(ExecutionSchedule.DayOfWeek.class)) {
- if (valuesManager.getValues().containsKey(d.name())) {
- selectedDays.add(d);
- }
- }
- executionSchedule.setDaysOfWeek(selectedDays);
-
- executionSchedule.setDayOfMonth(Integer.parseInt(valuesManager.getValueAsString("dayOfMonth")));
-
- executionSchedule.setStartDate((Date) valuesManager.getValues().get("startDate"));
-
- if ("Never".equals(valuesManager.getValues().get("endType"))) {
- executionSchedule.setEndDate(null);
- } else {
- executionSchedule.setEndDate((Date) valuesManager.getValues().get("endDate"));
- }
-
- form.setValue("message", executionSchedule.getMessage());
- }
-
- private LinkedHashMap<String, String> enumValueMap(Class<? extends Enum> e) {
- LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
- for (Object o : EnumSet.allOf(e)) {
- Enum v = (Enum) o;
- map.put(v.name(), v.name()); // localize
- }
- return map;
- }
-
- public ExecutionSchedule getExecutionSchedule() {
- return executionSchedule;
- }
-
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java
deleted file mode 100644
index db2d83e..0000000
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/detail/OperationDetailsView.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * RHQ Management Platform
- * Copyright (C) 2005-2010 Red Hat, Inc.
- * All rights reserved.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.detail;
-
-import java.util.Date;
-
-import com.google.gwt.user.client.rpc.AsyncCallback;
-import com.smartgwt.client.types.Overflow;
-import com.smartgwt.client.widgets.Canvas;
-import com.smartgwt.client.widgets.Window;
-import com.smartgwt.client.widgets.events.CloseClickHandler;
-import com.smartgwt.client.widgets.events.CloseClientEvent;
-import com.smartgwt.client.widgets.form.DynamicForm;
-import com.smartgwt.client.widgets.form.fields.LinkItem;
-import com.smartgwt.client.widgets.form.fields.StaticTextItem;
-import com.smartgwt.client.widgets.form.fields.events.ClickEvent;
-import com.smartgwt.client.widgets.form.fields.events.ClickHandler;
-
-import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
-import org.rhq.core.domain.operation.OperationDefinition;
-import org.rhq.core.domain.operation.OperationRequestStatus;
-import org.rhq.core.domain.operation.ResourceOperationHistory;
-import org.rhq.core.domain.util.PageList;
-import org.rhq.enterprise.gui.coregui.client.BookmarkableView;
-import org.rhq.enterprise.gui.coregui.client.CoreGUI;
-import org.rhq.enterprise.gui.coregui.client.ImageManager;
-import org.rhq.enterprise.gui.coregui.client.ViewPath;
-import org.rhq.enterprise.gui.coregui.client.components.configuration.ConfigurationEditor;
-import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryDataSource;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHTMLPane;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
-import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableWindow;
-
-/**
- * @author Greg Hinkle
- */
-public class OperationDetailsView extends LocatableVLayout implements BookmarkableView {
-
- private OperationDefinition definition;
- private ResourceOperationHistory operationHistory;
-
- private DynamicForm form;
-
- public OperationDetailsView(String locatorId) {
- super(locatorId);
- }
-
- public OperationDetailsView(String locatorId, OperationDefinition definition,
- ResourceOperationHistory operationHistory) {
- super(locatorId);
-
- this.definition = definition;
- this.operationHistory = operationHistory;
- }
-
- @Override
- protected void onDraw() {
- super.onDraw();
-
- for (Canvas child : getMembers()) {
- child.destroy();
- }
-
- if (this.operationHistory != null) {
- displayDetails(operationHistory);
- }
- }
-
- private void displayDetails(final ResourceOperationHistory operationHistory) {
-
- for (Canvas child : getMembers()) {
- removeChild(child);
- }
-
- this.definition = operationHistory.getOperationDefinition();
- this.operationHistory = operationHistory;
-
- // Information Form
-
- form = new DynamicForm();
- form.setWidth100();
- form.setWrapItemTitles(false);
-
- OperationRequestStatus status = operationHistory.getStatus();
-
- StaticTextItem operationItem = new StaticTextItem(OperationHistoryDataSource.Field.OPERATION_NAME, MSG
- .view_operationHistoryDetails_operation());
- operationItem.setValue(definition.getDisplayName());
-
- StaticTextItem submittedItem = new StaticTextItem(OperationHistoryDataSource.Field.STARTED_TIME, MSG
- .view_operationHistoryDetails_dateSubmitted());
- submittedItem.setValue(new Date(operationHistory.getStartedTime()));
-
- StaticTextItem completedItem = new StaticTextItem("completed", MSG.view_operationHistoryDetails_dateCompleted());
- if (status == OperationRequestStatus.INPROGRESS) {
- completedItem.setValue(MSG.common_val_na());
- } else if (status == OperationRequestStatus.CANCELED) {
- completedItem.setValue(MSG.common_val_never());
- } else {
- completedItem.setValue(new Date(operationHistory.getStartedTime() + operationHistory.getDuration()));
- }
-
- StaticTextItem requesterItem = new StaticTextItem(OperationHistoryDataSource.Field.SUBJECT, MSG
- .view_operationHistoryDetails_requestor());
- requesterItem.setValue(operationHistory.getSubjectName());
-
- LinkItem errorLinkItem = null;
-
- StaticTextItem statusItem = new StaticTextItem(OperationHistoryDataSource.Field.STATUS, MSG
- .view_operationHistoryDetails_status());
- String icon = ImageManager.getFullImagePath(ImageManager.getOperationResultsIcon(status));
- statusItem.setValue("<img src='" + icon + "'/>");
- switch (status) {
- case SUCCESS:
- statusItem.setTooltip(MSG.common_status_success());
- break;
- case FAILURE:
- statusItem.setTooltip(MSG.common_status_failed());
- errorLinkItem = new LinkItem("errorLink");
- errorLinkItem.setTitle(MSG.common_title_error());
- errorLinkItem.setLinkTitle(getShortErrorMessage(operationHistory));
- errorLinkItem.addClickHandler(new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- final Window winModal = new LocatableWindow(OperationDetailsView.this.extendLocatorId("errorWin"));
- winModal.setTitle(MSG.common_title_details());
- winModal.setOverflow(Overflow.VISIBLE);
- winModal.setShowMinimizeButton(false);
- winModal.setShowMaximizeButton(true);
- winModal.setIsModal(true);
- winModal.setShowModalMask(true);
- winModal.setAutoSize(true);
- winModal.setAutoCenter(true);
- winModal.setShowResizer(true);
- winModal.setCanDragResize(true);
- winModal.centerInPage();
- winModal.addCloseClickHandler(new CloseClickHandler() {
- @Override
- public void onCloseClick(CloseClientEvent event) {
- winModal.markForDestroy();
- }
- });
-
- LocatableHTMLPane htmlPane = new LocatableHTMLPane(OperationDetailsView.this
- .extendLocatorId("statusDetailsPane"));
- htmlPane.setMargin(10);
- htmlPane.setDefaultWidth(500);
- htmlPane.setDefaultHeight(400);
- String errorMsg = operationHistory.getErrorMessage();
- if (errorMsg == null) {
- errorMsg = MSG.common_status_failed();
- }
- htmlPane.setContents("<pre>" + errorMsg + "</pre>");
- winModal.addItem(htmlPane);
- winModal.show();
- }
- });
-
- break;
- case INPROGRESS:
- statusItem.setTooltip(MSG.common_status_inprogress());
- break;
- case CANCELED:
- statusItem.setTooltip(MSG.common_status_canceled());
- break;
- }
-
- /*
- Operation: View Process List
- Date Submitted: 3/11/10, 12:24:02 PM, EST
- Date Completed: 3/11/10, 12:24:03 PM, EST
- Requester: rhqadmin
- Status: Failure
- Error Message: __Exception: Cannot connect...__
- */
-
- if (errorLinkItem != null) {
- form.setItems(operationItem, submittedItem, completedItem, requesterItem, statusItem, errorLinkItem);
- } else {
- form.setItems(operationItem, submittedItem, completedItem, requesterItem, statusItem);
- }
-
- addMember(form);
-
- // params/results
-
- if (operationHistory.getParameters() != null) {
- ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("params"), definition
- .getParametersConfigurationDefinition(), operationHistory.getParameters());
- editor.setReadOnly(true);
- editor.setStructuredConfigTabTitle(MSG.view_operationHistoryDetails_parameters());
- addMember(editor);
- }
-
- if (status == OperationRequestStatus.SUCCESS && operationHistory.getResults() != null) {
- ConfigurationEditor editor = new ConfigurationEditor(extendLocatorId("results"), definition
- .getResultsConfigurationDefinition(), operationHistory.getResults());
- editor.setReadOnly(true);
- editor.setStructuredConfigTabTitle(MSG.view_operationHistoryDetails_results());
- addMember(editor);
- }
- }
-
- private void lookupDetails(int historyId) {
- ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
-
- criteria.addFilterId(historyId);
-
- criteria.fetchOperationDefinition(true);
- criteria.fetchParameters(true);
- criteria.fetchResults(true);
-
- GWTServiceLookup.getOperationService().findResourceOperationHistoriesByCriteria(criteria,
- new AsyncCallback<PageList<ResourceOperationHistory>>() {
- public void onFailure(Throwable caught) {
- CoreGUI.getErrorHandler()
- .handleError(MSG.view_operationHistoryDetails_error_fetchFailure(), caught);
- }
-
- public void onSuccess(PageList<ResourceOperationHistory> result) {
- ResourceOperationHistory item = result.get(0);
- displayDetails(item);
- }
- });
- }
-
- @Override
- public void renderView(ViewPath viewPath) {
- int historyId = viewPath.getCurrentAsInt();
- lookupDetails(historyId);
- }
-
- private String getShortErrorMessage(ResourceOperationHistory operationHistory) {
- String errMsg = operationHistory.getErrorMessage();
- if (errMsg == null) {
- errMsg = MSG.common_status_failed();
- } else if (errMsg.length() > 80) {
- errMsg = errMsg.substring(0, 80) + "...";
- }
- return errMsg;
- }
-}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
new file mode 100644
index 0000000..e350042
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryDataSource.java
@@ -0,0 +1,67 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history;
+
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.smartgwt.client.data.DSRequest;
+import com.smartgwt.client.data.DSResponse;
+
+import org.rhq.core.domain.criteria.ResourceOperationHistoryCriteria;
+import org.rhq.core.domain.operation.ResourceOperationHistory;
+import org.rhq.core.domain.util.PageList;
+import org.rhq.enterprise.gui.coregui.client.CoreGUI;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.OperationHistoryDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public class ResourceOperationHistoryDataSource extends OperationHistoryDataSource {
+
+ public static abstract class CriteriaField {
+ public static final String RESOURCE_ID = "resourceId";
+ }
+
+ @Override
+ protected void executeFetch(final DSRequest request, final DSResponse response) {
+ ResourceOperationHistoryCriteria criteria = new ResourceOperationHistoryCriteria();
+
+ if (request.getCriteria().getValues().containsKey(CriteriaField.RESOURCE_ID)) {
+ int resourceId = Integer.parseInt((String)request.getCriteria().getValues().get(
+ CriteriaField.RESOURCE_ID));
+ criteria.addFilterResourceIds(resourceId);
+ }
+
+ criteria.setPageControl(getPageControl(request));
+
+ operationService.findResourceOperationHistoriesByCriteria(criteria,
+ new AsyncCallback<PageList<ResourceOperationHistory>>() {
+ public void onFailure(Throwable caught) {
+ CoreGUI.getErrorHandler().handleError(MSG.dataSource_operationHistory_error_fetchFailure(), caught);
+ }
+
+ public void onSuccess(PageList<ResourceOperationHistory> result) {
+ response.setData(buildRecords(result));
+ processResponse(request.getRequestId(), response);
+ }
+ });
+ }
+
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
new file mode 100644
index 0000000..172da98
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/operation/history/ResourceOperationHistoryListView.java
@@ -0,0 +1,93 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history;
+
+import java.util.EnumSet;
+
+import com.smartgwt.client.data.Criteria;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.menu.IMenuButton;
+import com.smartgwt.client.widgets.menu.Menu;
+import com.smartgwt.client.widgets.menu.MenuItem;
+import com.smartgwt.client.widgets.menu.events.ClickHandler;
+import com.smartgwt.client.widgets.menu.events.MenuItemClickEvent;
+
+import org.rhq.core.domain.operation.OperationDefinition;
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.core.domain.resource.ResourceType;
+import org.rhq.core.domain.resource.composite.ResourceComposite;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.ResourceOperationHistoryDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.schedule.OperationCreateWizard;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableIMenuButton;
+import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableMenu;
+
+/**
+ * @author Ian Springer
+ */
+public class ResourceOperationHistoryListView extends AbstractOperationHistoryListView {
+
+ private ResourceComposite resourceComposite;
+
+ public ResourceOperationHistoryListView(String locatorId, ResourceComposite resourceComposite) {
+ super(locatorId, new ResourceOperationHistoryDataSource(), null,
+ new Criteria(ResourceOperationHistoryDataSource.CriteriaField.RESOURCE_ID,
+ String.valueOf(resourceComposite.getResource().getId())));
+ this.resourceComposite = resourceComposite;
+ }
+
+ @Override
+ protected void configureTable() {
+ super.configureTable();
+
+ if (this.resourceComposite.getResourcePermission().isControl()) {
+ final Resource resource = this.resourceComposite.getResource();
+ final Menu operationMenu = new LocatableMenu(this.extendLocatorId("Operation"));
+ ResourceTypeRepository.Cache.getInstance().getResourceTypes(resource.getResourceType().getId(),
+ EnumSet.of(ResourceTypeRepository.MetadataType.operations),
+ new ResourceTypeRepository.TypeLoadedCallback() {
+ public void onTypesLoaded(ResourceType type) {
+ for (final OperationDefinition operationDefinition : type.getOperationDefinitions()) {
+ MenuItem menuItem = new MenuItem(operationDefinition.getDisplayName());
+ operationMenu.addItem(menuItem);
+ menuItem.addClickHandler(new ClickHandler() {
+ public void onClick(MenuItemClickEvent event) {
+ new OperationCreateWizard(resource, operationDefinition).startOperationWizard();
+ }
+ });
+ }
+ }
+ });
+
+ IMenuButton operationsButton = new LocatableIMenuButton(this.extendLocatorId("Run"),
+ MSG.view_operationHistoryList_button_runOperation(), operationMenu);
+ operationsButton.setShowMenuBelow(false);
+ operationsButton.setAutoFit(true);
+ addExtraWidget(operationsButton);
+ }
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new ResourceOperationHistoryDetailsView(this.extendLocatorId("Details"));
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
index cec98e5..cc57951 100644
--- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/ReportTopView.java
@@ -43,9 +43,10 @@ import org.rhq.enterprise.gui.coregui.client.components.view.NavigationSection;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewFactory;
import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
import org.rhq.enterprise.gui.coregui.client.dashboard.portlets.platform.PlatformSummaryPortlet;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.configuration.ConfigurationHistoryView;
-import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.OperationHistoryView;
import org.rhq.enterprise.gui.coregui.client.report.measurement.MeasurementOOBView;
+import org.rhq.enterprise.gui.coregui.client.report.operation.SubsystemOperationHistoryListView;
import org.rhq.enterprise.gui.coregui.client.report.tag.TaggedView;
/**
@@ -116,10 +117,10 @@ public class ReportTopView extends AbstractSectionedLeftNavigationView {
}
});
- NavigationItem recentOperationsItem = new NavigationItem(OperationHistoryView.VIEW_ID,
+ NavigationItem recentOperationsItem = new NavigationItem(SubsystemOperationHistoryListView.VIEW_ID,
"subsystems/control/Operation_16.png", new ViewFactory() {
public Canvas createView() {
- return new OperationHistoryView(extendLocatorId(OperationHistoryView.VIEW_ID.getName()));
+ return new SubsystemOperationHistoryListView(extendLocatorId(SubsystemOperationHistoryListView.VIEW_ID.getName()));
}
});
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
new file mode 100644
index 0000000..af46041
--- /dev/null
+++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/report/operation/SubsystemOperationHistoryListView.java
@@ -0,0 +1,84 @@
+/*
+ * RHQ Management Platform
+ * Copyright 2010, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+package org.rhq.enterprise.gui.coregui.client.report.operation;
+
+import java.util.List;
+
+import com.smartgwt.client.types.Alignment;
+import com.smartgwt.client.widgets.Canvas;
+import com.smartgwt.client.widgets.grid.CellFormatter;
+import com.smartgwt.client.widgets.grid.ListGridField;
+import com.smartgwt.client.widgets.grid.ListGridRecord;
+
+import org.rhq.core.domain.resource.Resource;
+import org.rhq.enterprise.gui.coregui.client.LinkManager;
+import org.rhq.enterprise.gui.coregui.client.components.view.ViewName;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.AbstractOperationHistoryListView;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.OperationHistoryDataSource;
+import org.rhq.enterprise.gui.coregui.client.inventory.common.detail.operation.history.ResourceOperationHistoryDetailsView;
+import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.operation.history.ResourceOperationHistoryDataSource;
+
+/**
+ * @author Ian Springer
+ */
+public class SubsystemOperationHistoryListView extends AbstractOperationHistoryListView {
+
+ public static final ViewName VIEW_ID = new ViewName("RecentOperations", MSG.common_title_recent_operations());
+
+ public SubsystemOperationHistoryListView(String locatorId) {
+ super(locatorId, new ResourceOperationHistoryDataSource(), VIEW_ID.getTitle());
+ }
+
+ @Override
+ protected List<ListGridField> createFields() {
+ List<ListGridField> fields = super.createFields();
+
+ for (ListGridField field : fields) {
+ String fieldName = field.getName();
+ if (fieldName.equals(OperationHistoryDataSource.Field.OPERATION_NAME) ||
+ fieldName.equals(OperationHistoryDataSource.Field.SUBJECT) ||
+ fieldName.equals(OperationHistoryDataSource.Field.STARTED_TIME)) {
+ field.setWidth("25%");
+ }
+ }
+
+ ListGridField resourceField = new ListGridField(OperationHistoryDataSource.Field.RESOURCE,
+ MSG.common_title_resource());
+ resourceField.setAlign(Alignment.LEFT);
+ resourceField.setCellAlign(Alignment.LEFT);
+ resourceField.setCellFormatter(new CellFormatter() {
+ public String format(Object o, ListGridRecord listGridRecord, int i, int i1) {
+ Resource resource = (Resource) o;
+ String url = LinkManager.getResourceLink(resource.getId());
+ return "<a href=\"" + url + "\">" + resource.getName() + "</a>";
+ }
+ });
+ resourceField.setWidth("25%");
+ fields.add(resourceField);
+
+ return fields;
+ }
+
+ @Override
+ public Canvas getDetailsView(int id) {
+ return new ResourceOperationHistoryDetailsView(this.extendLocatorId("Details"));
+ }
+
+}
diff --git a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 0654519..2b65a7f 100644
--- a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++ b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -1339,8 +1339,8 @@ view_tabs_common_child_history = Child History
view_tabs_common_connectionSettings = Connection Settings
view_tabs_common_connectionSettingsHistory = Connection Settings History
view_tabs_common_operations = Operations
+view_tabs_common_schedule = Schedule
view_tabs_common_history = History
-view_tabs_common_scheduled = Scheduled
view_tabs_common_alerts = Alerts
view_tabs_common_definitions = Definitions
view_tabs_common_current = Current
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
index 21d0770..992e401 100644
--- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/operation/OperationManagerBean.java
@@ -1491,12 +1491,12 @@ public class OperationManagerBean implements OperationManagerLocal, OperationMan
}
/**
- * Given an attached history object, this will see if its has completed and if it is a resource history that is part
+ * Given the id of a history object, this will see if it has completed and if it is a resource history that is part
* of an overall group operation and if so will see if all of its peer resource histories are also complete. If the
* group members are all done, the group history object will have its status updated to reflect that the group
* itself is done.
*
- * @param history an EJB3 managed (aka attached) history object
+ * @param historyId id of a history object
*/
public void checkForCompletedGroupOperation(int historyId) {
OperationHistory history = entityManager.find(OperationHistory.class, historyId);
13 years, 6 months
[rhq] .classpath
by mazz
.classpath | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 81915fdbca9b3afdb31b52d5321e2de6a6e9668c
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Wed Dec 15 12:03:19 2010 -0500
add ant sources to eclipse
diff --git a/.classpath b/.classpath
index 14c4ae1..17aab76 100644
--- a/.classpath
+++ b/.classpath
@@ -166,7 +166,7 @@
<classpathentry exported="true" kind="var" path="M2_REPO/jboss/jboss-remoting/2.2.2.SP8/jboss-remoting-2.2.2.SP8.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/oswego-concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/rss4j/rss4j/0.92-on.2/rss4j-0.92-on.2.jar"/>
- <classpathentry exported="true" kind="var" path="M2_REPO/org/apache/ant/ant/1.8.0/ant-1.8.0.jar"/>
+ <classpathentry exported="true" kind="var" path="M2_REPO/org/apache/ant/ant/1.8.0/ant-1.8.0.jar" sourcepath="M2_REPO/org/apache/ant/ant/1.8.0/ant-1.8.0-sources.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/org/apache/ant/ant-nodeps/1.8.0/ant-nodeps-1.8.0.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/javax/servlet/servlet-api/2.4/servlet-api-2.4.jar"/>
<classpathentry exported="true" kind="var" path="M2_REPO/struts/struts/1.2.9/struts-1.2.9.jar"/>
13 years, 6 months
[rhq] Branch 'release-3.0.0' - 2 commits - modules/core modules/enterprise
by lkrejci
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java | 6
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/ConfigurationUtility.java | 11 +
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/ConfigurationSet.java | 75 ++++++++--
modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/group/EditGroupResourceConfigurationUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/EditTestConfigurationUIBean.java | 2
modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupPluginConfigurationUIBean.java | 2
7 files changed, 80 insertions(+), 20 deletions(-)
New commits:
commit 0a53ca30d70fe38283185673bff7aeae58ea33d5
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Dec 15 16:40:21 2010 +0100
BZ 663377 - Updating group config doesn't introduce "foreign" properties in open maps of individual resources.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java
index 87bd52c..cf48945 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/ConfigRenderer.java
@@ -263,7 +263,7 @@ public class ConfigRenderer extends Renderer {
// Update member Configurations if this is a group config.
if (configurationComponent instanceof ConfigurationSetComponent) {
ConfigurationSetComponent configurationSetComponent = ((ConfigurationSetComponent) configurationComponent);
- configurationSetComponent.getConfigurationSet().applyGroupConfiguration();
+ configurationSetComponent.getConfigurationSet().applyGroupConfigurationForView();
}
// Now add a new component to the JSF component tree.
@@ -310,7 +310,7 @@ public class ConfigRenderer extends Renderer {
// ...and from member Configurations if this is a group config.
if (configurationComponent instanceof ConfigurationSetComponent) {
ConfigurationSetComponent configurationSetComponent = ((ConfigurationSetComponent) configurationComponent);
- configurationSetComponent.getConfigurationSet().applyGroupConfiguration();
+ configurationSetComponent.getConfigurationSet().applyGroupConfigurationForView();
}
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Property at index " + listIndex
@@ -370,7 +370,7 @@ public class ConfigRenderer extends Renderer {
// ...and from member Configurations if this is a group config.
if (configurationComponent instanceof ConfigurationSetComponent) {
ConfigurationSetComponent configurationSetComponent = ((ConfigurationSetComponent) configurationComponent);
- configurationSetComponent.getConfigurationSet().applyGroupConfiguration();
+ configurationSetComponent.getConfigurationSet().applyGroupConfigurationForView();
}
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Property '" + memberName + "' deleted from map '"
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/ConfigurationSet.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/ConfigurationSet.java
index d84aa14..959b85f 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/ConfigurationSet.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/ConfigurationSet.java
@@ -67,18 +67,26 @@ public class ConfigurationSet {
calculateGroupProperty(childPropertyDefinition, sourceParentPropertyMaps, this.groupConfiguration);
}
- public void applyGroupConfiguration() {
+ public void applyGroupConfigurationForView() {
+ applyGroupConfiguration(true);
+ }
+
+ public void applyGroupConfigurationForUpdate() {
+ applyGroupConfiguration(false);
+ }
+
+ private void applyGroupConfiguration(boolean forView) {
if (this.members.isEmpty())
return;
Map<String, PropertyDefinition> childPropertyDefinitions = this.configurationDefinition
.getPropertyDefinitions();
- List<AbstractPropertyMap> sourceParentPropertyMaps = new ArrayList();
+ List<AbstractPropertyMap> sourceParentPropertyMaps = new ArrayList<AbstractPropertyMap>();
for (ConfigurationSetMember member : this.members)
sourceParentPropertyMaps.add(member.getConfiguration());
for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values())
- mergeProperty(childPropertyDefinition, sourceParentPropertyMaps, this.groupConfiguration);
+ mergeProperty(childPropertyDefinition, sourceParentPropertyMaps, this.groupConfiguration, forView);
}
-
+
public ConfigurationDefinition getConfigurationDefinition() {
return configurationDefinition;
}
@@ -172,8 +180,23 @@ public class ConfigurationSet {
// Also add it to each of the source config maps that don't already contain it, so that they can be
// rendered as unset on the propSet page.
for (AbstractPropertyMap map : sourceParentPropertyMaps) {
- if (map.get(memberName) == null)
- map.put(new PropertySimple(memberName, null));
+ if (map.get(memberName) == null) {
+ PropertySimple sourceProperty = new PropertySimple(memberName, null);
+ //ok, this is highly confusing but we have no other way of "marking"
+ //this kind of property.
+ //We need to mark the property as not present in the original source map.
+ //This is different from having an unset value of course.
+
+ //There is no other property on the Property class that we could use for this
+ //than the override. The confusion here is that the override property is used
+ //for the exact opposite reason on the target (i.e. the calculated group configuration),
+ //where it marks the fact that all the properties in the different resource configuration
+ //are set and have the same value.
+ //This works, because a member property is never also a calculated one, it can just confuse
+ //the casual reader of this code ;)
+ sourceProperty.setOverride(true);
+ map.put(sourceProperty);
+ }
}
Map<String, Integer> valueFrequencies = memberNameValueFrequenciesMap.get(memberName);
if (valueFrequencies.size() == 1
@@ -187,7 +210,7 @@ public class ConfigurationSet {
}
private static void mergeProperty(PropertyDefinition propertyDefinition,
- List<AbstractPropertyMap> memberParentPropertyMaps, AbstractPropertyMap groupParentPropertyMap) {
+ List<AbstractPropertyMap> memberParentPropertyMaps, AbstractPropertyMap groupParentPropertyMap, boolean forView) {
if (propertyDefinition instanceof PropertyDefinitionSimple) {
PropertySimple propertySimple = groupParentPropertyMap.getSimple(propertyDefinition.getName());
if (propertySimple != null && propertySimple.getOverride() != null && propertySimple.getOverride()) {
@@ -212,7 +235,7 @@ public class ConfigurationSet {
PropertyMap groupPropertyMap = groupParentPropertyMap.getMap(propertyDefinition.getName());
groupParentPropertyMap.put(groupPropertyMap);
mergePropertyMap((PropertyDefinitionMap) propertyDefinition, nestedSourceParentPropertyMaps,
- groupPropertyMap);
+ groupPropertyMap, forView);
} else if (propertyDefinition instanceof PropertyDefinitionList) {
PropertyDefinitionList propertyDefinitionList = (PropertyDefinitionList) propertyDefinition;
PropertyDefinition listMemberPropertyDefinition = propertyDefinitionList.getMemberDefinition();
@@ -225,18 +248,18 @@ public class ConfigurationSet {
}
private static void mergePropertyMap(PropertyDefinitionMap propertyDefinitionMap,
- List<AbstractPropertyMap> memberParentPropertyMaps, AbstractPropertyMap groupParentPropertyMap) {
+ List<AbstractPropertyMap> memberParentPropertyMaps, AbstractPropertyMap groupParentPropertyMap, boolean forView) {
Map<String, PropertyDefinition> childPropertyDefinitions = propertyDefinitionMap.getPropertyDefinitions();
if (!childPropertyDefinitions.isEmpty()) {
for (PropertyDefinition childPropertyDefinition : childPropertyDefinitions.values())
- mergeProperty(childPropertyDefinition, memberParentPropertyMaps, groupParentPropertyMap);
+ mergeProperty(childPropertyDefinition, memberParentPropertyMaps, groupParentPropertyMap, forView);
} else {
- mergeOpenPropertyMap(memberParentPropertyMaps, groupParentPropertyMap);
+ mergeOpenPropertyMap(memberParentPropertyMaps, groupParentPropertyMap, forView);
}
}
private static void mergeOpenPropertyMap(List<AbstractPropertyMap> memberParentPropertyMaps,
- AbstractPropertyMap groupParentPropertyMap) {
+ AbstractPropertyMap groupParentPropertyMap, boolean forView) {
for (String groupMemberPropertyName : groupParentPropertyMap.getMap().keySet()) {
PropertySimple groupMemberProperty = groupParentPropertyMap.getSimple(groupMemberPropertyName);
if (groupMemberProperty != null && groupMemberProperty.getOverride() != null
@@ -251,6 +274,34 @@ public class ConfigurationSet {
sourcePropertySimple.setStringValue(groupMemberProperty.getStringValue());
}
}
+ } else if (!forView) {
+ //we have a non-homogenic property here and want to update the underlying configurations
+ //for update. This means that we want to erradicate all the open map properties from the
+ //underlying configs that are not assigned a value in the calculated group config.
+ //this to basically undo the appearance of there being all open map properties defined
+ //in all configurations in each of them. That is needed for the view purposes but leaving
+ //the configs like that will cause new properties with "empty" values introduced in all the
+ //resource configs in the group after update.
+ for (AbstractPropertyMap sourceParentPropertyMap : memberParentPropertyMaps) {
+ PropertySimple sourcePropertySimple = sourceParentPropertyMap.getSimple(groupMemberPropertyName);
+ if (sourcePropertySimple == null) {
+ //there was no such property there - just add it
+ sourcePropertySimple = new PropertySimple(groupMemberPropertyName, groupMemberProperty
+ .getStringValue());
+ sourceParentPropertyMap.put(sourcePropertySimple);
+ } else {
+ //the members of open map are marked with override to signify that they have
+ //not been originally present in the member configuration.
+ //If this is true and the group property has null value, it means
+ //that the user has set no value for this property and thus it should
+ //be removed again from the member config.
+ if (groupMemberProperty.getStringValue() == null
+ && sourcePropertySimple.getOverride() != null && sourcePropertySimple.getOverride()) {
+
+ sourceParentPropertyMap.getMap().remove(sourcePropertySimple.getName());
+ }
+ }
+ }
}
}
}
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
index 1d802ef..6ca2650 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/propset/PropertySetRenderer.java
@@ -97,7 +97,7 @@ public class PropertySetRenderer extends Renderer {
// will not have been updated yet with any changes made to child UIInput values.
String refresh = FacesContextUtility.getOptionalRequestParameter("refresh");
if (refresh != null && refresh.equals(ConfigRenderer.PROPERTY_SET_COMPONENT_ID)) {
- propertySetComponent.getConfigurationSet().applyGroupConfiguration();
+ propertySetComponent.getConfigurationSet().applyGroupConfigurationForView();
component.getChildren().clear();
}
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/group/EditGroupResourceConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/group/EditGroupResourceConfigurationUIBean.java
index 1ba9b78..ee1f175 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/group/EditGroupResourceConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/group/EditGroupResourceConfigurationUIBean.java
@@ -69,7 +69,7 @@ public class EditGroupResourceConfigurationUIBean extends AbstractGroupResourceC
// so the managed bean doesn't have to worry about doing it.
getConfigurationSet().unmask();
- getConfigurationSet().applyGroupConfiguration();
+ getConfigurationSet().applyGroupConfigurationForUpdate();
getConfigurationManager().scheduleGroupResourceConfigurationUpdate(
EnterpriseFacesContextUtility.getSubject(), getGroup().getId(), getResourceConfigurations());
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/EditTestConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/EditTestConfigurationUIBean.java
index 0857a37..8e0955c 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/EditTestConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/configuration/test/EditTestConfigurationUIBean.java
@@ -34,7 +34,7 @@ public class EditTestConfigurationUIBean extends AbstractTestConfigurationUIBean
public String updateConfiguration() {
// Any values changed in the group config (i.e. via the inputs on the main page) need to be
// applied to all member configs before persisting them.
- getConfigurationSet().applyGroupConfiguration();
+ getConfigurationSet().applyGroupConfigurationForUpdate();
// TODO (low priority): Persist the test config somewhere.
FacesContextUtility.addMessage(FacesMessage.SEVERITY_INFO, "Configuration updated.");
return Outcomes.SUCCESS;
diff --git a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupPluginConfigurationUIBean.java b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupPluginConfigurationUIBean.java
index d1f874a..00e5b2a 100644
--- a/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupPluginConfigurationUIBean.java
+++ b/modules/enterprise/gui/portal-war/src/main/java/org/rhq/enterprise/gui/inventory/group/EditGroupPluginConfigurationUIBean.java
@@ -66,7 +66,7 @@ public class EditGroupPluginConfigurationUIBean extends AbstractGroupPluginConfi
// TODO: See if there's some way for the config renderer to handle calling applyGroupConfiguration(),
// so the managed bean doesn't have to worry about doing it.
getConfigurationSet().unmask();
- getConfigurationSet().applyGroupConfiguration();
+ getConfigurationSet().applyGroupConfigurationForUpdate();
getConfigurationManager().scheduleGroupPluginConfigurationUpdate(
EnterpriseFacesContextUtility.getSubject(), getGroup().getId(), getPluginConfigurations());
} catch (Exception e) {
commit e2f3addc506daa15b3b1d969561dcd9ca836f3b5
Author: Lukas Krejci <lkrejci(a)redhat.com>
Date: Wed Dec 15 15:50:40 2010 +0100
BZ 662662 - restore the ability to view/edit open maps by "faking" property definitions for the individual properties in the open map.
diff --git a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/ConfigurationUtility.java b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/ConfigurationUtility.java
index a9214cc..73962f0 100644
--- a/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/ConfigurationUtility.java
+++ b/modules/core/gui/src/main/java/org/rhq/core/gui/configuration/helper/ConfigurationUtility.java
@@ -26,6 +26,8 @@ import org.rhq.core.domain.configuration.definition.ConfigurationDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinition;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionList;
import org.rhq.core.domain.configuration.definition.PropertyDefinitionMap;
+import org.rhq.core.domain.configuration.definition.PropertyDefinitionSimple;
+import org.rhq.core.domain.configuration.definition.PropertySimpleType;
/**
* @author Ian Springer
@@ -42,7 +44,14 @@ public class ConfigurationUtility
{
Property subProperty = propertyHierarchy.get(i);
if (propertyDefinition instanceof PropertyDefinitionMap) {
- propertyDefinition = ((PropertyDefinitionMap)propertyDefinition).get(subProperty.getName());
+ if (((PropertyDefinitionMap)propertyDefinition).getPropertyDefinitions().isEmpty()) {
+ //this is an open map, i.e. a map with no child definitions, meaning that any simple property
+ //can go in it.
+ //let's create a definition that mimics the current property...
+ propertyDefinition = new PropertyDefinitionSimple(subProperty.getName(), null, false, PropertySimpleType.STRING);
+ } else {
+ propertyDefinition = ((PropertyDefinitionMap)propertyDefinition).get(subProperty.getName());
+ }
} else if (propertyDefinition instanceof PropertyDefinitionList) {
propertyDefinition = ((PropertyDefinitionList)propertyDefinition).getMemberDefinition();
}
13 years, 6 months
[rhq] modules/core
by Heiko W. Rupp
modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTestBase.java | 23 +++++-----
1 file changed, 12 insertions(+), 11 deletions(-)
New commits:
commit 90a400d27f01024a9324afeabf687d11f20d613f
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Dec 15 12:59:11 2010 +0100
Add a null-check as FileUtils.toFile() may return null.
diff --git a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTestBase.java b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTestBase.java
index c299cce..afe3982 100644
--- a/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTestBase.java
+++ b/modules/core/plugin-container/src/test/java/org/rhq/core/pc/upgrade/ResourceUpgradeTestBase.java
@@ -93,33 +93,33 @@ public abstract class ResourceUpgradeTestBase {
public String getResourceTypePluginName() {
return resourceTypePluginName;
}
-
+
@Override
public int hashCode() {
return resourceTypeName.hashCode() * resourceTypePluginName.hashCode();
}
-
+
@Override
public boolean equals(Object other) {
if (other == this) {
return true;
}
-
+
if (!(other instanceof ResType)) {
return false;
}
-
+
ResType o = (ResType)other;
-
+
return resourceTypeName.equals(o.getResourceTypeName()) && resourceTypePluginName.equals(o.getResourceTypePluginName());
}
-
+
@Override
public String toString() {
return "ResType[name='" + resourceTypeName + "', plugin='" + resourceTypePluginName + "']";
}
}
-
+
protected interface TestPayload {
Expectations getExpectations(Mockery context) throws Exception;
@@ -315,6 +315,7 @@ public abstract class ResourceUpgradeTestBase {
File pluginFile = FileUtils.toFile(url);
+ assert pluginFile!=null : "pluginFile was null";
assertTrue(pluginFile.exists(), pluginFile.getAbsoluteFile() + " plugin jar could not be found.");
}
@@ -362,7 +363,7 @@ public abstract class ResourceUpgradeTestBase {
//execute full discovery
InventoryManager im = PluginContainer.getInstance().getInventoryManager();
im.executeServerScanImmediately();
-
+
//do the service scan a couple of times so that we can commit
//the resources deep in the type hierarchy
for(int i = 0; i < 10; ++i) {
@@ -370,12 +371,12 @@ public abstract class ResourceUpgradeTestBase {
}
Map<ResType, Set<Resource>> resources = new HashMap<ResType, Set<Resource>>();
-
+
for(ResType type : test.getExpectedResourceTypes()) {
Set<Resource> rs = getTestingResources(type.getResourceTypeName(), type.getResourceTypePluginName());
resources.put(type, rs);
}
-
+
test.test(resources);
context.assertIsSatisfied();
@@ -402,7 +403,7 @@ public abstract class ResourceUpgradeTestBase {
expectations.allowing(getCurrentDiscoveryServerService()).getResources(
expectations.with(Expectations.any(Set.class)), expectations.with(Expectations.any(boolean.class)));
expectations.will(getCurrentServerSideInventory().getResources());
-
+
expectations.allowing(getCurrentDiscoveryServerService()).postProcessNewlyCommittedResources(
expectations.with(Expectations.any(Set.class)));
}
13 years, 6 months
[rhq] 2 commits - modules/enterprise
by Heiko W. Rupp
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java | 54 +---------
modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java | 2
2 files changed, 7 insertions(+), 49 deletions(-)
New commits:
commit 0aa2ef7be4b47d0d2a48e23ecdcd652d63a7dcca
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Dec 15 12:07:41 2010 +0100
Disable the limitation to certain groups for the moment
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
index c75e462..4d99505 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/test/AbstractEJB3Test.java
@@ -63,7 +63,7 @@ import org.rhq.enterprise.server.util.LookupUtil;
* @author Greg Hinkle
*/
public abstract class AbstractEJB3Test extends AssertJUnit {
- @BeforeSuite(groups = {"integration.ejb3","PERF"})
+ @BeforeSuite//(groups = {"integration.ejb3","PERF"}) // TODO investigate again
public static void startupEmbeddedJboss() throws Exception {
// Setting content location to the tmp dir
System.setProperty(ContentSourceManagerBean.FILESYSTEM_PROPERTY, System.getProperty("java.io.tmpdir"));
commit 34e34f0feef9215c0f5cc531e9e3d806b559f3a5
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Wed Dec 15 12:02:47 2010 +0100
Do the old try-rollback trick so that we leave no dangling stuff around.
diff --git a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java
index 53e21c9..6a09934 100644
--- a/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java
+++ b/modules/enterprise/server/jar/src/test/java/org/rhq/enterprise/server/measurement/test/MeasurementDataManagerTest.java
@@ -22,6 +22,7 @@ import java.util.Date;
import java.util.Random;
import javax.persistence.EntityManager;
+import javax.transaction.Status;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -75,8 +76,6 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
@BeforeMethod
public void beforeMethod() {
try {
- prepareScheduler();
-
this.resourceManager = LookupUtil.getResourceManager();
this.measurementDataManager = LookupUtil.getMeasurementDataManager();
this.callTimeDataManager = LookupUtil.getCallTimeDataManager();
@@ -89,41 +88,6 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
}
}
- @AfterMethod
- public void afterMethod() throws Exception {
- try {
- EntityManager em = getEntityManager();
- getTransactionManager().begin();
-
- MeasurementSchedule schedule1 = resource1.getSchedules().iterator().next();
- MeasurementSchedule schedule2 = resource2.getSchedules().iterator().next();
- schedule1 = em.find(MeasurementSchedule.class,schedule1.getId());
- schedule2 = em.find(MeasurementSchedule.class,schedule2.getId());
- em.remove(schedule1);
- em.remove(schedule2);
- resource1 = em.find(Resource.class,resource1.getId());
- resource2 = em.find(Resource.class,resource2.getId());
- em.remove(resource1);
- em.remove(resource2);
- theDefinition = em.find(MeasurementDefinition.class,theDefinition.getId());
- em.remove(theDefinition);
- theResourceType = em.find(ResourceType.class,theResourceType.getId());
- em.remove(theResourceType);
- theAgent = em.find(Agent.class,theAgent.getId());
- em.remove(theAgent);
-
- getTransactionManager().commit();
-
- } catch (Exception e) {
- e.printStackTrace();
- throw e;
- }
-
- finally {
- unprepareScheduler();
- }
- }
-
@Test
public void bz658491() throws Exception {
@@ -131,7 +95,6 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
try {
setupResources(em);
- commitAndClose(em);
MeasurementSchedule schedule1 = resource1.getSchedules().iterator().next();
MeasurementSchedule schedule2 = resource2.getSchedules().iterator().next();
@@ -166,10 +129,11 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
} catch (Exception e) {
e.printStackTrace();
throw e;
- }
-
- finally {
- unprepareScheduler();
+ } finally {
+ if (em != null) {
+ getTransactionManager().rollback();
+ em.close();
+ }
}
}
@@ -222,10 +186,4 @@ public class MeasurementDataManagerTest extends AbstractEJB3Test {
return em;
}
- private void commitAndClose(EntityManager em) throws Exception {
- getTransactionManager().commit();
- em.close();
- }
-
-
}
13 years, 6 months