Hi all
I'm having some problems porting a page. the page is
'/network/systems/custominfo/edit.pxt' and the problem is displaying
the list of systems with this custom data with the correct pagination.
I can do it with out the pagination but the pxt file used the
pagination so I'm attempting to as well.
Could someone have a look and comment? I'm sure what I've done is pretty close.
Thanks
CC
--
RHCE#805007969328369
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
index ebaf880..9d801e6 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/System_queries.xml
@@ -1819,5 +1819,26 @@ delete from rhnServerNotes where id = :id and server_id = :server_id
</query>
</write-mode>
+<!-- Lifted from web/modules/rhn/RHN/DB/DataSource/xml/System_queries.xml with slight changes -->
+<mode name="users_systems_with_value_for_key">
+ <query params="user_id, cikid">
+SELECT S.id,
+ S.name AS NAME,
+ SCDV.value,
+ TO_CHAR(SI.checkin, 'YYYY-MM-DD') as LAST_CHECKIN
+ FROM rhnServer S,
+ rhnServerCustomDataValue SCDV,
+ rhnUserServerPerms USP,
+ rhnServerInfo SI
+ WHERE USP.user_id = :user_id
+ AND USP.server_id = SCDV.server_id
+ AND SI.server_id = S.id
+ AND SCDV.key_id = :cikid
+ AND USP.server_id = S.id
+ORDER BY UPPER(NVL(S.NAME, '(none)')), S.ID
+ </query>
+ <elaborator name="system_overview" />
+</mode>
+
</datasource_modes>
diff --git a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
index 766c989..965bea7 100644
--- a/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
+++ b/java/code/src/com/redhat/rhn/domain/server/ServerFactory.java
@@ -117,6 +117,23 @@ public class ServerFactory extends HibernateFactory {
"CustomDataValue.findByKey", params);
}
+ /**
+ * Lookup all the systems with the specified CustomDataKey.
+ * @param userId The User ID of the user doing the query
+ * @param cikid The ID of the Key for the values you would like to lookup
+ * @return List of systems
+ */
+ public static List lookupServersWithCustomKey(Long userId, Long cikid) {
+ SelectMode m = ModeFactory.getMode("System_queries",
+ "users_systems_with_value_for_key");
+ Map inParams = new HashMap();
+
+ inParams.put("user_id", userId);
+ inParams.put("cikid", cikid);
+
+ return m.execute(inParams);
+ }
+
/**
* Lookup all storage Devices associated with the server.
* @param s The server for the values you would like to lookup
diff --git a/java/code/src/com/redhat/rhn/frontend/action/systems/customkey/UpdateCustomKeyAction.java b/java/code/src/com/redhat/rhn/frontend/action/systems/customkey/UpdateCustomKeyAction.java
new file mode 100644
index 0000000..ebe7c53
--- /dev/null
+++ b/java/code/src/com/redhat/rhn/frontend/action/systems/customkey/UpdateCustomKeyAction.java
@@ -0,0 +1,104 @@
+/**
+ * Copyright (c) 2009--2010 Red Hat, Inc.
+ *
+ * This software is licensed to you under the GNU General Public License,
+ * version 2 (GPLv2). There is NO WARRANTY for this software, express or
+ * implied, including the implied warranties of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2
+ * along with this software; if not, see
+ * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
+ *
+ * Red Hat trademarks are not licensed under GPLv2. No permission is
+ * granted to use or replicate Red Hat trademarks that are incorporated
+ * in this software or its documentation.
+ */
+package com.redhat.rhn.frontend.action.systems.customkey;
+
+import com.redhat.rhn.domain.org.CustomDataKey;
+import com.redhat.rhn.domain.org.OrgFactory;
+import com.redhat.rhn.domain.server.ServerFactory;
+import com.redhat.rhn.domain.user.User;
+import com.redhat.rhn.frontend.struts.RequestContext;
+import com.redhat.rhn.frontend.struts.RhnAction;
+import com.redhat.rhn.frontend.taglibs.list.ListTagHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListSessionSetHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
+
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+import org.apache.struts.action.DynaActionForm;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Handles the deletion of a key.
+ */
+public class UpdateCustomKeyAction extends RhnAction implements Listable {
+
+ private final String CIKID_PARAM = "cikid";
+ private final String LABEL_PARAM = "label";
+ private final String DESC_PARAM = "description";
+ private final String CREATE_PARAM = "created";
+ private final String MODIFY_PARAM = "modified";
+ private final String CREATOR_PARAM = "creator";
+ private final String MODIFIER_PARAM = "modifier";
+
+ /** {...@inheritdoc} */
+ public ActionForward execute(ActionMapping mapping,
+ ActionForm formIn,
+ HttpServletRequest request,
+ HttpServletResponse response) {
+
+ RequestContext context = new RequestContext(request);
+ DynaActionForm form = (DynaActionForm)formIn;
+
+ User user = context.getLoggedInUser();
+ Long cikid = context.getParamAsLong(CIKID_PARAM);
+ CustomDataKey key = OrgFactory.lookupKeyById(cikid);
+
+ request.setAttribute(CIKID_PARAM, cikid);
+ request.setAttribute(LABEL_PARAM, key.getLabel());
+ request.setAttribute(DESC_PARAM, key.getDescription());
+ request.setAttribute(CREATE_PARAM, key.getCreated());
+ request.setAttribute(MODIFY_PARAM, key.getModified());
+ request.setAttribute(CREATOR_PARAM, key.getCreator().getLogin());
+ request.setAttribute(MODIFIER_PARAM, key.getLastModifier().getLogin());
+
+ List servers = ServerFactory.lookupServersWithCustomKey(user.getId(), cikid);
+ request.setAttribute("server_count", servers.size());
+ request.setAttribute("pageList", servers);
+
+ ListSessionSetHelper helper = new ListSessionSetHelper(this, request);
+ helper.execute();
+
+ if (context.isSubmitted()) {
+ String desc = (String)form.get(DESC_PARAM);
+
+ key.setDescription(desc);
+ key.setModified(new Date());
+
+ ServerFactory.saveCustomKey(key);
+
+ return mapping.findForward("updated");
+ }
+
+ helper.destroy();
+ return mapping.findForward("default");
+ }
+
+ public List getResult(RequestContext context) {
+ User user = context.getLoggedInUser();
+ Long cikid = context.getParamAsLong(CIKID_PARAM);
+ List servers = ServerFactory.lookupServersWithCustomKey(user.getId(), cikid);
+
+ return servers;
+ }
+
+}
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
index c851b87..115c01a 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
@@ -13080,6 +13080,7 @@ the <strong>Red Hat Enterprise Linux System Administration Guide.</stro
</trans-unit>
</group>
+ <!-- custdata/deletekey.jsp -->
<group>
<context-group name="ctx">
<context context-type="sourcefile">/rhn/systems/customdata/DeleteKey.do</context>
@@ -13093,6 +13094,26 @@ the <strong>Red Hat Enterprise Linux System Administration Guide.</stro
</trans-unit>
</group>
+ <!-- custdata/updatekey.jsp -->
+ <group>
+ <context-group name="ctx">
+ <context context-type="sourcefile">/rhn/systems/customdata/UpdateCustomKey.do</context>
+ </context-group>
+
+ <trans-unit id="system.jsp.customkey.updatetitle">
+ <source>Edit Custom Info Key</source>
+ </trans-unit>
+ <trans-unit id="system.jsp.customkey.updatemsg">
+ <source>Define infomation about this key below.</source>
+ </trans-unit>
+ <trans-unit id="system.jsp.customkey.updateheader">
+ <source>Systems with a value for this key</source>
+ </trans-unit>
+ <trans-unit id="system.jsp.customkey.noservers">
+ <source>No systems exist which have a value for this key.</source>
+ </trans-unit>
+ </group>
+
<!-- System Common -->
<group>
<context-group name="ctx">
@@ -22013,6 +22034,9 @@ given channel.</source>
<trans-unit id="system.jsp.customkey.modified">
<source>Last Modified</source>
</trans-unit>
+ <trans-unit id="system.jsp.customkey.created">
+ <source>Created</source>
+ </trans-unit>
<trans-unit id="system.jsp.customkey.createlink">
<source>create new key</source>
</trans-unit>
diff --git a/java/code/webapp/WEB-INF/pages/systems/customkey/listcustomkeys.jsp b/java/code/webapp/WEB-INF/pages/systems/customkey/listcustomkeys.jsp
index fd296bd..42d9d4f 100644
--- a/java/code/webapp/WEB-INF/pages/systems/customkey/listcustomkeys.jsp
+++ b/java/code/webapp/WEB-INF/pages/systems/customkey/listcustomkeys.jsp
@@ -47,7 +47,7 @@
defaultsort="asc"
styleclass="first-column">
- <a href="/network/systems/custominfo/edit.pxt?cikid=${current.id}">
+ <a href="/rhn/systems/customdata/UpdateCustomKey.do?cikid=${current.id}">
<c:out value="${current.label}" />
</a>
</rl:column>
diff --git a/java/code/webapp/WEB-INF/pages/systems/customkey/updatekey.jsp b/java/code/webapp/WEB-INF/pages/systems/customkey/updatekey.jsp
new file mode 100644
index 0000000..3c1dff8
--- /dev/null
+++ b/java/code/webapp/WEB-INF/pages/systems/customkey/updatekey.jsp
@@ -0,0 +1,118 @@
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<%@ taglib uri="http://rhn.redhat.com/rhn" prefix="rhn" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
+<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
+<%@ taglib uri="http://rhn.redhat.com/tags/list" prefix="rl" %>
+
+<html:html xhtml="true">
+<body>
+<br>
+
+
+
+<div>
+ <div class="toolbar-h1">
+ <div class="toolbar">
+ <span class="toolbar">
+ <a href="/rhn/systems/customdata/DeleteCustomKey.do?cikid=${cikid}">
+ <img src="/img/action-del.gif" alt="delete key" title="delete key" />delete key</a>
+ </span>
+ </div>
+ <img src="/img/rhn-icon-keyring.gif" alt="" />
+ <bean:message key="system.jsp.customkey.updatetitle"/>
+
+ <a href="/rhn/help/reference/en-US/s1-sm-systems.jsp#s2-sm-system-cust-info" target="_new" class="help-title">
+ <img src="/img/rhn-icon-help.gif" alt="Help Icon" />
+ </a>
+ </div>
+
+ <div class="page-summary">
+ <p><bean:message key="system.jsp.customkey.updatemsg"/></p>
+ </div>
+
+ <hr />
+
+ <form action="/rhn/systems/customdata/UpdateCustomKey.do?cikid=${cikid}" name="edit_token" method="post">
+ <table class="details">
+ <tr>
+ <th><bean:message key="system.jsp.customkey.keylabel"/>:</th>
+ <td>${label}</td>
+ </tr>
+
+ <tr>
+ <th><bean:message key="system.jsp.customkey.description"/>:</th>
+ <td>
+ <textarea wrap="virtual" rows="6" cols="50" name="description"><c:out value="${description}" /></textarea>
+ </td>
+ </tr>
+
+ <tr>
+ <th><bean:message key="system.jsp.customkey.created"/>:</th>
+ <td>${created} by ${creator}</td>
+ </tr>
+
+ <tr>
+ <th><bean:message key="system.jsp.customkey.modified"/>:</th>
+ <td>${modified} by ${modifier}</td>
+ </tr>
+ </table>
+
+ <div align="right">
+ <hr />
+
+ <input type="submit" name="UpdateKey" value="Update Key" />
+
+ <rhn:submitted/>
+ </div>
+ </form>
+
+</div>
+
+ <h2><bean:message key="system.jsp.customkey.updateheader"/></h2>
+<%--
+ <c:if test="${server_count == 0}">
+ <bean:message key="system.jsp.customkey.noservers"/>
+ </c:if>
+ <c:if test="${server_count != 0}">
+ <rl:listset name="systemListSet" legend="system">
+ <rl:list
+ dataset="pageList"
+ name="systemList"
+ emptykey="nosystems.message"
+ alphabarcolumn="name"
+ filter="com.redhat.rhn.frontend.taglibs.list.filters.SystemOverviewFilter" >
+
+ <rl:decorator name="ElaborationDecorator"/>
+ <rl:decorator name="PageSizeDecorator"/>
+
+ <!-- Name Column -->
+ <rl:column sortable="true"
+ bound="false"
+ headerkey="systemlist.jsp.system"
+ sortattr="name"
+ defaultsort="asc"
+ styleclass="first-column">
+ <a href="/rhn/systems/details/Overview.do?sid=${current.id}">${current.name}</a>
+ </rl:column>
+
+ <!-- Values Column -->
+ <rl:column sortable="false"
+ bound="false"
+ headerkey="cik.update.jsp.value">
+ <c:out value="${current.value}" />
+ </rl:column>
+
+ <!-- Last Checkin Column -->
+ <rl:column sortable="false"
+ bound="false"
+ headerkey="cik.update.jsp.last_checkin"
+ styleclass="last-column">
+ <c:out value="${current.last_checkin}" />
+ </rl:column>
+
+ </rl:list>
+ </rl:listset>
+ </c:if>
+--%>
+ </body>
+</html:html>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml b/java/code/webapp/WEB-INF/struts-config.xml
index c7bd894..50b9612 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -1102,6 +1102,14 @@
<form-property name="submitted" type="java.lang.Boolean" />
</form-bean>
+ <form-bean name="updateCustomDataForm"
+ type="com.redhat.rhn.frontend.struts.ScrubbingDynaActionForm" >
+ <form-property name="cikid" type="java.lang.Long" />
+ <form-property name="label" type="java.lang.String" />
+ <form-property name="description" type="java.lang.String" />
+ <form-property name="submitted" type="java.lang.Boolean" />
+ </form-bean>
+
</form-beans>
<global-exceptions>
@@ -6890,6 +6898,15 @@
<forward name="deleted" path="/systems/customdata/CustomDataList.do" redirect="true"/>
</action>
+ <action path="/systems/customdata/UpdateCustomKey"
+ scope="request"
+ input="/WEB-INF/pages/systems/customkey/updatekey.jsp"
+ type="com.redhat.rhn.frontend.action.systems.customkey.UpdateCustomKeyAction"
+ name="updateCustomDataForm"
+ className="com.redhat.rhn.frontend.struts.RhnActionMapping">
+ <forward name="default" path="/WEB-INF/pages/systems/customkey/updatekey.jsp" />
+ <forward name="updated" path="/systems/customdata/CustomDataList.do" redirect="true"/>
+ </action>
<action path="/software/manage/packages/PackageList"
scope="request"
_______________________________________________
Spacewalk-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/spacewalk-devel