java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
| 8
java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
| 4
java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
| 76 +++-
java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
| 160 ++++++----
java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
| 2
java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
| 88 +++++
java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
| 8
java/code/src/com/redhat/rhn/frontend/strings/jsp/StringResource_en_US.xml
| 45 ++
java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
| 47 ++
java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
| 23 -
java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
| 109 ++++--
java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
| 14
java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
| 89 +++--
java/code/webapp/WEB-INF/struts-config.xml
| 2
schema/spacewalk/oracle/packages/rhn_entitlements.pkb
| 18 -
15 files changed, 498 insertions(+), 195 deletions(-)
New commits:
commit 063f08fc3588bc1ba62bbbfb5188da78b583b36c
Author: Partha Aji <paji(a)redhat.com>
Date: Wed Jun 23 00:07:07 2010 -0400
Added code to get multiorgs org -> software channel ents page work with flex
entitlements
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
index 85ef770..f43463e 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Channel_queries.xml
@@ -354,14 +354,6 @@ SELECT CFO.id, CFO.name, CFO.label, CFO.current_members,
CFO.max_members, CFO.ha
</query>
</mode>
-<mode name="channel_entitlements_for_all_orgs"
class="com.redhat.rhn.frontend.dto.ChannelOverview">
- <query params="">
-SELECT CFO.id, CFO.org_id, CFO.name, CFO.label, CFO.current_members, CFO.max_members,
CFO.has_subscription, CFO.url
- FROM rhnChannelFamilyOverview CFO
- ORDER BY CFO.name DESC
- </query>
-</mode>
-
<mode name="channel_entitlements_for_all_m_orgs"
class="com.redhat.rhn.frontend.dto.MultiOrgEntitlementsDto">
<query params="">
SELECT MAX(cfo.id) as id,
diff --git a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
index b5a7924..916463a 100644
--- a/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
+++ b/java/code/src/com/redhat/rhn/common/db/datasource/xml/Org_queries.xml
@@ -182,8 +182,8 @@ AND sg.org_id != 1
</callable-mode>
<callable-mode name="assign_software_entitlements">
- <query params="channel_family_label from_org_id, to_org_id, quantity">
- {call
rhn_entitlements.assign_channel_entitlement(:channel_family_label,:from_org_id,:to_org_id,:quantity,
0)}
+ <query params="channel_family_label from_org_id, to_org_id, quantity,
flex_quantity">
+ {call
rhn_entitlements.assign_channel_entitlement(:channel_family_label,:from_org_id,:to_org_id,:quantity,
:flex_quantity)}
</query>
</callable-mode>
diff --git a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
index e749c04..9a032ac 100644
--- a/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
+++ b/java/code/src/com/redhat/rhn/domain/channel/ChannelFamily.java
@@ -23,7 +23,6 @@ import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.Set;
/**
@@ -40,7 +39,8 @@ public class ChannelFamily extends BaseDomainHelper {
private Set<Channel> channels = new HashSet<Channel>();
private Set virtSubscriptionLevels = new HashSet();
- private Set<PrivateChannelFamily> privateChannelFamilies;
+ private Set<PrivateChannelFamily> privateChannelFamilies =
+ new HashSet<PrivateChannelFamily>();
/**
* @return Returns the channels.
@@ -190,18 +190,11 @@ public class ChannelFamily extends BaseDomainHelper {
* @return maxmembers of this channelfamily. NULL == unlimited
*/
public Long getMaxMembers(Org orgIn) {
- Long retval = null;
- if (this.privateChannelFamilies != null &&
- this.privateChannelFamilies.size() > 0) {
- Iterator i = this.privateChannelFamilies.iterator();
- while (i.hasNext()) {
- PrivateChannelFamily pcf = (PrivateChannelFamily) i.next();
- if (pcf.getOrg().getId().equals(orgIn.getId())) {
- retval = pcf.getMaxMembers();
- }
- }
+ PrivateChannelFamily pcf = getAllocation(orgIn);
+ if (pcf != null) {
+ return pcf.getMaxMembers();
}
- return retval;
+ return null;
}
/**
@@ -210,20 +203,55 @@ public class ChannelFamily extends BaseDomainHelper {
* @return currentMembers of this channelfamily.
*/
public Long getCurrentMembers(Org orgIn) {
- Long retval = null;
- if (this.privateChannelFamilies != null &&
- this.privateChannelFamilies.size() > 0) {
- Iterator i = this.privateChannelFamilies.iterator();
- while (i.hasNext()) {
- PrivateChannelFamily pcf = (PrivateChannelFamily) i.next();
- if (pcf.getOrg().equals(orgIn)) {
- retval = pcf.getCurrentMembers();
- }
- }
+ PrivateChannelFamily pcf = getAllocation(orgIn);
+ if (pcf != null) {
+ return pcf.getCurrentMembers();
}
- return retval;
+ return null;
}
+
+ /**
+ * Get max flex members of this channel family. NULL means unlimited
+ * @param orgIn org to lookup the max flex embers for
+ * @return max flex members of this channelfamily. NULL == unlimited
+ */
+ public Long getMaxFlex(Org orgIn) {
+ PrivateChannelFamily pcf = getAllocation(orgIn);
+ if (pcf != null) {
+ return pcf.getMaxFlex();
+ }
+ return null;
+ }
+
+ /**
+ * Get current flex members of this channel family.
+ * @param orgIn org to lookup the current flex members for
+ * @return currentflex Members of this channelfamily.
+ */
+ public Long getCurrentFlex(Org orgIn) {
+ PrivateChannelFamily pcf = getAllocation(orgIn);
+ if (pcf != null) {
+ return pcf.getCurrentFlex();
+ }
+ return null;
+ }
+
+
+ /**
+ * returns the channel family allocation of this channel family
+ * in the given org
+ * @param orgIn the org whose allocation is requested
+ * @return the channel allocation
+ */
+ private PrivateChannelFamily getAllocation(Org orgIn) {
+ for (PrivateChannelFamily alloc : getPrivateChannelFamilies()) {
+ if (orgIn.equals(alloc.getOrg())) {
+ return alloc;
+ }
+ }
+ return null;
+ }
/**
* @return Returns the privateChannelFamilies.
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
index 2294739..ea05a15 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/OrgSoftwareSubscriptionsAction.java
@@ -15,14 +15,18 @@
package com.redhat.rhn.frontend.action.multiorg;
import com.redhat.rhn.common.validator.ValidatorError;
+import com.redhat.rhn.common.validator.ValidatorException;
import com.redhat.rhn.domain.channel.ChannelFamily;
import com.redhat.rhn.domain.channel.ChannelFamilyFactory;
import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import com.redhat.rhn.frontend.dto.ChannelOverview;
+import com.redhat.rhn.frontend.dto.OrgChannelFamily;
import com.redhat.rhn.frontend.struts.RequestContext;
import com.redhat.rhn.frontend.struts.RhnAction;
import com.redhat.rhn.frontend.struts.RhnValidationHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.ListHelper;
+import com.redhat.rhn.frontend.taglibs.list.helper.Listable;
import com.redhat.rhn.manager.channel.ChannelManager;
import com.redhat.rhn.manager.org.UpdateOrgSoftwareEntitlementsCommand;
@@ -34,10 +38,10 @@ 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.Iterator;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -47,33 +51,61 @@ import javax.servlet.http.HttpServletResponse;
* OrgSoftwareSubscriptionsAction - updates the Channel subs for a single org
* @version $Rev: 1 $
*/
-public class OrgSoftwareSubscriptionsAction extends RhnAction {
-
+public class OrgSoftwareSubscriptionsAction extends RhnAction implements Listable {
+ private static final String SUBSCRIPTIONS = "subscriptions";
private static Logger log = Logger.getLogger(OrgSoftwareSubscriptionsAction.class);
+ private static String makeLabel(HttpServletRequest request) {
+ RequestContext ctx = new RequestContext(request);
+ Long oid = ctx.getParamAsLong(RequestContext.ORG_ID);
+ return "OrgSoftwareSubscriptions" + oid;
+ }
+
/** {@inheritDoc} */
public ActionForward execute(ActionMapping mapping,
ActionForm formIn,
HttpServletRequest request,
HttpServletResponse response) {
- DynaActionForm dynaForm = (DynaActionForm) formIn;
RequestContext ctx = new RequestContext(request);
Long oid = ctx.getParamAsLong(RequestContext.ORG_ID);
Org org = OrgFactory.lookupById(oid);
request.setAttribute("org", org);
- request.setAttribute("parentUrl", request.getRequestURI());
+
+ Map params = new HashMap();
+ params.put(RequestContext.ORG_ID, oid);
+ ListHelper helper = new ListHelper(this, request, params);
+ helper.execute();
+ if (!ctx.isSubmitted()) {
+ Map<String, String> subsMap = new HashMap<String, String>();
+ List <OrgChannelFamily> subs = helper.getDataSet();
+ for (OrgChannelFamily sub : subs) {
+ if (sub.getMaxAvailable() > 0) {
+ subsMap.put(sub.getKey(), sub.getMaxMembers().toString());
+ }
+ if (sub.getMaxAvailableFlex() > 0) {
+ subsMap.put(sub.getFlexKey(), sub.getMaxFlex().toString());
+ }
+ }
+ request.getSession().setAttribute(makeLabel(request), subsMap);
+ }
+ else {
+ Map <String, String> subsMap = (Map <String, String>)
+
request.getSession().getAttribute(makeLabel(request));
+ for (String id : subsMap.keySet()) {
+ if (request.getParameter(id) != null) {
+ subsMap.put(id, request.getParameter(id));
+ }
+ }
+ }
+ request.setAttribute(SUBSCRIPTIONS,
+ request.getSession().getAttribute(makeLabel(request)));
+
ActionForward retval =
- getStrutsDelegate().forwardParam(mapping.findForward("default"),
- "oid", oid.toString());
+ mapping.findForward("default");
- // Used to tell if we're submitting the form for pagination or an actual
- // form submit.
- String updateOrgs = request.getParameter("updateOrganizations");
- boolean update = (updateOrgs != null) &&
(!updateOrgs.equals("0"));
- if (isSubmitted(dynaForm) && update) {
-
+ if (ctx.wasDispatched("orgdetails.jsp.submit")) {
ActionErrors ae = updateSubscriptions(org, request);
if (ae != null && ae.size() > 0) {
getStrutsDelegate().saveMessages(request, ae);
@@ -81,68 +113,88 @@ public class OrgSoftwareSubscriptionsAction extends RhnAction {
"oid", oid.toString());
}
- else {
+ else {
createSuccessMessage(request,
"org.entitlements.syssoft.success", null);
retval =
getStrutsDelegate().forwardParam(mapping.findForward("success"),
"oid", oid.toString());
+ request.getSession().removeAttribute(makeLabel(request));
}
}
- setupFormValues(org, request);
-
return retval;
}
- void setupFormValues(Org org, HttpServletRequest request) {
- request.setAttribute("pageList", ChannelManager.
- listChannelFamilySubscriptionsFor(org));
- }
- private ActionErrors updateSubscriptions(Org org, HttpServletRequest request) {
- List entitlements = ChannelManager.entitlements(
- OrgFactory.getSatelliteOrg().getId(), null);
-
+ private ActionErrors updateSubscriptions(Org org, HttpServletRequest request) {
if (org.getId().equals(OrgFactory.getSatelliteOrg().getId())) {
return RhnValidationHelper.validatorErrorToActionErrors(
new ValidatorError("org.entitlements.system.defaultorg"));
}
ActionErrors errors = new ActionErrors();
- Iterator i = entitlements.iterator();
- while (i.hasNext()) {
- ChannelOverview co = (ChannelOverview) i.next();
+
+ Map <String, String> subsMap = (Map <String, String>)
+ request.getAttribute(SUBSCRIPTIONS);
+
+ List <ChannelOverview> entitlements = ChannelManager.entitlements(
+ OrgFactory.getSatelliteOrg().getId(), null);
+
+ for (ChannelOverview co : entitlements) {
ChannelFamily cfm = ChannelFamilyFactory.lookupById(co.getId().longValue());
- String count = (String) request.getParameter(co.getId().toString());
- // check for bad numbers
- if (count != null) {
- // check for invalid number format
- try {
- Long.parseLong(count.trim());
+ String regCountKey = OrgChannelFamily.makeKey(co.getId());
+ try {
+ Long regCount = subsMap.containsKey(regCountKey) ?
+ processCount(subsMap.get(regCountKey), errors, cfm) : 0;
+ if (regCount != null) {
+ String flexCountKey = OrgChannelFamily.makeFlexKey(co.getId());
+ Long flex = subsMap.containsKey(flexCountKey) ?
+ processCount(subsMap.get(flexCountKey), errors, cfm) : 0;
+
+ if (flex != null && regCount != null) {
+ UpdateOrgSoftwareEntitlementsCommand cmd =
+ new UpdateOrgSoftwareEntitlementsCommand(cfm.getLabel(), org,
+ regCount, flex);
+ ValidatorError ve = cmd.store();
+ if (ve != null) {
+ errors.add(
+
RhnValidationHelper.validatorErrorToActionErrors(ve));
+ }
+ }
}
- catch (NumberFormatException ex) {
- ValidatorError error = new ValidatorError(
- "orgsoftwaresubs.invalid", cfm.getName());
- return (RhnValidationHelper.validatorErrorToActionErrors(error));
- }
}
-
- if (count != null && !StringUtils.isEmpty(count)) {
- //Test id is a number
- if (!StringUtils.isNumeric(count)) {
- errors.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("orgsoftwaresubs.edit.ent",
cfm.getName()));
- continue;
- }
- UpdateOrgSoftwareEntitlementsCommand cmd =
- new UpdateOrgSoftwareEntitlementsCommand(cfm.getLabel(), org,
- new Long(count));
- ValidatorError ve = cmd.store();
- if (ve != null) {
- errors.add(RhnValidationHelper.validatorErrorToActionErrors(ve));
- }
+ catch (ValidatorException ve) {
+ errors.add(RhnValidationHelper.validatorErrorToActionErrors(
+ ve.getResult().getErrors().get(0)));
}
}
return errors;
}
+
+
+ private Long processCount(String count, ActionErrors errors, ChannelFamily cfm) {
+ if (!StringUtils.isBlank(count)) {
+ // check for invalid number format
+ try {
+ return Long.parseLong(count.trim());
+ }
+ catch (NumberFormatException ex) {
+ ValidatorException.raiseException("orgsoftwaresubs.invalid",
cfm.getName());
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public List getResult(RequestContext contextIn) {
+ Org org = (Org)contextIn.getRequest().getAttribute("org");
+ List<OrgChannelFamily> subs = ChannelManager.
+ listChannelFamilySubscriptionsFor(org);
+ return subs;
+ }
+
+
}
diff --git
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
index 2292227..b5841ab 100644
---
a/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
+++
b/java/code/src/com/redhat/rhn/frontend/action/multiorg/SoftwareEntitlementSubscriptionsAction.java
@@ -223,7 +223,7 @@ public class SoftwareEntitlementSubscriptionsAction extends RhnAction
{
UpdateOrgSoftwareEntitlementsCommand updateCmd = null;
try {
updateCmd = new
UpdateOrgSoftwareEntitlementsCommand(channelFamily.getLabel(),
- org, newCount);
+ org, newCount, 0L);
}
catch (IllegalArgumentException e) {
ValidatorError error = new ValidatorError(
diff --git a/java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
b/java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
index 939bd79..50b4fa3 100644
--- a/java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
+++ b/java/code/src/com/redhat/rhn/frontend/dto/OrgChannelFamily.java
@@ -14,6 +14,8 @@
*/
package com.redhat.rhn.frontend.dto;
+import com.redhat.rhn.domain.org.OrgFactory;
+
/**
* OrgChannelFamily
@@ -23,8 +25,73 @@ public class OrgChannelFamily extends ChannelOverview {
private Long satelliteMaxMembers;
private Long satelliteCurrentMembers;
+ private Long satelliteMaxFlexMembers;
+ private Long satelliteCurrentFlexMembers;
+
+ /**
+ * @return the key
+ */
+ public String getKey() {
+ return makeKey(getId());
+ }
+
+ /**
+ * @return the key
+ */
+ public String getFlexKey() {
+ return makeFlexKey(getId());
+ }
+
+
+ /**
+ * @param id the id of the channel family
+ * @return the key
+ */
+ public static String makeKey(Long id) {
+ return String.valueOf(id);
+ }
/**
+ * @param id the id of the channel family
+ * @return the key
+ */
+ public static String makeFlexKey(Long id) {
+ return id + "-flex";
+ }
+
+
+ /**
+ * @return Returns the satelliteMaxFlexMembers.
+ */
+ public Long getSatelliteMaxFlex() {
+ return satelliteMaxFlexMembers;
+ }
+
+
+ /**
+ * @param satelliteMaxFlexMembersIn The satelliteMaxFlexMembers to set.
+ */
+ public void setSatelliteMaxFlex(Long satelliteMaxFlexMembersIn) {
+ satelliteMaxFlexMembers = satelliteMaxFlexMembersIn;
+ }
+
+
+ /**
+ * @return Returns the satelliteCurrentFlexMembers.
+ */
+ public Long getSatelliteCurrentFlex() {
+ return satelliteCurrentFlexMembers;
+ }
+
+
+ /**
+ * @param satelliteCurrentFlexMembersIn The satelliteCurrentFlexMembers to set.
+ */
+ public void setSatelliteCurrentFlex(Long satelliteCurrentFlexMembersIn) {
+ satelliteCurrentFlexMembers = satelliteCurrentFlexMembersIn;
+ }
+
+ /**
* @return Returns the satelliteMaxMembers.
*/
public Long getSatelliteMaxMembers() {
@@ -52,4 +119,25 @@ public class OrgChannelFamily extends ChannelOverview {
this.satelliteCurrentMembers = satelliteCurrentMembersIn;
}
+ /**
+ * the maximum number of the available slots
+ * @return the number of slots
+ */
+ public long getMaxAvailable() {
+ if (OrgFactory.getSatelliteOrg().getId().equals(getOrgId())) {
+ return getMaxMembers();
+ }
+ return getSatelliteMaxMembers() - getSatelliteCurrentMembers() +
getMaxMembers();
+ }
+
+ /**
+ * the maximum number of the available flex slots
+ * @return the number of slots
+ */
+ public long getMaxAvailableFlex() {
+ if (OrgFactory.getSatelliteOrg().getId().equals(getOrgId())) {
+ return getMaxFlex();
+ }
+ return getSatelliteMaxFlex() - getSatelliteCurrentFlex() + getMaxFlex();
+ }
}
diff --git a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
index 3987ef8..d8a94a6 100644
--- a/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
+++ b/java/code/src/com/redhat/rhn/frontend/strings/java/StringResource_en_US.xml
@@ -7992,8 +7992,12 @@ Follow this url to see the full list of inactive systems:
<source>Entitlements successfully updated.</source>
</trans-unit>
- <trans-unit id="org.entitlements.software.toomany">
- <source>You attempted to give {0} too many {1} entitlements. Please
enter a value lower than or equal to {2}</source>
+ <trans-unit id="org.entitlements.software.not_in_range">
+ <source>You attempted to give {0} too many {1} entitlements. Please
enter a value between {2} and {3}</source>
+ </trans-unit>
+
+ <trans-unit id="org.entitlements.software.not_in_range.flex">
+ <source>You attempted to give {0} too many {1} flex entitlements. Please
enter a value between {2} and {3}</source>
</trans-unit>
<trans-unit id="org.entitlements.software.proposedwarning">
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 205a90d..98cc570 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
@@ -4563,6 +4563,51 @@ deducted from the default organization.</source>
<context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
</context-group>
</trans-unit>
+ <trans-unit id="No Entitlements Available">
+<source>No Entitlements Available</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Regular Usage">
+<source>Regular Usage</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Regular Proposed Total">
+<source>Regular Proposed Total</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Flex Usage">
+<source>Flex Usage</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Flex Proposed Total">
+<source>Flex Proposed Total</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+ <trans-unit id="Entitlement Usage Type">
+<source>Used / Total</source>
+ <context-group name="ctx">
+ <context
context-type="sourcefile">/rhn/admin/multiorg/OrgSoftwareSubscriptions</context>
+ </context-group>
+ </trans-unit>
+
+
+
+
<trans-unit id="softwareEntitlementDetails.noChannelsFound">
<source>No channels found.</source>
<context-group name="ctx">
diff --git a/java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
b/java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
index 482d139..7773785 100644
--- a/java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
+++ b/java/code/src/com/redhat/rhn/frontend/xmlrpc/org/OrgHandler.java
@@ -508,13 +508,12 @@ public class OrgHandler extends BaseHandler {
String channelFamilyLabel, Integer allocation) {
getSatAdmin(sessionKey);
-
Org org = verifyOrgExists(orgId);
lookupChannelFamily(channelFamilyLabel);
UpdateOrgSoftwareEntitlementsCommand cmd =
new UpdateOrgSoftwareEntitlementsCommand(channelFamilyLabel, org,
- new Long(allocation));
+ Long.valueOf(allocation), 0L);
ValidatorError ve = cmd.store();
if (ve != null) {
throw new ValidationException(ve.getMessage());
@@ -524,6 +523,50 @@ public class OrgHandler extends BaseHandler {
}
/**
+ * Set an organizations entitlement allocation for a channel family.
+ *
+ * If increasing the entitlement allocation, the default organization
+ * must have a sufficient number of free entitlements.
+ *
+ * @param sessionKey User's session key.
+ * @param orgId Organization ID to set allocation for.
+ * @param channelFamilyLabel Channel family to set allocation for.
+ * @param allocation New flex entitlement allocation.
+ * @return 1 on success.
+ *
+ * @xmlrpc.doc Set an organization's flex entitlement allocation for the given
software
+ * entitlement.
+ *
+ * If increasing the flex entitlement allocation, the default organization
+ * (i.e. orgId=1) must have a sufficient number of free flex entitlements.
+ *
+ * @xmlrpc.param #param("string", "sessionKey")
+ * @xmlrpc.param #param("int", "orgId")
+ * @xmlrpc.param #param_desc("string", "label", "Software
entitlement label.")
+ * @xmlrpc.param #param("int", "allocation")
+ * @xmlrpc.returntype #return_int_success()
+ */
+ public int setSoftwareFlexEntitlements(String sessionKey, Integer orgId,
+ String channelFamilyLabel, Integer allocation) {
+
+ getSatAdmin(sessionKey);
+ Org org = verifyOrgExists(orgId);
+ lookupChannelFamily(channelFamilyLabel);
+
+ UpdateOrgSoftwareEntitlementsCommand cmd =
+ new UpdateOrgSoftwareEntitlementsCommand(channelFamilyLabel, org,
+ 0L, Long.valueOf(allocation));
+ ValidatorError ve = cmd.store();
+ if (ve != null) {
+ throw new ValidationException(ve.getMessage());
+ }
+
+ return 1;
+ }
+
+
+
+ /**
* Lookup a channel family, throwing an exception if it cannot be found.
*
* @param channelFamilyLabel Channel family label to look up.
diff --git a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
index 253676b..c773824 100644
--- a/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
+++ b/java/code/src/com/redhat/rhn/manager/channel/ChannelManager.java
@@ -248,20 +248,28 @@ public class ChannelManager extends BaseManager {
}
for (ChannelOverview sato : satEntitlements) {
- ChannelOverview orgo = orgMap.get(sato.getId());
OrgChannelFamily ocf = new OrgChannelFamily();
+
ocf.setSatelliteCurrentMembers(sato.getCurrentMembers());
ocf.setSatelliteMaxMembers(sato.getMaxMembers());
+ ocf.setSatelliteCurrentFlex(sato.getCurrentFlex());
+ ocf.setSatelliteMaxFlex(sato.getMaxFlex());
ocf.setId(sato.getId());
ocf.setName(sato.getName());
ocf.setLabel(sato.getLabel());
+
+ ChannelOverview orgo = orgMap.get(sato.getId());
if (orgo == null) {
ocf.setCurrentMembers(new Long(0));
ocf.setMaxMembers(new Long(0));
+ ocf.setMaxFlex(0L);
+ ocf.setCurrentFlex(0L);
}
else {
ocf.setCurrentMembers(orgo.getCurrentMembers());
ocf.setMaxMembers(orgo.getMaxMembers());
+ ocf.setMaxFlex(orgo.getMaxFlex());
+ ocf.setCurrentFlex(orgo.getCurrentFlex());
}
if (ocf.getSatelliteMaxMembers() != null) {
ret.add(ocf);
@@ -272,19 +280,6 @@ public class ChannelManager extends BaseManager {
/**
* Returns a list channel entitlements for all orgs.
- * @param pc The PageControl
- * @return channel entitlements
- */
- public static DataResult<ChannelOverview> entitlementsForAllOrgs(PageControl
pc) {
- SelectMode m = ModeFactory.getMode("Channel_queries",
- "channel_entitlements_for_all_orgs");
-
- Map params = new HashMap();
- return makeDataResult(params, params, pc, m);
- }
-
- /**
- * Returns a list channel entitlements for all orgs.
* @return channel entitlements for multiorgs
*/
public static DataList<MultiOrgEntitlementsDto> entitlementsForAllMOrgs() {
diff --git
a/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
b/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
index 069e60b..0f67f81 100644
--- a/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
+++ b/java/code/src/com/redhat/rhn/manager/org/UpdateOrgSoftwareEntitlementsCommand.java
@@ -24,6 +24,7 @@ import
com.redhat.rhn.domain.org.Org;
import com.redhat.rhn.domain.org.OrgFactory;
import org.apache.log4j.Logger;
+import org.apache.tools.ant.taskdefs.condition.IsFileSelected;
import java.util.HashMap;
import java.util.Map;
@@ -42,6 +43,7 @@ public class UpdateOrgSoftwareEntitlementsCommand {
private Org org;
private long newTotal;
+ private long newFlexTotal;
private ChannelFamily channelFamily;
/**
@@ -49,14 +51,17 @@ public class UpdateOrgSoftwareEntitlementsCommand {
* @param channelFamilyLabel label of entitlement to update
* @param orgIn to update totals for
* @param newTotalIn This is the *proposed* new total for the org you are passing
in.
+ * @param newFlexTotalIn This is the *proposed* new flex total
+ * for the org you are passing in.
*/
public UpdateOrgSoftwareEntitlementsCommand(String channelFamilyLabel,
- Org orgIn, Long newTotalIn) {
+ Org orgIn, Long newTotalIn, Long newFlexTotalIn) {
if (orgIn.getId().equals(OrgFactory.getSatelliteOrg().getId())) {
throw new IllegalArgumentException("Cant update the default org");
}
this.org = orgIn;
this.newTotal = newTotalIn;
+ this.newFlexTotal = newFlexTotalIn;
this.channelFamily = ChannelFamilyFactory.lookupByLabel(channelFamilyLabel,
OrgFactory.getSatelliteOrg());
if (this.channelFamily == null) {
@@ -70,16 +75,13 @@ public class UpdateOrgSoftwareEntitlementsCommand {
* @return if we should force unentitlement if
* current members is greater then proposed entitlement count
*/
- private boolean forceUnentitlement() {
+ private boolean forceUnentitlement(Long orgCur, Long orgProposedMax) {
boolean retval = true;
-
- Long orgCur = this.channelFamily.getCurrentMembers(this.org);
-
if (orgCur == null) {
- orgCur = new Long(0);
+ orgCur = 0L;
}
- if (orgCur > this.newTotal &&
!ConfigDefaults.get().forceUnentitlement()) {
+ if (orgCur > orgProposedMax &&
!ConfigDefaults.get().forceUnentitlement()) {
retval = false;
}
return retval;
@@ -89,32 +91,62 @@ public class UpdateOrgSoftwareEntitlementsCommand {
* Update the entitlements in the DB.
* @return ValidatorError if there were any problems with the proposed total
*/
- public ValidatorError store() {
-
+ public ValidatorError store() {
+ ValidatorError err = null;
+ err = storeRegular();
+ if (err == null) {
+ return storeFlex();
+ }
+ return err;
+ }
+
+ private ValidatorError storeRegular() {
// Check available entitlements
Org satOrg = OrgFactory.getSatelliteOrg();
- Long avail = new Long(0);
- Long maxMem = this.channelFamily.getMaxMembers(satOrg);
- Long current = this.channelFamily.getMaxMembers(this.org);
-
- if (current == null) {
- current = new Long(0);
+ return store(channelFamily.getMaxMembers(satOrg),
+ channelFamily.getMaxMembers(org),
+ channelFamily.getCurrentMembers(satOrg),
+ channelFamily.getCurrentMembers(org),
+ newTotal, false);
+ }
+
+ private ValidatorError storeFlex() {
+ // Check available entitlements
+ Org satOrg = OrgFactory.getSatelliteOrg();
+ return store(channelFamily.getMaxFlex(satOrg),
+ channelFamily.getMaxFlex(org),
+ channelFamily.getCurrentFlex(satOrg),
+ channelFamily.getCurrentFlex(org),
+ newFlexTotal, true);
+ }
+
+ private ValidatorError store(Long satMax, Long orgMax,
+ Long satCurrent, Long orgCurrent,
+ Long proposed, boolean isFlex) {
+ // No sense making the call if its the same.
+ if (orgMax == proposed) {
+ return null;
}
- if (maxMem != null) {
- avail = maxMem -
- this.channelFamily.getCurrentMembers(satOrg) +
- current;
+
+ if (orgMax == null) {
+ orgMax = 0L;
+ }
+
+ Long avail = 0L;
+ if (satMax != null) {
+ avail = satMax - satCurrent + orgMax;
}
-
- if (avail < this.newTotal) {
- return new ValidatorError("org.entitlements.software.toomany",
- this.org.getName(),
- this.channelFamily.getName(),
- avail);
+
+ if (proposed == null || proposed < 0 || avail < proposed) {
+ String key = isFlex ? "org.entitlements.software.not_in_range.flex"
:
+ "org.entitlements.software.not_in_range";
+
+ return new ValidatorError(key, this.org.getName(),
+ this.channelFamily.getName(), 0, avail);
}
// Proposed cannot be lower than current members
- if (!forceUnentitlement()) {
+ if (!forceUnentitlement(orgCurrent, proposed)) {
return new ValidatorError(
"org.entitlements.software.proposedwarning",
this.channelFamily.getName(),
@@ -122,25 +154,21 @@ public class UpdateOrgSoftwareEntitlementsCommand {
);
}
- // No sense making the call if its the same.
- if (current.longValue() == this.newTotal) {
- return null;
- }
-
+
Long toOrgId;
Long fromOrgId;
long actualTotal;
// If we are decreasing the # of entitlements
// we give back to the default org.
- if (current.longValue() > this.newTotal) {
+ if (orgMax.longValue() > proposed) {
fromOrgId = this.org.getId();
toOrgId = OrgFactory.getSatelliteOrg().getId();
- actualTotal = current.longValue() - this.newTotal;
+ actualTotal = orgMax.longValue() - proposed;
}
else {
toOrgId = this.org.getId();
fromOrgId = OrgFactory.getSatelliteOrg().getId();
- actualTotal = this.newTotal - current.longValue();
+ actualTotal = proposed - orgMax.longValue();
}
Map in = new HashMap();
@@ -148,12 +176,19 @@ public class UpdateOrgSoftwareEntitlementsCommand {
in.put("channel_family_label", channelFamily.getLabel());
in.put("from_org_id", fromOrgId);
in.put("to_org_id", toOrgId);
- in.put("quantity", actualTotal);
+ if (isFlex) {
+ in.put("quantity", 0);
+ in.put("flex_quantity", actualTotal);
+
+ }
+ else {
+ in.put("quantity", actualTotal);
+ in.put("flex_quantity", 0);
+
+ }
CallableMode m = ModeFactory.getCallableMode(
"Org_queries", "assign_software_entitlements");
m.execute(in, new HashMap());
return null;
}
-
-
}
diff --git
a/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
b/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
index f69ab00..f75f95d 100644
---
a/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
+++
b/java/code/src/com/redhat/rhn/manager/org/test/UpdateOrgSoftwareEntitlementsTest.java
@@ -83,7 +83,7 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
// Now give the remaining:
cmd = new UpdateOrgSoftwareEntitlementsCommand(fam.getLabel(), user.getOrg(),
- ChannelFamilyFactoryTest.ENTITLEMENT_ALLOCATION);
+ ChannelFamilyFactoryTest.ENTITLEMENT_ALLOCATION, 0L);
assertNull(cmd.store());
}
@@ -91,18 +91,18 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
Long orig = fam.getMaxMembers(OrgFactory.getSatelliteOrg());
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), new Long(1), 0L);
assertNull(cmd.store());
reloadFamilies();
Long now = fam.getMaxMembers(OrgFactory.getSatelliteOrg()).longValue();
assertEquals(orig.longValue() - 1, now.longValue());
cmd = new UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), new Long(1), 0L);
assertNull(cmd.store());
reloadFamilies();
assertEquals(orig.longValue() - 1, now.longValue());
cmd = new UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(0));
+ fam.getLabel(), user.getOrg(), new Long(0), 0L);
cmd.store();
reloadFamilies();
now = fam.getMaxMembers(OrgFactory.getSatelliteOrg()).longValue();
@@ -114,11 +114,11 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
Long origValue = fam.getMaxMembers(OrgFactory.getSatelliteOrg());
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), new Long(1), 0L);
assertNull(cmd.store());
reloadFamilies();
cmd = new UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(2));
+ fam.getLabel(), user.getOrg(), new Long(2), 0L);
assertNull(cmd.store());
reloadFamilies();
assertEquals(2, fam.getMaxMembers(user.getOrg()).longValue());
@@ -135,7 +135,7 @@ public class UpdateOrgSoftwareEntitlementsTest extends
BaseTestCaseWithUser {
}
}
UpdateOrgSoftwareEntitlementsCommand cmd = new
UpdateOrgSoftwareEntitlementsCommand(
- fam.getLabel(), user.getOrg(), new Long(1));
+ fam.getLabel(), user.getOrg(), new Long(1), 0L);
assertNull(cmd.store());
}
diff --git a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
index 58f3ee0..d2f2314 100644
--- a/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
+++ b/java/code/webapp/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp
@@ -44,55 +44,76 @@
<rl:listset name="entitlementSet">
<rhn:submitted/>
<input type="hidden" name="oid"
value="${param.oid}"/>
- <!-- Hack to get around the problem with form submitting when doing
- pagination. See javascript attached to the submit button below. -->
- <input type="hidden" name="updateOrganizations"
value="0"/>
-
- <rl:list dataset="pageList"
+ <rl:list
width="100%"
- name="userList"
styleclass="list"
emptykey="orgsoftwaresubs.jsp.nochannelfams">
- <rl:column bound="false"
- sortable="false"
+ <rl:column
+ filterattr="name"
headerkey="entitlements.jsp.channel"
styleclass="first-column">
<a
href="/rhn/admin/multiorg/SoftwareEntitlementDetails.do?cfid=${current.id}"><c:out
value="${current.name}" /></a>
</rl:column>
- <rl:column bound="false"
- sortable="false"
- headerkey="orgsystemsubs.jsp.total">
- <c:out value="${current.maxMembers}" />
- </rl:column>
- <rl:column bound="false"
- sortable="false"
- headerkey="orgsystemsubs.jsp.usage">
- <c:out value="${current.currentMembers}" />
+ <rl:column styleclass="center"
+ headertext="${rhn:localize('Regular Usage')}
<br/>(${rhn:localize('Entitlement Usage Type')})">
+ <c:out value="${current.currentMembers} / ${current.maxMembers}"
/>
</rl:column>
- <rl:column bound="false"
- sortable="false"
- headerkey="orgsystemsubs.jsp.proposed_total"
styleclass="last-column">
- <c:choose>
- <c:when test="${param.oid != 1}">
- <input name="${current.id}"
value="${current.maxMembers}" type="text"
- onkeydown="return blockEnter(event)">
- <br>
- <span class="small-text"><bean:message
key="orgsystemsubs.jsp.possible_vals"
- arg0="0" arg1="${current.satelliteMaxMembers -
current.satelliteCurrentMembers + current.maxMembers}"/></span>
- </c:when>
- <c:otherwise>
- ${current.maxMembers}
- </c:otherwise>
- </c:choose>
+ <rl:column
+ headerkey="Regular Proposed Total">
+ <c:choose>
+ <c:when test = "${current.maxAvailable == 0}">
+ <bean:message key="No Entitlements Available"/>
+ </c:when>
+ <c:otherwise>
+ <c:choose>
+ <c:when test="${param.oid != 1}">
+ <input name="${current.key}"
value="${requestScope.subscriptions[current.key]}" type="text" size =
"13"
+ onkeydown="return blockEnter(event)">
+ <br>
+ <span class="small-text"><bean:message
key="orgsystemsubs.jsp.possible_vals"
+ arg0="0"
arg1="${current.maxAvailable}"/></span>
+ </c:when>
+ <c:otherwise>
+ ${current.maxAvailable}
+ </c:otherwise>
+ </c:choose>
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
+ <rl:column styleclass="center"
+ headertext="${rhn:localize('Flex Usage')}
<br/>(${rhn:localize('Entitlement Usage Type')})">
+ <c:out value="${current.currentFlex} / ${current.maxFlex}"
/>
</rl:column>
+ <rl:column bound="false"
+ sortable="false"
+ headerkey="Flex Proposed Total"
styleclass="last-column">
+ <c:choose>
+ <c:when test = "${current.maxAvailableFlex == 0}">
+ <bean:message key="No Entitlements Available"/>
+ </c:when>
+ <c:otherwise>
+ <c:choose>
+ <c:when test="${param.oid != 1}">
+ <input name="${current.flexKey}"
value="${requestScope.subscriptions[current.flexKey]}" type="text"
size = "13"
+ onkeydown="return blockEnter(event)">
+ <br>
+ <span class="small-text"><bean:message
key="orgsystemsubs.jsp.possible_vals"
+ arg0="0"
arg1="${current.maxAvailableFlex}"/></span>
+ </c:when>
+ <c:otherwise>
+ ${current.maxAvailableFlex}
+ </c:otherwise>
+ </c:choose>
+ </c:otherwise>
+ </c:choose>
+ </rl:column>
</rl:list>
<c:if test="${param.oid != 1}">
<div align="right">
<hr/>
- <input type="submit" name="dispatch"
value="${rhn:localize('orgdetails.jsp.submit')}"
- onclick="this.form.updateOrganizations.value = '1';return
true;">
+ <input type="submit" name="dispatch"
value="${rhn:localize('orgdetails.jsp.submit')}"/>
</div>
</c:if>
</rl:listset>
diff --git a/java/code/webapp/WEB-INF/struts-config.xml
b/java/code/webapp/WEB-INF/struts-config.xml
index 205b830..774bee6 100644
--- a/java/code/webapp/WEB-INF/struts-config.xml
+++ b/java/code/webapp/WEB-INF/struts-config.xml
@@ -4536,7 +4536,7 @@
<forward name="success"
path="/admin/multiorg/OrgSoftwareSubscriptions.do"
redirect="true" />
<forward name="error"
- path="/admin/multiorg/OrgSoftwareSubscriptions.do"
redirect="true" />
+ path="/WEB-INF/pages/admin/multiorg/orgsoftwaresubs.jsp"/>
</action>
<action path="/admin/multiorg/SoftwareEntitlements"
diff --git a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
index 22da3ca..80d963b 100644
--- a/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
+++ b/schema/spacewalk/oracle/packages/rhn_entitlements.pkb
@@ -1152,8 +1152,8 @@ is
flex_in in number
)
is
- prev_ent_count number;
- prev_ent_count_flex number;
+ from_org_prev_ent_count number;
+ from_org_prev_ent_count_flex number;
new_ent_count number;
new_ent_count_flex number;
to_org_prev_ent_count number;
@@ -1165,7 +1165,7 @@ is
begin
select max_members
- into prev_ent_count
+ into from_org_prev_ent_count
from rhnChannelFamily cf,
rhnPrivateChannelFamily pcf
where pcf.org_id = from_org_id_in
@@ -1192,7 +1192,7 @@ is
begin
select fve_max_members
- into prev_ent_count_flex
+ into from_org_prev_ent_count_flex
from rhnChannelFamily cf,
rhnPrivateChannelFamily pcf
where pcf.org_id = from_org_id_in
@@ -1214,7 +1214,7 @@ is
and cf.label = channel_family_label_in;
exception
when NO_DATA_FOUND then
- to_org_prev_ent_count := 0;
+ to_org_prev_ent_count_flex := 0;
end;
begin
@@ -1228,14 +1228,14 @@ is
'invalid_channel_family');
end;
- new_ent_count := prev_ent_count - quantity_in;
- new_ent_count_flex := prev_ent_count_flex - flex_in;
+ new_ent_count := from_org_prev_ent_count - quantity_in;
+ new_ent_count_flex := from_org_prev_ent_count_flex - flex_in;
- if prev_ent_count > new_ent_count then
+ if from_org_prev_ent_count >= new_ent_count then
new_quantity := to_org_prev_ent_count + quantity_in;
end if;
- if prev_ent_count_flex > new_ent_count_flex then
+ if from_org_prev_ent_count_flex >= new_ent_count_flex then
new_flex := to_org_prev_ent_count_flex + flex_in;
end if;