Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * #%L
   * BroadleafCommerce Framework
   * %%
   * Copyright (C) 2009 - 2013 Broadleaf Commerce
   * %%
   * Licensed 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.
  * #L%
  */
 package org.broadleafcommerce.core.payment.domain;
 
 
 import java.util.List;
 
 
 @Table(name = "BLC_ORDER_PAYMENT")
     {
         @AdminPresentationMergeOverride(name = "", mergeEntries =
             @AdminPresentationMergeEntry(propertyType = ..,
                                             booleanOverrideValue = true)),
         @AdminPresentationMergeOverride(name = "billingAddress", mergeEntries = {
                 @AdminPresentationMergeEntry(propertyType = ..,
                         overrideValue = ....),
                 @AdminPresentationMergeEntry(propertyType = ..,
                         intOverrideValue = ....)
         }),
         @AdminPresentationMergeOverride(name = "billingAddress.isDefault", mergeEntries = {
                 @AdminPresentationMergeEntry(propertyType = ..,
                         booleanOverrideValue = true)
         }),
         @AdminPresentationMergeOverride(name = "billingAddress.isActive", mergeEntries = {
                 @AdminPresentationMergeEntry(propertyType = ..,
                         booleanOverrideValue = true)
         }),
         @AdminPresentationMergeOverride(name = "billingAddress.isBusiness", mergeEntries = {
                 @AdminPresentationMergeEntry(propertyType = ..,
                         booleanOverrideValue = true)
         })
     }
 )
@AdminPresentationClass(populateToOneFields = ., friendlyName = "OrderPaymentImpl_baseOrderPayment")
@SQLDelete(sql="UPDATE BLC_ORDER_PAYMENT SET ARCHIVED = 'Y' WHERE ORDER_PAYMENT_ID = ?")
})
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(generator = "OrderPaymentId")
        name="OrderPaymentId",
        strategy="org.broadleafcommerce.common.persistence.IdOverrideTableGenerator",
        parameters = {
            @Parameter(name="segment_value", value="OrderPaymentImpl"),
            @Parameter(name="entity_name", value="org.broadleafcommerce.core.payment.domain.OrderPaymentImpl")
        }
    )
    @Column(name = "ORDER_PAYMENT_ID")
    protected Long id;
    @ManyToOne(targetEntity = OrderImpl.class, optional = true)
    @JoinColumn(name = "ORDER_ID", nullable = true)
    @Index(name="ORDERPAYMENT_ORDER_INDEX", columnNames={"ORDER_ID"})
    @AdminPresentation(excluded = true)
    protected Order order;
    @ManyToOne(targetEntity = AddressImpl.class, cascade = { .. })
    @JoinColumn(name = "ADDRESS_ID")
    @Index(name="ORDERPAYMENT_ADDRESS_INDEX", columnNames={"ADDRESS_ID"})
    protected Address billingAddress;
    @Column(name = "AMOUNT", precision=19, scale=5)
    @AdminPresentation(friendlyName = "OrderPaymentImpl_Payment_Amount", order=2000, gridOrder = 2000, prominent=true,
            fieldType=.)
    protected BigDecimal amount;
    @Column(name = "REFERENCE_NUMBER")
    @Index(name="ORDERPAYMENT_REFERENCE_INDEX", columnNames={"REFERENCE_NUMBER"})
    @AdminPresentation(friendlyName = "OrderPaymentImpl_Payment_Reference_Number")
    protected String referenceNumber;
    @Column(name = "PAYMENT_TYPE", nullable = false)
    @Index(name="ORDERPAYMENT_TYPE_INDEX", columnNames={"PAYMENT_TYPE"})
    @AdminPresentation(friendlyName = "OrderPaymentImpl_Payment_Type", order=3000, gridOrder = 3000, prominent=true,
            fieldType= .,
            broadleafEnumeration="org.broadleafcommerce.common.payment.PaymentType")
    protected String type;
    
    @Column(name = "GATEWAY_TYPE")
    @AdminPresentation(friendlyName = "OrderPaymentImpl_Gateway_Type", order=1000, gridOrder = 1000, prominent=true,
            fieldType = .,
            broadleafEnumeration="org.broadleafcommerce.common.payment.PaymentGatewayType")
    protected String gatewayType;
    
    //TODO: add a filter for archived transactions
    @OneToMany(mappedBy = "orderPayment", targetEntity = PaymentTransactionImpl.class, cascade = { . }, orphanRemoval = true)
    @AdminPresentationCollection(friendlyName="OrderPaymentImpl_Details",
            tab = ..., tabOrder = ...)
    
    @Embedded
    protected ArchiveStatus archiveStatus = new ArchiveStatus();
    
    @Override
    public Money getAmount() {
        return  == null ? null : BroadleafCurrencyUtils.getMoney(getOrder().getCurrency());
    }
    @Override
    public void setAmount(Money amount) {
        this. = Money.toAmount(amount);
    }
    @Override
    public Long getId() {
        return ;
    }
    @Override
    public void setId(Long id) {
        this. = id;
    }
    @Override
    public Order getOrder() {
        return ;
    }
    @Override
    public void setOrder(Order order) {
        this. = order;
    }
    @Override
    public Address getBillingAddress() {
        return ;
    }
    @Override
    public void setBillingAddress(Address billingAddress) {
        this. = billingAddress;
    }
    @Override
    public String getReferenceNumber() {
        return ;
    }
    @Override
    public void setReferenceNumber(String referenceNumber) {
        this. = referenceNumber;
    }
    @Override
    public PaymentType getType() {
        return PaymentType.getInstance();
    }
    @Override
    public void setType(PaymentType type) {
        this. = type == null ? null : type.getType();
    }
    
    @Override
        return PaymentGatewayType.getInstance();
    }
    @Override
    public void setPaymentGatewayType(PaymentGatewayType gatewayType) {
        this. = gatewayType == null ? null : gatewayType.getType();
    }
    @Override
        return ;
    }
    @Override
    public void setTransactions(List<PaymentTransactiontransactions) {
        this. = transactions;
    }
    
    @Override
    public void addTransaction(PaymentTransaction transaction) {
        getTransactions().add(transaction);
    }
    
    @Override
        List<PaymentTransactionresult = new ArrayList<PaymentTransaction>();
        for (PaymentTransaction tx : getTransactions()) {
            if (tx.getType().equals(type)) {
                result.add(tx);
            }
        }
        return result;
    }
    @Override
        for (PaymentTransaction tx : getTransactions()) {
            if (tx.getParentTransaction() == null) {
                return tx;
            }
        }
        return null;
    }
    @Override
        Money amount = BroadleafCurrencyUtils.getMoney(.getOrder().getCurrency());
        for (PaymentTransaction tx : getTransactions()){
            if (type.equals(tx.getType())) {
                amount = amount.add(tx.getAmount());
            }
        }
        return amount;
    }
    
    @Override
        Money amount = BroadleafCurrencyUtils.getMoney(.getOrder().getCurrency());
        for (PaymentTransaction tx : getTransactions()){
            if (type.equals(tx.getType()) && tx.getSuccess()){
                amount = amount.add(tx.getAmount());
            }
        }
        return amount;
    }
    @Override
    public BroadleafCurrency getCurrency() {
        if ( != null) {
            return .getCurrency();
        }
        return null;
    }
    @Override
    public String getCurrencyCode() {
        if (getCurrency() != null) {
            return getCurrency().getCurrencyCode();
        }
        return null;
    }
    
    @Override
    public Character getArchived() {
        if ( == null) {
             = new ArchiveStatus();
        }
        return .getArchived();
    }
    @Override
    public void setArchived(Character archived) {
        if ( == null) {
             = new ArchiveStatus();
        }
        .setArchived(archived);
    }
    @Override
    public boolean isActive() {
        return 'Y' != getArchived();
    }
    
    @Override
    public boolean equals(Object obj) {
        if (obj instanceof OrderPaymentImpl) {
            OrderPaymentImpl that = (OrderPaymentImplobj;
            return new EqualsBuilder()
                .append(this.that.id)
                .append(this.that.referenceNumber)
                .append(this.that.type)
                .append(this.that.archiveStatus)
                .build();
        }
        return false;
    }
    @Override
    public int hashCode() {
        return new HashCodeBuilder()
            .append()
            .append()
            .append()
            .build();
    }
    public static class Presentation {
        public static class Tab {
            public static class Name {
                public static final String Address = "PaymentInfoImpl_Address_Tab";
                public static final String Log = "PaymentInfoImpl_Log_Tab";
                public static final String Advanced = "PaymentInfoImpl_Advanced_Tab";
            }
            public static class Order {
                public static final int Address = 2000;
                public static final int Log = 4000;
                public static final int Advanced = 5000;
            }
        }
        public static class Group {
            public static class Name {
                public static final String Items = "PaymentInfoImpl_Items";
            }
            public static class Order {
                public static final int Items = 1000;
            }
        }
        public static class FieldOrder {
            public static final int REFNUMBER = 3000;
        }
    }
New to GrepCode? Check out our FAQ X