You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by im...@apache.org on 2007/09/04 11:29:13 UTC
svn commit: r572590 - in /myfaces/orchestra/trunk: core15/
core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/
examples/ examples/src/main/java/org/apache/myfaces/examples/mops/backings/
examples/src/main/java/org/apache/myfac...
Author: imario
Date: Tue Sep 4 02:29:10 2007
New Revision: 572590
URL: http://svn.apache.org/viewvc?rev=572590&view=rev
Log:
fixed bugs regarding required fields in EjbExtractor
moved to latest derby
petstore progress
Added:
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/CustomerLogin.java (with props)
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/ProductDetail.java (with props)
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/dao/ShopCustomerDao.java (with props)
myfaces/orchestra/trunk/examples/src/main/webapp/mops/CustomerLogin.jsp (with props)
Modified:
myfaces/orchestra/trunk/core15/pom.xml
myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java
myfaces/orchestra/trunk/examples/pom.xml
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/PetstoreData.java
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/CustomerGroup.java
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/Product.java
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ProductPrice.java
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShopCustomer.java
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCart.java
myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCartItem.java
myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml
myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml
myfaces/orchestra/trunk/examples/src/main/webapp/mops/EditProduct.jsp
myfaces/orchestra/trunk/examples/src/main/webapp/mops/ProductDetail.jsp
myfaces/orchestra/trunk/examples/src/main/webapp/mops/SearchProduct.jsp
myfaces/orchestra/trunk/sandbox/pom.xml
Modified: myfaces/orchestra/trunk/core15/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/pom.xml?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/pom.xml (original)
+++ myfaces/orchestra/trunk/core15/pom.xml Tue Sep 4 02:29:10 2007
@@ -122,7 +122,7 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
- <version>10.2.2.0</version>
+ <version>10.3.1.4</version>
<scope>test</scope>
</dependency>
Modified: myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java (original)
+++ myfaces/orchestra/trunk/core15/src/main/java/org/apache/myfaces/orchestra/dynaForm/metadata/impl/ejb/EjbExtractor.java Tue Sep 4 02:29:10 2007
@@ -34,6 +34,7 @@
import org.apache.myfaces.orchestra.dynaForm.metadata.RelationType;
import org.apache.myfaces.orchestra.dynaForm.metadata.Selection;
+import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Embedded;
@@ -453,6 +454,16 @@
Column column = accessibleObject.getAnnotation(Column.class);
mdField.setRequired(!column.nullable());
}
+ if (accessibleObject.isAnnotationPresent(Basic.class))
+ {
+ // is required
+ Basic basic = accessibleObject.getAnnotation(Basic.class);
+ // do not clear flag if its already required from the @column annotation
+ if (!basic.optional())
+ {
+ mdField.setRequired(!basic.optional());
+ }
+ }
if (accessibleObject.isAnnotationPresent(Id.class))
{
@@ -471,6 +482,11 @@
if (accessibleObject.isAnnotationPresent(OneToOne.class))
{
mdField.setRelationType(RelationType.ONE_TO_ONE);
+ OneToOne relation = accessibleObject.getAnnotation(OneToOne.class);
+ if (!relation.optional())
+ {
+ mdField.setRequired(relation.optional());
+ }
}
if (accessibleObject.isAnnotationPresent(OneToMany.class))
{
@@ -479,6 +495,12 @@
if (accessibleObject.isAnnotationPresent(ManyToOne.class))
{
mdField.setRelationType(RelationType.MANY_TO_ONE);
+
+ ManyToOne relation = accessibleObject.getAnnotation(ManyToOne.class);
+ if (!relation.optional())
+ {
+ mdField.setRequired(relation.optional());
+ }
}
if (accessibleObject.isAnnotationPresent(ManyToMany.class))
{
Modified: myfaces/orchestra/trunk/examples/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/pom.xml?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/pom.xml (original)
+++ myfaces/orchestra/trunk/examples/pom.xml Tue Sep 4 02:29:10 2007
@@ -109,7 +109,7 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
- <version>10.2.2.0</version>
+ <version>10.3.1.4</version>
</dependency>
<dependency>
Added: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/CustomerLogin.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/CustomerLogin.java?rev=572590&view=auto
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/CustomerLogin.java (added)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/CustomerLogin.java Tue Sep 4 02:29:10 2007
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.examples.mops.backings;
+
+import org.apache.myfaces.examples.lib.FacesConst;
+import org.apache.myfaces.examples.lib.SpringUtils;
+import org.apache.myfaces.examples.mops.dao.ShopCustomerDao;
+import org.apache.myfaces.examples.mops.model.ShopCustomer;
+import org.apache.myfaces.orchestra.conversation.Conversation;
+import org.apache.myfaces.orchestra.viewController.annotations.InitView;
+import org.apache.myfaces.orchestra.viewController.annotations.ViewController;
+import org.springframework.transaction.PlatformTransactionManager;
+
+@ViewController(viewIds="/mops/CustomerLogin.jsp")
+public class CustomerLogin
+{
+ private PlatformTransactionManager transactionManager;
+
+ private ShopCustomerDao shopCustomerDao;
+
+ private ShopCustomer shopCustomer;
+
+ private PetstoreData petstoreData;
+
+ @InitView
+ public void initView()
+ {
+ if (petstoreData.getCustomerId() != null)
+ {
+ shopCustomer = shopCustomerDao.getByKey(petstoreData.getCustomerId());
+ }
+
+ if (shopCustomer == null)
+ {
+ shopCustomer = new ShopCustomer();
+ }
+ }
+
+ public PlatformTransactionManager getTransactionManager()
+ {
+ return transactionManager;
+ }
+
+ public void setTransactionManager(PlatformTransactionManager transactionManager)
+ {
+ this.transactionManager = transactionManager;
+ }
+
+ public PetstoreData getPetstoreData()
+ {
+ return petstoreData;
+ }
+
+ public void setPetstoreData(PetstoreData petstoreData)
+ {
+ this.petstoreData = petstoreData;
+ }
+
+ public ShopCustomerDao getShopCustomerDao()
+ {
+ return shopCustomerDao;
+ }
+
+ public void setShopCustomerDao(ShopCustomerDao shopCustomerDao)
+ {
+ this.shopCustomerDao = shopCustomerDao;
+ }
+
+ public ShopCustomer getShopCustomer()
+ {
+ return shopCustomer;
+ }
+
+ public void setShopCustomer(ShopCustomer shopCustomer)
+ {
+ this.shopCustomer = shopCustomer;
+ }
+
+ public boolean isLoggedIn()
+ {
+ return petstoreData.getCustomerId() != null;
+ }
+
+ public String saveAction()
+ {
+ SpringUtils.commit(transactionManager);
+
+ // tell the other conversation to reload its data
+ petstoreData.refreshCustomer();
+
+ Conversation.getCurrentInstance().invalidate();
+ return FacesConst.SUCCESS;
+ }
+
+ public String loginAction()
+ {
+ shopCustomerDao.save(shopCustomer);
+
+ SpringUtils.commit(transactionManager);
+
+ petstoreData.loginCustomer(shopCustomer.getId());
+
+ Conversation.getCurrentInstance().invalidate();
+ return FacesConst.SUCCESS;
+ }
+}
\ No newline at end of file
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/CustomerLogin.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/CustomerLogin.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/CustomerLogin.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/PetstoreData.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/PetstoreData.java?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/PetstoreData.java (original)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/PetstoreData.java Tue Sep 4 02:29:10 2007
@@ -1,6 +1,7 @@
package org.apache.myfaces.examples.mops.backings;
import org.apache.myfaces.examples.mops.dao.ProductDao;
+import org.apache.myfaces.examples.mops.dao.ShopCustomerDao;
import org.apache.myfaces.examples.mops.model.ShopCustomer;
import org.apache.myfaces.examples.mops.model.ShoppingCart;
import org.springframework.transaction.annotation.Transactional;
@@ -8,6 +9,7 @@
public class PetstoreData
{
private ProductDao productDao;
+ private ShopCustomerDao shopCustomerDao;
private ShopCustomer customer;
private ShoppingCart shoppingCart;
@@ -22,6 +24,21 @@
this.productDao = productDao;
}
+ public ShopCustomerDao getShopCustomerDao()
+ {
+ return shopCustomerDao;
+ }
+
+ public void setShopCustomerDao(ShopCustomerDao shopCustomerDao)
+ {
+ this.shopCustomerDao = shopCustomerDao;
+ }
+
+ public ShopCustomer getCustomer()
+ {
+ return customer;
+ }
+
public Long getCustomerGroupId()
{
if (customer != null)
@@ -40,5 +57,30 @@
shoppingCart = new ShoppingCart();
}
shoppingCart.addProduct(productDao.getByKey(productId), quantity);
+ }
+
+ public void loginCustomer(long customerId)
+ {
+ customer = shopCustomerDao.getByKey(customerId);
+ }
+
+ public boolean isLoggedIn()
+ {
+ return customer != null;
+ }
+
+ public Long getCustomerId()
+ {
+ if (customer == null)
+ {
+ return null;
+ }
+
+ return customer.getId();
+ }
+
+ public void refreshCustomer()
+ {
+ shopCustomerDao.refresh(customer);
}
}
Added: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/ProductDetail.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/ProductDetail.java?rev=572590&view=auto
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/ProductDetail.java (added)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/ProductDetail.java Tue Sep 4 02:29:10 2007
@@ -0,0 +1,126 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.examples.mops.backings;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.examples.lib.FacesConst;
+import org.apache.myfaces.examples.lib.FacesUtils;
+import org.apache.myfaces.examples.mops.dao.ProductDao;
+import org.apache.myfaces.examples.mops.dao.ProductPriceDao;
+import org.apache.myfaces.examples.mops.model.Product;
+import org.apache.myfaces.examples.mops.model.ProductPrice;
+import org.apache.myfaces.orchestra.viewController.annotations.InitView;
+import org.apache.myfaces.orchestra.viewController.annotations.ViewController;
+
+import javax.faces.context.FacesContext;
+
+@ViewController(viewIds="/mops/ProductDetail.jsp")
+public class ProductDetail
+{
+ private ProductDao productDao;
+ private ProductPriceDao productPriceDao;
+
+ private Product product;
+ private ProductPrice price;
+
+ private PetstoreData petstoreData;
+
+ private long quantity;
+
+ @InitView
+ public void myInitView()
+ {
+ String productId = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("productId");
+ if (!StringUtils.isEmpty(productId))
+ {
+ initProduct(Long.valueOf(productId, 10));
+ }
+ }
+
+ public ProductDao getProductDao()
+ {
+ return productDao;
+ }
+
+ public void setProductDao(ProductDao productDao)
+ {
+ this.productDao = productDao;
+ }
+
+ public ProductPriceDao getProductPriceDao()
+ {
+ return productPriceDao;
+ }
+
+ public void setProductPriceDao(ProductPriceDao productPriceDao)
+ {
+ this.productPriceDao = productPriceDao;
+ }
+
+ public PetstoreData getPetstoreData()
+ {
+ return petstoreData;
+ }
+
+ public void setPetstoreData(PetstoreData petstoreData)
+ {
+ this.petstoreData = petstoreData;
+ }
+
+ public void initProduct(Long productId)
+ {
+ product = productDao.getByKey(productId);
+ if (product == null)
+ {
+ FacesUtils.addInfoMessage("can't find a product with id '" + productId + "'");
+ return;
+ }
+
+ price = productPriceDao.getPriceForProduct(
+ product,
+ petstoreData.getCustomerGroupId());
+ }
+
+ public Product getProduct()
+ {
+ return product;
+ }
+
+ public ProductPrice getPrice()
+ {
+ return price;
+ }
+
+ public long getQuantity()
+ {
+ return quantity;
+ }
+
+ public void setQuantity(long quantity)
+ {
+ this.quantity = quantity;
+ }
+
+ public String buyAction()
+ {
+ petstoreData.addProduct(getProduct().getId(), quantity);
+
+ return FacesConst.SUCCESS;
+ }
+}
\ No newline at end of file
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/ProductDetail.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/ProductDetail.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/backings/ProductDetail.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/dao/ShopCustomerDao.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/dao/ShopCustomerDao.java?rev=572590&view=auto
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/dao/ShopCustomerDao.java (added)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/dao/ShopCustomerDao.java Tue Sep 4 02:29:10 2007
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.examples.mops.dao;
+
+import org.apache.myfaces.examples.mops.model.ShopCustomer;
+
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+
+public class ShopCustomerDao
+{
+ @PersistenceContext
+ private EntityManager entityManager;
+
+ public ShopCustomer getByKey(long customerId)
+ {
+ return entityManager.find(ShopCustomer.class, Long.valueOf(customerId));
+ }
+
+ public void save(ShopCustomer shopCustomer)
+ {
+ entityManager.persist(shopCustomer);
+ }
+
+ public void refresh(ShopCustomer customer)
+ {
+ entityManager.refresh(customer);
+ }
+}
\ No newline at end of file
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/dao/ShopCustomerDao.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/dao/ShopCustomerDao.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/dao/ShopCustomerDao.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/CustomerGroup.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/CustomerGroup.java?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/CustomerGroup.java (original)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/CustomerGroup.java Tue Sep 4 02:29:10 2007
@@ -25,6 +25,7 @@
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Version;
+import javax.persistence.Basic;
@Entity
@NamedQueries(value=
@@ -53,6 +54,7 @@
this.id = id;
}
+ @Basic(optional=false)
public String getDescription()
{
return description;
Modified: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/Product.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/Product.java?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/Product.java (original)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/Product.java Tue Sep 4 02:29:10 2007
@@ -30,6 +30,7 @@
import javax.persistence.Version;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
+import javax.persistence.Basic;
import java.util.HashSet;
import java.util.Set;
@@ -48,6 +49,8 @@
private String description;
+ private String longDescription;
+
private Set<ProductPrice> productPrices;
private Long version;
@@ -65,6 +68,7 @@
this.id = id;
}
+ @Basic(optional=false)
public String getProductNumber()
{
return productNumber;
@@ -75,6 +79,7 @@
this.productNumber = productNumber;
}
+ @Basic(optional=false)
public String getDescription()
{
return description;
@@ -83,6 +88,16 @@
public void setDescription(String description)
{
this.description = description;
+ }
+
+ public String getLongDescription()
+ {
+ return longDescription;
+ }
+
+ public void setLongDescription(String longDescription)
+ {
+ this.longDescription = longDescription;
}
@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
Modified: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ProductPrice.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ProductPrice.java?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ProductPrice.java (original)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ProductPrice.java Tue Sep 4 02:29:10 2007
@@ -33,6 +33,7 @@
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
+import javax.persistence.Basic;
import java.util.Date;
@Entity
@@ -40,10 +41,10 @@
{
@NamedQuery(
name="productPriceCustomerGroupCurrent",
- query="select p from ProductPrice p where p.product = :product and p.validFrom < :date and (p.validTo is null or p.validTo > :date) and p.customerGroup.id = :customerGroupId"),
+ query="select p from ProductPrice p where p.product = :product and p.validFrom <= :date and (p.validTo is null or p.validTo > :date) and p.customerGroup.id = :customerGroupId"),
@NamedQuery(
name="productPriceCurrent",
- query="select p from ProductPrice p where p.product = :product and p.validFrom < :date and (p.validTo is null or p.validTo > :date) and p.customerGroup.id is null")
+ query="select p from ProductPrice p where p.product = :product and p.validFrom <= :date and (p.validTo is null or p.validTo > :date) and p.customerGroup is null")
}
)
public class ProductPrice
@@ -74,7 +75,7 @@
this.id = id;
}
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false)
@DisplayOnly
public Product getProduct()
{
@@ -87,6 +88,7 @@
}
@Temporal(value= TemporalType.DATE)
+ @Basic(optional=false)
public Date getValidFrom()
{
return validFrom;
@@ -108,6 +110,7 @@
this.validTo = validTo;
}
+ @Basic(optional=false)
public double getPrice()
{
return price;
Modified: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShopCustomer.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShopCustomer.java?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShopCustomer.java (original)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShopCustomer.java Tue Sep 4 02:29:10 2007
@@ -18,6 +18,9 @@
*/
package org.apache.myfaces.examples.mops.model;
+import org.apache.myfaces.orchestra.dynaForm.annot.ui.DataProvider;
+
+import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
@@ -54,6 +57,7 @@
this.id = id;
}
+ @Basic(optional=false)
public String getFirstName()
{
return firstName;
@@ -64,6 +68,7 @@
this.firstName = firstName;
}
+ @Basic(optional=false)
public String getLastName()
{
return lastName;
@@ -74,6 +79,7 @@
this.lastName = lastName;
}
+ @Basic(optional=false)
public String getEmail()
{
return email;
@@ -84,7 +90,11 @@
this.email = email;
}
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false)
+ @DataProvider(
+ description = "#{customerGroupSuggest.getDescription}",
+ value = "#{customerGroupSuggest.getCustomerGroupsByFulltext}",
+ converterId="customerGroupPkConverter")
public CustomerGroup getCustomerGroup()
{
return customerGroup;
Modified: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCart.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCart.java?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCart.java (original)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCart.java Tue Sep 4 02:29:10 2007
@@ -36,7 +36,7 @@
private Long id;
private ShopCustomer shopCustomer;
-
+
private Set<ShoppingCartItem> shoppingCartItem;
private Long version;
@@ -53,7 +53,7 @@
this.id = id;
}
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false)
public ShopCustomer getCustomer()
{
return shopCustomer;
Modified: myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCartItem.java
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCartItem.java?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCartItem.java (original)
+++ myfaces/orchestra/trunk/examples/src/main/java/org/apache/myfaces/examples/mops/model/ShoppingCartItem.java Tue Sep 4 02:29:10 2007
@@ -26,6 +26,7 @@
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Version;
+import javax.persistence.Basic;
@Entity
public class ShoppingCartItem
@@ -52,7 +53,7 @@
this.id = id;
}
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false)
public ShoppingCart getShoppingCart()
{
return shoppingCart;
@@ -63,7 +64,7 @@
this.shoppingCart = shoppingCart;
}
- @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
+ @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL, optional = false)
public Product getProduct()
{
return product;
@@ -74,6 +75,7 @@
this.product = product;
}
+ @Basic(optional=false)
public long getQuantity()
{
return quantity;
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/applicationContext.xml Tue Sep 4 02:29:10 2007
@@ -341,6 +341,10 @@
class="org.apache.myfaces.examples.mops.dao.CustomerGroupDao" />
<bean
+ name="shopCustomerDao"
+ class="org.apache.myfaces.examples.mops.dao.ShopCustomerDao" />
+
+ <bean
name="customerGroupSuggest"
class="org.apache.myfaces.examples.mops.dao.CustomerGroupSuggest"
scope="viewController"
@@ -361,7 +365,8 @@
name="petstoreData"
class="org.apache.myfaces.examples.mops.backings.PetstoreData"
scope="conversation"
- orchestra:conversationName="petstoreConversation">
+ orchestra:conversationName="petstoreConversation"
+ autowire="byName">
<aop:scoped-proxy/>
</bean>
@@ -385,6 +390,15 @@
</bean>
<bean
+ name="mopsProductDetail"
+ class="org.apache.myfaces.examples.mops.backings.ProductDetail"
+ scope="flash"
+ autowire="byName">
+
+ <aop:scoped-proxy/>
+ </bean>
+
+ <bean
name="mopsEditCustomerGroup"
class="org.apache.myfaces.examples.mops.backings.EditCustomerGroup"
scope="flash"
@@ -403,9 +417,12 @@
</bean>
<bean
- name="mopsCustomerGroupDatasource"
- class="org.apache.myfaces.examples.mops.backings.CustomerGroupDatasource"
- scope="request">
+ name="mopsCustomerLogin"
+ class="org.apache.myfaces.examples.mops.backings.CustomerLogin"
+ scope="flash"
+ autowire="byName">
+ <aop:scoped-proxy/>
</bean>
+
</beans>
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/WEB-INF/faces-config.xml Tue Sep 4 02:29:10 2007
@@ -159,6 +159,25 @@
<to-view-id>/mops/EditProduct.jsp?productId=#{param.productId}</to-view-id>
<redirect/>
</navigation-case>
+ <navigation-case>
+ <from-outcome>CustomerLogin</from-outcome>
+ <to-view-id>/mops/CustomerLogin.jsp</to-view-id>
+ <redirect/>
+ </navigation-case>
+ </navigation-rule>
+
+ <navigation-rule>
+ <from-view-id>/mops/CustomerLogin.jsp</from-view-id>
+ <navigation-case>
+ <from-action>#{mopsCustomerLogin.loginAction}</from-action>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/mops/SearchProduct.jsp</to-view-id>
+ </navigation-case>
+ <navigation-case>
+ <from-action>#{mopsCustomerLogin.saveAction}</from-action>
+ <from-outcome>success</from-outcome>
+ <to-view-id>/mops/SearchProduct.jsp</to-view-id>
+ </navigation-case>
</navigation-rule>
</faces-config>
Added: myfaces/orchestra/trunk/examples/src/main/webapp/mops/CustomerLogin.jsp
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/mops/CustomerLogin.jsp?rev=572590&view=auto
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/mops/CustomerLogin.jsp (added)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/mops/CustomerLogin.jsp Tue Sep 4 02:29:10 2007
@@ -0,0 +1,81 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+ --%>
+
+<%@ page pageEncoding="UTF-8" %>
+<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
+<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
+<%@ taglib uri="http://myfaces.apache.org/tomahawk" prefix="t" %>
+<%@ taglib uri="http://myfaces.apache.org/sandbox" prefix="s" %>
+<%@ taglib uri="http://myfaces.apache.org/orchestra15" prefix="ox" %>
+
+<f:view>
+ <%@ include file="../header.jspf" %>
+
+ <h:form>
+
+ <t:htmlTag value="h3">
+ <h:outputText value="Customer Login"/>
+ </t:htmlTag>
+
+ <h:outputText value="This is not a real login thing, just create a new customer and press login" />
+
+ <ox:dynaForm
+ id="customer"
+ var="customer"
+ uri="org.apache.myfaces.examples.mops.model.ShopCustomer"
+ valueBindingPrefix="mopsCustomerLogin.shopCustomer">
+
+ <h:panelGrid
+ columns="1"
+ rowClasses="formData,formAction"
+ styleClass="formInput"
+ width="40%">
+
+ <f:facet name="header">
+ <h:outputText value="Enter your informations" />
+ </f:facet>
+
+ <h:panelGrid
+ id="customer-layout"
+ columns="2"
+ rowClasses="TR1,TR2"
+ width="100%">
+ </h:panelGrid>
+
+ <h:panelGrid
+ columns="1"
+ rowClasses="formAction">
+ <h:commandButton
+ value="login"
+ action="#{mopsCustomerLogin.loginAction}"
+ rendered="#{!mopsCustomerLogin.loggedIn}"/>
+ <h:commandButton
+ value="save"
+ action="#{mopsCustomerLogin.saveAction}"
+ rendered="#{mopsCustomerLogin.loggedIn}"/>
+ </h:panelGrid>
+
+ </h:panelGrid>
+
+ </ox:dynaForm>
+
+ </h:form>
+
+ <%@ include file="../footer.jspf" %>
+</f:view>
\ No newline at end of file
Propchange: myfaces/orchestra/trunk/examples/src/main/webapp/mops/CustomerLogin.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: myfaces/orchestra/trunk/examples/src/main/webapp/mops/CustomerLogin.jsp
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Propchange: myfaces/orchestra/trunk/examples/src/main/webapp/mops/CustomerLogin.jsp
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/mops/EditProduct.jsp
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/mops/EditProduct.jsp?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/mops/EditProduct.jsp (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/mops/EditProduct.jsp Tue Sep 4 02:29:10 2007
@@ -39,6 +39,11 @@
var="product"
uri="org.apache.myfaces.examples.mops.model.Product"
valueBindingPrefix="mopsEditProduct.product">
+ <ox:dynaFormConfigs>
+ <ox:dynaFormConfig for="longDescription">
+ <t:inputHtml/>
+ </ox:dynaFormConfig>
+ </ox:dynaFormConfigs>
<h:panelGrid
columns="1"
rowClasses="formData,formAction"
@@ -83,7 +88,8 @@
id="prices"
var="prices"
uri="org.apache.myfaces.examples.mops.backings.EditProduct$ProductPriceWrapper"
- rendered="#{mopsEditProduct.savedProduct}">
+ rendered="#{mopsEditProduct.savedProduct}"
+ exclusiveFields="true">
<ox:dynaFormConfigs>
<ox:dynaFormConfig for="productPrice.id" displayOnly="true"/>
<ox:dynaFormConfig for="productPrice.customerGroup"/>
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/mops/ProductDetail.jsp
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/mops/ProductDetail.jsp?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/mops/ProductDetail.jsp (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/mops/ProductDetail.jsp Tue Sep 4 02:29:10 2007
@@ -30,124 +30,32 @@
<h:form>
<t:htmlTag value="h3">
- <h:outputText value="Edit Product"/>
+ <h:outputText value="Product Details"/>
</t:htmlTag>
- <ox:dynaForm
- id="product"
- var="product"
- uri="org.apache.myfaces.examples.mops.model.Product"
- valueBindingPrefix="mopsEditProduct.product">
- <h:panelGrid
- columns="1"
- rowClasses="formData,formAction"
- styleClass="formInput"
- width="40%">
-
- <f:facet name="header">
- <h:panelGroup>
- <h:outputText
- value="New product"
- rendered="#{!mopsEditProduct.savedProduct}"/>
-
- <h:outputText
- value="Edit product"
- rendered="#{mopsEditProduct.savedProduct}"/>
- </h:panelGroup>
- </f:facet>
-
- <h:panelGrid
- id="product-layout"
- columns="2"
- rowClasses="TR1,TR2"
- width="100%">
- </h:panelGrid>
-
- <h:panelGrid
- columns="2"
- rowClasses="formAction">
- <h:commandButton
- value="New product"
- action="#{mopsEditProduct.newProductAction}" />
- <h:commandButton
- value="Save product"
- action="#{mopsEditProduct.saveProductAction}" />
- </h:panelGrid>
- </h:panelGrid>
- </ox:dynaForm>
+ <h:panelGrid columns="2">
+ <h:outputText value="picture" />
+
+ <h:panelGrid columns="1">
+
+ <h:outputText value="#{mopsProductDetail.product.description}"/>
+
+ <h:outputText value="#{mopsProductDetail.product.longDescription}"/>
+
+ <h:panelGroup>
+ <h:outputText value="Price: "/>
+ <h:outputText value="#{mopsProductDetail.price.price}">
+ <f:convertNumber
+ groupingUsed="true"
+ maxFractionDigits="2"
+ minFractionDigits="2"
+ type="currency" />
+ </h:outputText>
+ </h:panelGroup>
- <ox:dynaForm
- id="prices"
- var="prices"
- uri="org.apache.myfaces.examples.mops.backings.EditProduct$ProductPriceWrapper"
- rendered="#{mopsEditProduct.savedProduct}">
- <t:dataTable
- id="prices-layout"
- var="price"
- value="#{mopsEditProduct.productPrices}">
-
- <f:facet name="header">
- <h:outputText
- value="Product prices" />
- </f:facet>
-
- <t:column id="data" />
-
- <t:column>
- <f:facet name="header">
- <h:outputText value="actions" />
- </f:facet>
- <h:panelGrid columns="2">
- <h:commandButton
- value="edit" />
- <h:commandButton
- value="delete">
- <t:updateActionListener
- property="#{mopsEditProduct.productPrice}"
- value="#{price.productPrice}" />
- </h:commandButton>
- </h:panelGrid>
- </t:column>
-
- </t:dataTable>
- </ox:dynaForm>
-
- <ox:dynaForm
- id="newPrice"
- var="newPrice"
- uri="org.apache.myfaces.examples.mops.model.Product"
- valueBindingPrefix="#{mopsEditProduct.productPrice}"
- rendered="#{mopsEditProduct.savedProduct}">
- <h:panelGrid
- columns="1"
- rowClasses="formData,formAction"
- styleClass="formInput"
- width="40%">
-
- <f:facet name="header">
- <h:outputText
- value="New price" />
- </f:facet>
-
- <h:panelGrid
- id="newPrice-layout"
- columns="2"
- rowClasses="TR1,TR2"
- width="100%">
- </h:panelGrid>
-
- <h:panelGrid
- columns="2"
- rowClasses="formAction">
- <h:commandButton
- value="New product"
- action="#{mopsEditProduct.newPriceAction}" />
- <h:commandButton
- value="Save product"
- action="#{mopsEditProduct.savePriceAction}" />
- </h:panelGrid>
</h:panelGrid>
- </ox:dynaForm>
+
+ </h:panelGrid>
</h:form>
Modified: myfaces/orchestra/trunk/examples/src/main/webapp/mops/SearchProduct.jsp
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/examples/src/main/webapp/mops/SearchProduct.jsp?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/examples/src/main/webapp/mops/SearchProduct.jsp (original)
+++ myfaces/orchestra/trunk/examples/src/main/webapp/mops/SearchProduct.jsp Tue Sep 4 02:29:10 2007
@@ -41,6 +41,10 @@
</f:facet>
<h:commandLink
+ value="Login"
+ action="CustomerLogin"/>
+
+ <h:commandLink
value="Enable administrator mode"
action="#{mopsSecurity.switchAdministratorModeAction}"
rendered="#{!mopsSecurity.administratorMode}"/>
@@ -61,6 +65,15 @@
</h:panelGrid>
+ <h:outputText
+ value="you are not logged in"
+ rendered="#{!petstoreData.loggedIn}"
+ />
+ <h:outputText
+ value="Hello #{petstoreData.customer.firstName} #{petstoreData.customer.lastName} (Group: #{petstoreData.customer.customerGroup.id}/#{petstoreData.customer.customerGroup.description})"
+ rendered="#{petstoreData.loggedIn}"
+ />
+
<h:panelGrid columns="3">
<f:facet name="header">
<h:outputText value="Search product" />
@@ -93,23 +106,23 @@
<h:outputText value="picture" />
- <h:outputText value="#{product.product.description}" />
+ <h:panelGrid columns="1">
+ <h:outputText value="#{product.product.description}" />
- <h:outputText value="picture" />
+ <h:panelGroup>
+ <h:outputText value="Price: "/>
+ <h:outputText value="#{product.price.price}">
+ <f:convertNumber
+ groupingUsed="true"
+ maxFractionDigits="2"
+ minFractionDigits="2"
+ type="currency" />
+ </h:outputText>
+ </h:panelGroup>
+ </h:panelGrid>
- <h:outputText value="#{product.product.description}" />
</h:panelGrid>
- <h:panelGroup>
- <h:outputText value="Price: "/>
- <h:outputText value="#{product.price.price}">
- <f:convertNumber
- groupingUsed="true"
- maxFractionDigits="2"
- minFractionDigits="2"
- type="currency" />
- </h:outputText>
- </h:panelGroup>
<h:panelGroup>
@@ -119,11 +132,12 @@
<f:param name="productId" value="#{product.product.id}" />
</h:commandLink>
- <h:outputText value=""/>
+ <h:outputText value=" "/>
<h:commandLink
value="edit"
- action="EditSelectedProduct">
+ action="EditSelectedProduct"
+ rendered="#{mopsSecurity.administratorMode}">
<f:param name="productId" value="#{product.product.id}" />
</h:commandLink>
Modified: myfaces/orchestra/trunk/sandbox/pom.xml
URL: http://svn.apache.org/viewvc/myfaces/orchestra/trunk/sandbox/pom.xml?rev=572590&r1=572589&r2=572590&view=diff
==============================================================================
--- myfaces/orchestra/trunk/sandbox/pom.xml (original)
+++ myfaces/orchestra/trunk/sandbox/pom.xml Tue Sep 4 02:29:10 2007
@@ -125,7 +125,7 @@
<dependency>
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
- <version>10.2.2.0</version>
+ <version>10.3.1.4</version>
<scope>test</scope>
</dependency>