[jboss-svn-commits] JBL Code SVN: r19105 - in labs/jbosslabs/labs-3.0-build: core/core-model/src/main/java/org/jboss/labs/core/model and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Mar 19 06:34:20 EDT 2008
Author: wrzep
Date: 2008-03-19 06:34:19 -0400 (Wed, 19 Mar 2008)
New Revision: 19105
Added:
labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/SaveCompatibleLicenses.java
Removed:
labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/AddCompatibleLicense.java
Modified:
labs/jbosslabs/labs-3.0-build/core/core-model/src/main/java/org/jboss/labs/core/model/License.java
labs/jbosslabs/labs-3.0-build/ignore.txt
labs/jbosslabs/labs-3.0-build/services/project-service/src/main/java/org/jboss/labs/core/service/impl/LicenseServiceBean.java
labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/ShowLicense.java
labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/UpdateLicense.java
labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/META-INF/persistence.xml
labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/license/license.xhtml
Log:
JBLAB-915 licenses compatibility management
Modified: labs/jbosslabs/labs-3.0-build/core/core-model/src/main/java/org/jboss/labs/core/model/License.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/core/core-model/src/main/java/org/jboss/labs/core/model/License.java 2008-03-19 08:36:18 UTC (rev 19104)
+++ labs/jbosslabs/labs-3.0-build/core/core-model/src/main/java/org/jboss/labs/core/model/License.java 2008-03-19 10:34:19 UTC (rev 19105)
@@ -42,7 +42,7 @@
private String name;
private String licenseVersion;
private String url;
- @OneToMany
+ @ManyToMany
private List<License> compatibleLicensesList;
@OneToOne
Modified: labs/jbosslabs/labs-3.0-build/ignore.txt
===================================================================
--- labs/jbosslabs/labs-3.0-build/ignore.txt 2008-03-19 08:36:18 UTC (rev 19104)
+++ labs/jbosslabs/labs-3.0-build/ignore.txt 2008-03-19 10:34:19 UTC (rev 19105)
@@ -2,4 +2,5 @@
.classpath
.project
.settings
+.iml
Modified: labs/jbosslabs/labs-3.0-build/services/project-service/src/main/java/org/jboss/labs/core/service/impl/LicenseServiceBean.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/services/project-service/src/main/java/org/jboss/labs/core/service/impl/LicenseServiceBean.java 2008-03-19 08:36:18 UTC (rev 19104)
+++ labs/jbosslabs/labs-3.0-build/services/project-service/src/main/java/org/jboss/labs/core/service/impl/LicenseServiceBean.java 2008-03-19 10:34:19 UTC (rev 19105)
@@ -4,20 +4,20 @@
import org.jboss.labs.core.service.LicenseService;
import org.jboss.labs.exception.admin.LicenseNotFoundException;
-import javax.ejb.Stateless;
+import javax.ejb.Stateful;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
import java.util.List;
/**
* @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
*/
- at Stateless(name="LicenseService")
+ at Stateful(name="LicenseService")
public class LicenseServiceBean implements LicenseService {
- @PersistenceContext(unitName = "core_model")
- //, type = PersistenceContextType.EXTENDED) \
+ @PersistenceContext(unitName = "core_model", type = PersistenceContextType.EXTENDED)
private EntityManager em;
@SuppressWarnings("unchecked")
Deleted: labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/AddCompatibleLicense.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/AddCompatibleLicense.java 2008-03-19 08:36:18 UTC (rev 19104)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/AddCompatibleLicense.java 2008-03-19 10:34:19 UTC (rev 19105)
@@ -1,55 +0,0 @@
-/*
-* JBoss Labs. http://labs.jboss.com/jbosslabs
-*
-* Copyright © 2008 Red Hat Middleware, LLC. All rights reserved.
-*
-* This copyrighted material is made available to anyone wishing to use,
-* modify, copy, or redistribute it subject to the terms and conditions
-* of the GNU Lesser General Public License, v. 2.1.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT A WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License, v.2.1 along with this distribution; if not, write to the Free
-* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-* 02110-1301, USA.
-*
-* Red Hat Author(s): Bob McWhirter, Przemyslaw Dej, Ryszard Kozmik,
-* Tomasz Szymanski, Adam Warski, Pawel Wrzeszcz
-*/
-
-package org.jboss.labs.admin.action.license;
-
-import org.jboss.labs.core.model.License;
-import org.jboss.seam.annotations.Name;
-import org.jboss.seam.annotations.In;
-
-import java.io.Serializable;
-
-/**
- * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
- */
-
- at Name("addCompatibleLicense")
-public class AddCompatibleLicense implements Serializable {
-
- private Object compatibleLicense;
- @In private License license;
-
- private static final long serialVersionUID = -4903680348182905686L;
-
- public void addCompatibleLicense() {
- license.getCompatibleLicensesList().add(license);
- }
-
- public Object getCompatibleLicense() {
- return compatibleLicense;
- }
-
- public void setCompatibleLicense(Object compatibleLicense) {
- this.compatibleLicense = compatibleLicense;
- }
-}
\ No newline at end of file
Copied: labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/SaveCompatibleLicenses.java (from rev 19102, labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/AddCompatibleLicense.java)
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/SaveCompatibleLicenses.java (rev 0)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/SaveCompatibleLicenses.java 2008-03-19 10:34:19 UTC (rev 19105)
@@ -0,0 +1,73 @@
+/*
+* JBoss Labs. http://labs.jboss.com/jbosslabs
+*
+* Copyright © 2008 Red Hat Middleware, LLC. All rights reserved.
+*
+* This copyrighted material is made available to anyone wishing to use,
+* modify, copy, or redistribute it subject to the terms and conditions
+* of the GNU Lesser General Public License, v. 2.1.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT A WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License, v.2.1 along with this distribution; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+* 02110-1301, USA.
+*
+* Red Hat Author(s): Bob McWhirter, Przemyslaw Dej, Ryszard Kozmik,
+* Tomasz Szymanski, Adam Warski, Pawel Wrzeszcz
+*/
+
+package org.jboss.labs.admin.action.license;
+
+import org.jboss.labs.core.model.License;
+import org.jboss.seam.annotations.Name;
+import org.jboss.seam.annotations.In;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
+ */
+
+ at Name("saveCompatibleLicenses")
+public class SaveCompatibleLicenses implements Serializable {
+
+ @In private List<String> compatibleLicenses;
+ @In private License license;
+ @In private List<License> licenses;
+
+ private static final long serialVersionUID = -4903680348182905686L;
+
+ // The following code would be 10x nicer if we didn't have services separated from Seam
+
+ public void saveCompatibleLicenses() {
+
+ List<License> lList = new ArrayList<License>();
+
+ for (String compatibleLicense : compatibleLicenses) {
+ License l = find(compatibleLicense);
+ lList.add(l);
+ }
+
+ license.setCompatibleLicensesList(lList);
+ }
+
+ private License find(String licenseIdString) {
+
+ int lincenseId = Integer.parseInt(licenseIdString);
+ for (License l : licenses) {
+ if (l.getId().equals(lincenseId)) {
+ return l;
+ }
+ }
+
+ throw new IllegalStateException("Cannot find license. id="+licenseIdString);
+ }
+
+}
\ No newline at end of file
Modified: labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/ShowLicense.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/ShowLicense.java 2008-03-19 08:36:18 UTC (rev 19104)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/ShowLicense.java 2008-03-19 10:34:19 UTC (rev 19105)
@@ -25,6 +25,7 @@
import org.jboss.labs.admin.Pages;
import org.jboss.labs.core.model.License;
+import org.jboss.labs.core.service.LicenseService;
import org.jboss.labs.exception.admin.ProjectNotFoundException;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Begin;
@@ -33,6 +34,10 @@
import org.jboss.seam.annotations.Out;
import org.jboss.seam.core.Conversation;
+import javax.faces.model.SelectItem;
+import java.util.List;
+import java.util.ArrayList;
+
/**
* @author Pawel Wrzeszcz (pwrzeszcz [at] jboss . org)
*/
@@ -40,8 +45,14 @@
@Name("showLicense")
public class ShowLicense {
+ @In private List<License> licenses;
+
@Out(scope = ScopeType.CONVERSATION) private License license;
+ @Out(scope = ScopeType.CONVERSATION) private List<String> compatibleLicenses;
+
+ @Out(scope = ScopeType.CONVERSATION) private List<SelectItem> licenseItems;
+
@In private Conversation conversation;
@Begin(nested=true)
@@ -51,6 +62,20 @@
conversation.setDescription(license.getName());
+ licenseItems = new ArrayList<SelectItem>();
+
+ for (License l : licenses) {
+ if (!l.equals(license)) {
+ licenseItems.add(new SelectItem(l.getId(), l.getName() + " ver. " + l.getLicenseVersion()));
+ }
+ }
+
+ compatibleLicenses = new ArrayList<String>();
+
+ for (License l : license.getCompatibleLicensesList()) {
+ compatibleLicenses.add(l.getId().toString());
+ }
+
return Pages.LICENSE_PAGE;
}
}
\ No newline at end of file
Modified: labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/UpdateLicense.java
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/UpdateLicense.java 2008-03-19 08:36:18 UTC (rev 19104)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/java/org/jboss/labs/admin/action/license/UpdateLicense.java 2008-03-19 10:34:19 UTC (rev 19105)
@@ -52,6 +52,8 @@
@In private FacesMessages facesMessages;
+ @In(create = true) private SaveCompatibleLicenses saveCompatibleLicenses;
+
private static final long serialVersionUID = -8691237645254515225L;
public String save(License license) throws NamingException {
@@ -70,6 +72,8 @@
}
}
+ saveCompatibleLicenses.saveCompatibleLicenses();
+
this.license = licenseService.updateLicense(license);
conversation.end();
Modified: labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/META-INF/persistence.xml
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/META-INF/persistence.xml 2008-03-19 08:36:18 UTC (rev 19104)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/META-INF/persistence.xml 2008-03-19 10:34:19 UTC (rev 19105)
@@ -14,7 +14,6 @@
<class>org.jboss.labs.core.model.admin.ProjectRequest</class>
<class>org.jboss.labs.core.model.admin.JoinRequest</class>
-
</persistence-unit>
</persistence>
Modified: labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/license/license.xhtml
===================================================================
--- labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/license/license.xhtml 2008-03-19 08:36:18 UTC (rev 19104)
+++ labs/jbosslabs/labs-3.0-build/views/admin/src/main/webapp/license/license.xhtml 2008-03-19 10:34:19 UTC (rev 19105)
@@ -51,15 +51,14 @@
<h:commandLink value="delete" action="#{l.compatibleLicensesList.remove(l)}"/>
</h:column>
</h:dataTable>
- <h:selectOneMenu value="#{addCompatibleLicense.compatibleLicense}">
- <s:selectItems value="#{licenses}" var="x"
- label="#{x.name} #{x.licenseVersion}"
-
- noSelectionLabel="Please Select..."/>
-
- </h:selectOneMenu>
- <h:commandButton action="#{addCompatibleLicense.addCompatibleLicense()}" value="Add" disabled="true"/>
<br/>
+ <h:selectManyCheckbox value="#{compatibleLicenses}" layout="pageDirection">
+ <f:selectItems value="#{licenseItems}" />
+ </h:selectManyCheckbox>
+ <ui:remove>
+ <h:commandButton action="#{saveCompatibleLicenses.saveCompatibleLicenses()}" value="OK"/>
+ </ui:remove>
+ <br/>
<h:commandButton value="Save" action="#{updateLicense.save(license)}"/>
<ui:remove>
<h:commandButton value="Apply" action="#{updateLicense.apply(license)}" />
More information about the jboss-svn-commits
mailing list