I have created a view model (below). It is not clear to me how to either get it to display.
* * Copyright 2012-2013 Eurocommercial Properties NV * * * 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. */ package dom.todo; import java.math.BigDecimal; import java.util.List; import javax.jdo.annotations.Extension; import javax.jdo.annotations.IdentityType; import javax.jdo.annotations.InheritanceStrategy; import org.joda.time.LocalDate; import org.apache.isis.applib.AbstractViewModel; import org.apache.isis.applib.annotation.Bookmarkable; import org.apache.isis.applib.annotation.DescribedAs; import org.apache.isis.applib.annotation.Hidden; import org.apache.isis.applib.annotation.Immutable; import org.apache.isis.applib.annotation.Optional; import org.apache.isis.applib.annotation.Render; import org.apache.isis.applib.annotation.Render.Type; import org.apache.isis.applib.annotation.Title; /** * View model that provides a summary of the sales made on a given day by each party */ @javax.jdo.annotations.PersistenceCapable( identityType = IdentityType.NONDURABLE, table = "DailySalesTotalForParty", extensions = { @Extension(vendorName = "datanucleus", key = "view-definition", value = "CREATE VIEW \"DailySalesTotalForParty\" " + "( " + " {this.transactionDate}, " + " {this.fromPartyId}, " + " {this.transactiontype}, " + " {this.totalAmount} " + ") AS " + "SELECT " + " \"Tranaction\".\"transactiondate\" , " + " \"Transaction.\".\"fromparty_party_id_oid\", " + " \"Transaction.\".\"transactiontype\", " + " SUM(\"Transaction\".\"facevalue\") AS \"totalAmount\", " + " FROM \"Transaction\" " + "GROUP BY " + " \"Transaction\".\"fromparty_party_id_oid\", " + " \"Transaction\".\"transactiondate\"") }) @javax.jdo.annotations.Inheritance(strategy = InheritanceStrategy.NEW_TABLE) @Bookmarkable @Immutable public class DailySalesTotalForParty extends AbstractViewModel { private static final String OID_SEPARATOR = "_AND_"; // ////////////////////////////////////// /** * {@link org.apache.isis.applib.ViewModel} implementation. */ @Override public String viewModelMemento() { return getFromPartyId() + OID_SEPARATOR + getTransactionDate().toString(); } /** * {@link org.apache.isis.applib.ViewModel} implementation. */ @Override public void viewModelInit(final String memento) { String[] split = memento.split(OID_SEPARATOR); setFromPartyId(split[0]); setTransactionDate(new LocalDate(split[1])); } // ////////////////////////////////////// private String fromPartyId; /** * Used as the {@link #viewModelMemento() view model memento}, holds the * reference of the corresponding {@link #getProperty()}. * * <p> * This attribute is always guaranteed to be populated. */ @javax.jdo.annotations.Column(allowsNull = "false") @DescribedAs("From Party Id") @Hidden public String getFromPartyId() { return fromPartyId; } public void setFromPartyId(final String reference) { this.fromPartyId = reference; } // ////////////////////////////////////// /** * Annotated as {@link javax.jdo.annotations.NotPersistent not persistent} * because not mapped in the <tt>view-definition</tt>. */ @javax.jdo.annotations.NotPersistent private Party fromParty; /** * Lazily loaded from the {@link #getReference() reference}, provides access * to the underlying {@link Property}. */ @Optional @Title(sequence = "1") public Party getFromParty() { if (fromParty == null) { setFromParty(partytypes.findPartyFromOID(getFromPartyId())); } return fromParty; } public void setFromParty(final Party party) { this.fromParty = party; } // ////////////////////////////////////// private LocalDate transactionDate; @Title(sequence = "2", prepend = " - ") public LocalDate getTransactionDate() { return transactionDate; } public void setTransactionDate(final LocalDate dueDate) { this.transactionDate = dueDate; } // ////////////////////////////////////// private BigDecimal totalAmount; public BigDecimal getTotalAmount() { return totalAmount; } public void setTotalAmount(final BigDecimal total) { this.totalAmount = total; } // ////////////////////////////////////// @Render(Type.EAGERLY) public List<Transaction> getTransactions() { return transactions.findTransactionsForPartyAndDate(getParty(), getTransactionDate()); } // ////////////////////////////////////// private Partytypes partytypes; final public void injectPartytypes(final Partytypes partytypes) { this.partytypes = partytypes; } private Transactions transactions; final public void injectTransactions(final Transactions transactions) { this.transactions = transactions; } }
