[abportal] View of /src/main/java/eu/smartlm/abs/portal/view/data/ABSQuery.java
View of /src/main/java/eu/smartlm/abs/portal/view/data/ABSQuery.java
Parent Directory
| Revision Log
Revision 1 -
( download)
( annotate)
Wed Jul 28 10:05:51 2010 UTC
(13 years, 9 months ago)
by dgarcia
File size: 9179 byte(s)
First code commit
package eu.smartlm.abs.portal.view.data;
import java.util.Calendar;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import eu.smartlm.abs.portal.security.login.controller.LoginController;
import eu.smartlm.abs.portal.util.StringUtil;
/**
* Class that represents the Accounting and Billing Query that the user does with the portlet
* @author David García Pérez - CESGA
*
*/
public class ABSQuery {
//The different options
public static int NUMBER_OF_OPTIONS = 6;
public static String DATE_FORMAT = "yyyy/MM/dd";
public static String PRODUCT = "Product";
public static String USER = "User";
public static String ACCOUNTINGGROUP = "AccountingGroup";
public static String PROJECT = "Project";
public static String HOST = "Host";
public static String SUBMITHOST = "SubmitHost";
// Number of options
private int numberOptions = NUMBER_OF_OPTIONS;
// Possible form fields
private boolean products = true;
private boolean users = true;
private boolean accountingGroups = true;
private boolean projects = true;
private boolean hosts = true;
private boolean submithosts = true;
// Possible Queries
private Set<String> queryProducts = new HashSet<String>();
private Set<String> queryUsers = new HashSet<String>();
private Set<String> queryAccountingGroups = new HashSet<String>();
private Set<String> queryOrganizations = new HashSet<String>();
private Set<String> queryProjects = new HashSet<String>();
private Set<String> queryHosts = new HashSet<String>();
private Set<String> querySubmitHosts = new HashSet<String>();
// Possible Security Filters
private Set<String> securityUserFilter = new HashSet<String>();
private Set<String> securityAccountingGroupFilter = new HashSet<String>();
// Dates to search for Usage Records
private String startDate = "";
private String endDate = "";
private String firstOption = "";
private String secondOption = "";
//List of options to show in the forms
private Set<String> options = new HashSet<String>();
private int loginStatus = LoginController.LOGGED_OUT;
public ABSQuery() {
prepareOptions();
}
private void prepareOptions() {
options.clear();
options.add(PRODUCT);
options.add(USER);
options.add(ACCOUNTINGGROUP);
options.add(PROJECT);
options.add(HOST);
options.add(SUBMITHOST);
}
/**
* It resets all the variables to its default values
*/
public void reset() {
products = true;
projects = true;
users = true;
accountingGroups = true;
hosts = true;
submithosts = true;
numberOptions = NUMBER_OF_OPTIONS;
// We empty the already constructed query
queryAccountingGroups.clear();
queryHosts.clear();
queryOrganizations.clear();
queryProducts.clear();
queryProjects.clear();
querySubmitHosts.clear();
queryUsers.clear();
// We make all the options available again
prepareOptions();
// We reset the date fields
Date today = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(today);
calendar.add(Calendar.DATE, -7);
Date oneweekago = calendar.getTime();
startDate = StringUtil.dateToString(oneweekago);
endDate = StringUtil.dateToString(today);
firstOption = "";
secondOption = "";
}
@Override
public String toString() {
String string = "";
for(String option : options) {
string = string + " " + option;
}
string = string + " FIRST: " + firstOption + " Second: " + secondOption;
return string;
}
/**
* @return the products
*/
public boolean isProducts() {
return products;
}
/**
* @param products the products to set
*/
public void setProducts(boolean products) {
if(products) options.add(PRODUCT);
else options.remove(PRODUCT);
this.products = products;
}
/**
* @return the users
*/
public boolean isUsers() {
return users;
}
/**
* @param users the users to set
*/
public void setUsers(boolean users) {
if(users) options.add(USER);
else options.remove(USER);
this.users = users;
}
/**
* @return the AccountingGroups
*/
public boolean isAccountingGroups() {
return accountingGroups;
}
/**
* @param departments the departments to set
*/
public void setAccountingGroups(boolean accountingGroups) {
if(accountingGroups) options.add(ACCOUNTINGGROUP);
else options.remove(ACCOUNTINGGROUP);
this.accountingGroups = accountingGroups;
}
/**
* @return the project
*/
public boolean isProjects() {
return projects;
}
/**
* @param project the project to set
*/
public void setProjects(boolean project) {
if(project) options.add(PROJECT);
else options.remove(PROJECT);
this.projects = project;
}
/**
* @return the hosts
*/
public boolean isHosts() {
return hosts;
}
/**
* @param hosts the hosts to set
*/
public void setHosts(boolean hosts) {
if(hosts) options.add(HOST);
else options.remove(HOST);
this.hosts = hosts;
}
/**
* @return the submithosts
*/
public boolean isSubmithosts() {
return submithosts;
}
/**
* @param submithosts the submithosts to set
*/
public void setSubmithosts(boolean submithosts) {
if(submithosts) options.add(SUBMITHOST);
else options.remove(SUBMITHOST);
this.submithosts = submithosts;
}
/**
* This method returns a list of options currently available for the form
* @return options to be returned
*/
public Set<String> getOptions() {
return options;
}
/**
* @param numberOptions the numberOptions to set
*/
public void setNumberOptions(int numberOptions) {
this.numberOptions = numberOptions;
}
/**
* @return the numberOptions
*/
public int getNumberOptions() {
return numberOptions;
}
/**
* @return the queryProducts
*/
public Set<String> getQueryProducts() {
return queryProducts;
}
/**
* @param queryProducts the queryProducts to set
*/
public void setQueryProducts(Set<String> queryProducts) {
this.queryProducts = queryProducts;
}
/**
* @return the queryUsers
*/
public Set<String> getQueryUsers() {
return queryUsers;
}
/**
* @param queryUsers the queryUsers to set
*/
public void setQueryUsers(Set<String> queryUsers) {
this.queryUsers = queryUsers;
}
/**
* @return the queryDepartments
*/
public Set<String> getQueryAccountingGroups() {
return queryAccountingGroups;
}
/**
* @param queryDepartments the queryAccountingGroups to set
*/
public void setQueryAccountingGroups(Set<String> queryAccountingGroups) {
this.queryAccountingGroups = queryAccountingGroups;
}
/**
* @return the queryOrganizations
*/
public Set<String> getQueryOrganizations() {
return queryOrganizations;
}
/**
* @param queryOrganizations the queryOrganizations to set
*/
public void setQueryOrganizations(Set<String> queryOrganizations) {
this.queryOrganizations = queryOrganizations;
}
/**
* @return the queryProjects
*/
public Set<String> getQueryProjects() {
return queryProjects;
}
/**
* @param queryProjects the queryProjects to set
*/
public void setQueryProjects(Set<String> queryProjects) {
this.queryProjects = queryProjects;
}
/**
* @return the queryHosts
*/
public Set<String> getQueryHosts() {
return queryHosts;
}
/**
* @param queryHosts the queryHosts to set
*/
public void setQueryHosts(Set<String> queryHosts) {
this.queryHosts = queryHosts;
}
/**
* @return the querySubmitHosts
*/
public Set<String> getQuerySubmitHosts() {
return querySubmitHosts;
}
/**
* @param querySubmitHosts the querySubmitHosts to set
*/
public void setQuerySubmitHosts(Set<String> querySubmitHosts) {
this.querySubmitHosts = querySubmitHosts;
}
/**
* @param startDate the startDate to set
*/
public void setStartDate(String startDate) {
this.startDate = startDate;
}
/**
* @return the startDate
*/
public String getStartDate() {
return startDate;
}
/**
* @param endDate the endDate to set
*/
public void setEndDate(String endDate) {
this.endDate = endDate;
}
/**
* @return the endDate
*/
public String getEndDate() {
return endDate;
}
/**
* @param firstOption the firstOption to set
*/
public void setFirstOption(String firstOption) {
this.firstOption = firstOption;
}
/**
* @return the firstOption
*/
public String getFirstOption() {
return firstOption;
}
/**
* @param secondOption the secondOption to set
*/
public void setSecondOption(String secondOption) {
this.secondOption = secondOption;
}
/**
* @return the secondOption
*/
public String getSecondOption() {
return secondOption;
}
public void setSecurityUserFilter(Set<String> securityUserFilter) {
this.securityUserFilter = securityUserFilter;
}
public Set<String> getSecurityUserFilter() {
return securityUserFilter;
}
public void setSecurityAccountingGroupFilter(
Set<String> securityAccountingGroupFilter) {
this.securityAccountingGroupFilter = securityAccountingGroupFilter;
}
public Set<String> getSecurityAccountingGroupFilter() {
return securityAccountingGroupFilter;
}
public void setLoginStatus(int loginStatus) {
this.loginStatus = loginStatus;
}
public int getLoginStatus() {
return loginStatus;
}
}
|