I am trying to run the JAVA pgm, but it is giving error as "selection does not contain a main type".
The filename is "ScoreLeadSummary.java" when i try to run it or debug,it gives the pop up as "selection does not contain a main type"
Please help me out in resolving the above issue to run the .java file.
I am facing same issue with other .java files inside the project
The code is as shown below:
Expand|Select|Wrap|Line Numbers
- package com.trilogy.dealerportal.web.component.dealer;
- import com.trilogy.dealerportal.domain.Disposition;
- import com.trilogy.dealerportal.domain.ScoredLead;
- import com.trilogy.dealerportal.domain.ScoreCategory;
- import com.trilogy.dealerportal.security.AuthenticationService;
- import com.trilogy.dealerportal.service.DealerService;
- import com.trilogy.dealerportal.service.ScoreCategoryService;
- import org.apache.tapestry.BaseComponent;
- import org.apache.tapestry.IRequestCycle;
- import org.apache.tapestry.annotations.ComponentClass;
- import org.apache.tapestry.annotations.EventListener;
- import org.apache.tapestry.annotations.InjectObject;
- import org.apache.tapestry.annotations.Parameter;
- import org.apache.tapestry.components.IPrimaryKeyConverter;
- import org.apache.tapestry.event.BrowserEvent;
- import org.apache.tapestry.form.IPropertySelectionModel;
- import org.apache.tapestry.form.StringPropertySelectionModel;
- import org.json.JSONException;
- import org.json.JSONObject;
- import java.text.DateFormat;
- import java.text.DecimalFormat;
- import java.text.Format;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Comparator;
- import java.util.List;
- import java.util.Map;
- /**
- * Scored lead summary component
- *
- * @author SoftServe
- */
- @ComponentClass(allowBody = true, allowInformalParameters = false)
- public abstract class ScoredLeadSummary extends BaseComponent {
- private static final IPropertySelectionModel DISPOSITION_MODEL;
- private static final Format SCORE_FORMAT = new DecimalFormat("#");
- @InjectObject(value = "spring:dealerService")
- public abstract DealerService getDealerService();
- @InjectObject("spring:authenticationService")
- public abstract AuthenticationService getAuthenticationService();
- @Parameter(required = true)
- public abstract DateFormat getDateFormat();
- @Parameter(required = true)
- public abstract List<ScoredLead> getScoredLeads();
- @InjectObject("spring:scoreCategoryService")
- public abstract ScoreCategoryService getScoreCategoryService();
- @Parameter(required = true)
- public abstract int getItemsPerPage();
- @Parameter(required = true)
- public abstract int getCurrentPage();
- public abstract ScoredLead getLead();
- public abstract void setLead(ScoredLead lead);
- public abstract String getCurrent();
- public abstract void setCurrent(String current);
- public abstract int getOrder();
- public abstract void setOrder(int order);
- private List<ScoredLead> scoredLeads = new ArrayList<ScoredLead>();
- static {
- // initialize disposition model
- Disposition dispositions[] = Disposition.values();
- String strings[] = new String[dispositions.length];
- for (int i = 0; i < dispositions.length; i++) {
- strings[i] = dispositions[i].getDescription();
- }
- DISPOSITION_MODEL = new StringPropertySelectionModel(strings);
- }
- public List<ScoredLead> getSortedLeads() {
- int startIndex = getCurrentPage() * getItemsPerPage();
- if (startIndex >= scoredLeads.size() - getItemsPerPage()) {
- startIndex = scoredLeads.size() - getItemsPerPage();
- }
- if (startIndex < 0) {
- startIndex = 0;
- }
- int endIndex = startIndex + getItemsPerPage();
- if (endIndex > scoredLeads.size()) {
- endIndex = scoredLeads.size();
- }
- if (getCurrent() != null) {
- SortElement element = ((SortElement) getComponent(getCurrent()));
- Comparator<Object> comparator = element.getComparator(getOrder());
- if (comparator != null) {
- Collections.sort(scoredLeads, comparator);
- }
- }
- return scoredLeads.subList(startIndex, endIndex);
- }
- public boolean isCredit() {
- return getDealerService().getDealerById(getAuthenticationService().getUserId()).getCredit();
- }
- public Format getScoreFormat() {
- return SCORE_FORMAT;
- }
- public String getJson() throws JSONException {
- ScoredLead lead = getLead();
- ScoreCategoryService scoreCategoryService = getScoreCategoryService();
- JSONObject json = new JSONObject();
- json.append("firstName", lead.getFirstName());
- json.append("lastName", lead.getLastName());
- json.append("address", lead.getAddress());
- json.append("zip", lead.getZip());
- json.append("phone", lead.getPhone());
- json.append("email", lead.getEmail());
- json.append("year", lead.getYear());
- // make sure this is compatible with {@link #SCORE_FORMAT}
- ScoreCategory category = scoreCategoryService.getScoreCategoryByScore(Math.round(lead.getScore()));
- json.append("score", category.getName());
- json.append("make", lead.getMake());
- json.append("model", lead.getModel());
- json.append("autoFICO", lead.getAutoFICO());
- json.append("house", lead.getHouse());
- json.append("age", lead.getAge());
- json.append("incomeRange", lead.getIncomeRange());
- json.append("providerName", lead.getProviderName());
- json.append("requestDate", lead.getRequestDate() != null ? getDateFormat().format(lead.getRequestDate()) : "");
- json.append("autoLoans", lead.getAutoLoans());
- json.append("autoLeases", lead.getAutoLeases());
- json.append("scoreColor", category.getColor());
- return json.toString();
- }
- /**
- * Get map string representation. Displays string which consists of two components - map size and maximum map value.
- *
- * @param map map of values. Usually either {@link com.trilogy.dealerportal.domain.Lead#autoLoans} or
- * {@link com.trilogy.dealerportal.domain.Lead#autoLeases}
- * @return map string representation. Returns null if map either empty or has no values which are not nulls
- */
- public String toString(Map<String, Integer> map) {
- if (map == null || map.size() == 0) {
- return "";
- }
- Integer maxValue = null;
- for (Integer value: map.values()) {
- maxValue = (maxValue == null || value != null && value > maxValue ? value : maxValue);
- }
- return map.size() + "-$" + (maxValue == null ? 0 : maxValue);
- }
- public IPropertySelectionModel getDispositionModel() {
- return DISPOSITION_MODEL;
- }
- /**
- * Credit infor change event listener. {@link #setDisposition(String)} does actual work
- *
- * @param event event
- */
- @EventListener(targets = "dispositionSelect", events = "onchange")
- public void dispositionChange(BrowserEvent event) {
- // do nothing here
- }
- /**
- * Converter method to convert <code>ScoredLead</code> into <code>long</code> and vice versa
- *
- * @return converter
- */
- public IPrimaryKeyConverter getConverter() {
- return new IPrimaryKeyConverter() {
- public Object getPrimaryKey(Object o) {
- return getScoredLeads().indexOf(o);
- }
- public Object getValue(Object o) {
- return getScoredLeads().get((Integer) o);
- }
- };
- }
- public String getDisposition() {
- return getLead().getDisposition().getDescription();
- }
- public void setDisposition(String disposition) {
- // leads are read-only, at least for now
- }
- public void sort(String id, int order) {
- setCurrent(id);
- setOrder(order);
- }
- @Override
- protected void cleanupAfterRender(IRequestCycle cycle) {
- scoredLeads = null;
- super.cleanupAfterRender(cycle);
- }
- @Override
- protected void prepareForRender(IRequestCycle cycle) {
- scoredLeads = getScoredLeads();
- super.prepareForRender(cycle);
- }
- }