You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
2.8 KiB
79 lines
2.8 KiB
package kr.co.kihyun.beans.entity; |
|
|
|
import java.util.Date; |
|
import java.util.List; |
|
import java.util.Map; |
|
|
|
import javax.jdo.PersistenceManager; |
|
import javax.jdo.Query; |
|
import javax.jdo.annotations.Discriminator; |
|
import javax.jdo.annotations.IdentityType; |
|
import javax.jdo.annotations.Inheritance; |
|
import javax.jdo.annotations.InheritanceStrategy; |
|
import javax.jdo.annotations.PersistenceCapable; |
|
|
|
import kr.co.kihyun.beans.entity.util.QueryImpl; |
|
import kr.co.kihyun.moumi.MoumiConfig; |
|
|
|
@PersistenceCapable(identityType = IdentityType.APPLICATION) |
|
@Inheritance(strategy = InheritanceStrategy.SUPERCLASS_TABLE) |
|
public class LimitBySubmitDateStrategy extends AcceptanceLimitStrategy { |
|
/** |
|
* |
|
*/ |
|
private static final long serialVersionUID = -6410603811430300673L; |
|
private static final String filter = |
|
"isDeleted == 'N' && type == TYPE_REPORT && " + |
|
"(process == PROCESS_COMP || process == PROCESS_END ) && " + |
|
"totDoc == tot_doc"; |
|
|
|
public LimitBySubmitDateStrategy() { |
|
} |
|
|
|
public LimitBySubmitDateStrategy(Long limitCount) { |
|
super(limitCount); |
|
} |
|
|
|
@SuppressWarnings("unchecked") |
|
@Override |
|
public List<TotReport> getCompReports(PersistenceManager pm, Map<String, Object> filterMap) { |
|
//System.out.println("9999999999999999999999999999999999999999999999999999999999999 LimitBySubmitDateStrategy.getComReports"); |
|
QueryImpl q = new QueryImpl(pm, TotReport.class); |
|
q.setFilter(filter); |
|
q.setSearchFilter(filterMap); |
|
q.declareParameters("kr.co.kihyun.beans.entity.TotDoc tot_doc"); |
|
q.setOrdering("submitDate"); |
|
q.setRange(0, this.getLimitCount()); |
|
return (List<TotReport>) q.execute(this.getTotDoc()); |
|
} |
|
|
|
@Override |
|
public TotDocProcess getProcess(PersistenceManager pm) { |
|
Query q = pm.newQuery(TotReport.class); |
|
q.setResult("count(this)"); |
|
q.setFilter(filter); |
|
q.declareParameters("kr.co.kihyun.beans.entity.TotDoc tot_doc"); |
|
System.out.println(q.execute(this.getTotDoc())); |
|
System.out.println((Long) q.execute(this.getTotDoc()) >= this.getLimitCount()); |
|
if ((Long) q.execute(this.getTotDoc()) >= this.getLimitCount()) |
|
return TotDocProcess.END; |
|
if (this.getTotDoc().getStartDate() == null || |
|
(this.getTotDoc().getStartDate().after(new Date()) && this.getProcess() == TotDocProcess.PRSS)) |
|
return TotDocProcess.REG; |
|
return this.getProcess(); |
|
} |
|
|
|
@Override |
|
public String getDescription(PersistenceManager pm) { |
|
Query q = pm.newQuery(TotReport.class); |
|
q.setResult("count(this)"); |
|
q.setFilter(filter); |
|
q.declareParameters("kr.co.kihyun.beans.entity.TotDoc tot_doc"); |
|
return new StringBuilder(30) |
|
.append(MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.endBySubmitCount")) |
|
.append(" - ").append((Long) q.execute(this.getTotDoc())).append("/").append(this.getLimitCount()) |
|
.append(" ").append(MoumiConfig.getMessageBundle().getString("moumi.message.tot_doc.coporation")) |
|
.toString(); |
|
} |
|
|
|
}
|
|
|