* @throws ClassNotFoundException
* @throws IOException
*/
public void offerteAttiveConScadenza(String user, JTextArea show_offers, String in_choice, GregorianCalendar datastart, GregorianCalendar data_end) throws FileNotFoundException, ClassNotFoundException, IOException
{
Entry loggedUser = Access.get_user_data(user);
ArrayList<Utilizzabile> arrayData = getDataExpire(datastart,data_end);
if(!(loggedUser.getType()))
{
//admin
if (in_choice.equals("1")){
class CompareDataScadenza implements Comparator<Utilizzabile> {
@Override
public int compare(Utilizzabile e1, Utilizzabile e2) {
if (e1 instanceof BeniDiConsumo){
//beni vs
if (e2 instanceof Vacanze){
//beni vs vacanze
if (((BeniDiConsumo)e1).getScadenza().getTimeInMillis() < ((Vacanze)e2).getScadenzaOfferta().getTimeInMillis())
return -1;
return 1;
}else{
if (e2 instanceof BeniDiConsumo){
//bene vs //bene
if (((BeniDiConsumo)e1).getScadenza().getTimeInMillis() < ((BeniDiConsumo)e2).getScadenza().getTimeInMillis())
return -1;
return 1;
}else{
//bene vs cena
if (e2 instanceof CeneInRistoranti) {
if (((BeniDiConsumo)e1).getScadenza().getTimeInMillis() < ((CeneInRistoranti)e2).getDataScadenzaOffertaCena().getTimeInMillis())
return -1;
return 1;
}else{
//bene vs prest
if (((BeniDiConsumo)e1).getScadenza().getTimeInMillis() < ((PrestazioniDopera)e2).getScadenza().getTimeInMillis())
return -1;
return 1;
}
}
}
}else{
if (e1 instanceof Vacanze){
//vacanze vs
if (e2 instanceof BeniDiConsumo){
//vacanze vs bene
if (((Vacanze)e1).getScadenzaOfferta().getTimeInMillis() < ((BeniDiConsumo)e2).getScadenza().getTimeInMillis())
return -1;
return 1;
}else{
if (e2 instanceof Vacanze){
//vacabnza vs vacanza
if (((Vacanze)e1).getScadenzaOfferta().getTimeInMillis() < ((Vacanze)e2).getScadenzaOfferta().getTimeInMillis())
return -1;
return 1;
}else{
//vacanza vs cena
if (e2 instanceof CeneInRistoranti) {
if (((Vacanze)e1).getScadenzaOfferta().getTimeInMillis() < ((CeneInRistoranti)e2).getDataScadenzaOffertaCena().getTimeInMillis())
return -1;
return 1;
}else{
//vacanza vs prest
if (((Vacanze)e1).getScadenzaOfferta().getTimeInMillis() < ((PrestazioniDopera)e2).getScadenza().getTimeInMillis())
return -1;
return 1;
}
}
}
}else{
//Cene vs
if (e1 instanceof CeneInRistoranti){
if (e2 instanceof Vacanze){
//cena vs vacanza
if (((CeneInRistoranti)e1).getDataScadenzaOffertaCena().getTimeInMillis() < ((Vacanze)e2).getScadenzaOfferta().getTimeInMillis())
return -1;
return 1;
}else{
if (e2 instanceof CeneInRistoranti){
//cena vs cena
if (((CeneInRistoranti)e1).getDataScadenzaOffertaCena().getTimeInMillis() < ((CeneInRistoranti)e2).getDataScadenzaOffertaCena().getTimeInMillis())
return -1;
return 1;
}else{
//cena vs bene
if (e2 instanceof BeniDiConsumo) {
if (((CeneInRistoranti)e1).getDataScadenzaOffertaCena().getTimeInMillis() < ((BeniDiConsumo)e2).getScadenza().getTimeInMillis())
return -1;
return 1;
}else{
//cena vs prest
if (((CeneInRistoranti)e1).getDataScadenzaOffertaCena().getTimeInMillis() < ((PrestazioniDopera)e2).getScadenza().getTimeInMillis())
return -1;
return 1;
}
}
}
}else{
if (e2 instanceof Vacanze){
//prest vs vacanza
if (((PrestazioniDopera)e1).getScadenza().getTimeInMillis() < ((Vacanze)e2).getScadenzaOfferta().getTimeInMillis())
return -1;
return 1;
}else{
if (e2 instanceof CeneInRistoranti){
//prest vs cena
if (((PrestazioniDopera)e1).getScadenza().getTimeInMillis() < ((CeneInRistoranti)e2).getDataScadenzaOffertaCena().getTimeInMillis())
return -1;
return 1;
}else{
//prest vs bene
if (e2 instanceof BeniDiConsumo) {
if (((PrestazioniDopera)e1).getScadenza().getTimeInMillis() < ((BeniDiConsumo)e2).getScadenza().getTimeInMillis())
return -1;
return 1;
}else{
//prest vs prest
if (((PrestazioniDopera)e1).getScadenza().getTimeInMillis() < ((PrestazioniDopera)e2).getScadenza().getTimeInMillis())
return -1;
return 1;
}
}
}
}
}
}
}
}
Collections.sort(arrayData,new CompareDataScadenza());
print_cat_admin (arrayData,show_offers);
}else{
class CompareID implements Comparator<Utilizzabile> {
@Override
public int compare(Utilizzabile e1, Utilizzabile e2) {
if (e1 instanceof BeniDiConsumo){
//beni vs
if (e2 instanceof Vacanze){
//beni vs vacanze
if (((BeniDiConsumo)e1).getIdBene() < ((Vacanze)e2).getIdViaggio())
return -1;
return 1;
}else{
if (e2 instanceof BeniDiConsumo){
//bene vs //bene
if (((BeniDiConsumo)e1).getIdBene() < ((BeniDiConsumo)e2).getIdBene())
return -1;
return 1;
}else{
//bene vs cena
if (e2 instanceof CeneInRistoranti){
if (((BeniDiConsumo)e1).getIdBene() < ((CeneInRistoranti)e2).getIdCena())
return -1;
return 1;
}else{
if (((BeniDiConsumo)e1).getIdBene() < ((PrestazioniDopera)e2).getIdPrOpera())
return -1;
return 1;
}
}
}
}else{
if (e1 instanceof Vacanze){
//vacanze vs
if (e2 instanceof BeniDiConsumo){
//vacanze vs bene
if (((Vacanze)e1).getIdViaggio() < ((BeniDiConsumo)e2).getIdBene())
return -1;
return 1;
}else{
if (e2 instanceof Vacanze){
//vacabnza vs vacanza
if (((Vacanze)e1).getIdViaggio() < ((Vacanze)e2).getIdViaggio())
return -1;
return 1;
}else{
//vacanza vs cena
if (e2 instanceof CeneInRistoranti){
if (((Vacanze)e1).getIdViaggio() < ((CeneInRistoranti)e2).getIdCena())
return -1;
return 1;
}else{
if (((Vacanze)e1).getIdViaggio() < ((PrestazioniDopera)e2).getIdPrOpera())
return -1;
return 1;
}
}
}
}else{
if (e1 instanceof CeneInRistoranti){
//Cene vs
if (e2 instanceof Vacanze){
//cena vs vacanza
if (((CeneInRistoranti)e1).getIdCena() < ((Vacanze)e2).getIdViaggio())
return -1;
return 1;
}else{
if (e2 instanceof CeneInRistoranti){
//cena vs cena
if (((CeneInRistoranti)e1).getIdCena() < ((CeneInRistoranti)e2).getIdCena())
return -1;
return 1;
}else{
//cena vs bene
if (e2 instanceof BeniDiConsumo){
if (((CeneInRistoranti)e1).getIdCena() < ((BeniDiConsumo)e2).getIdBene())
return -1;
return 1;
}else{
if (((CeneInRistoranti)e1).getIdCena() < ((PrestazioniDopera)e2).getIdPrOpera())
return -1;
return 1;
}
}
}
}else{
if (e2 instanceof Vacanze){
//prest vs vacanza
if (((PrestazioniDopera)e1).getIdPrOpera() < ((Vacanze)e2).getIdViaggio())
return -1;
return 1;
}else{
if (e2 instanceof CeneInRistoranti){
//prest vs cena
if (((PrestazioniDopera)e1).getIdPrOpera() < ((CeneInRistoranti)e2).getIdCena())
return -1;
return 1;
}else{
//prest vs bene
if (e2 instanceof BeniDiConsumo){
if (((PrestazioniDopera)e1).getIdPrOpera() < ((BeniDiConsumo)e2).getIdBene())
return -1;
return 1;
}else{
if (((PrestazioniDopera)e1).getIdPrOpera() < ((PrestazioniDopera)e2).getIdPrOpera())
return -1;
return 1;
}
}
}
}
}
}
}
}
Collections.sort(arrayData,new CompareID());
print_cat_admin (arrayData,show_offers);
}
} else{
// user
class CompareIDUser implements Comparator<Utilizzabile> {
@Override
public int compare(Utilizzabile e1, Utilizzabile e2) {
if (e1 instanceof BeniDiConsumo){
//beni vs
if (e2 instanceof Vacanze){
//beni vs vacanze
if (((BeniDiConsumo)e1).getIdBene() < ((Vacanze)e2).getIdViaggio())
return -1;
return 1;
}else{
if (e2 instanceof BeniDiConsumo){
//bene vs //bene
if (((BeniDiConsumo)e1).getIdBene() < ((BeniDiConsumo)e2).getIdBene())
return -1;
return 1;
}else{
//bene vs cena
if (e2 instanceof CeneInRistoranti){
if (((BeniDiConsumo)e1).getIdBene() < ((CeneInRistoranti)e2).getIdCena())
return -1;
return 1;
}else{
if (((BeniDiConsumo)e1).getIdBene() < ((PrestazioniDopera)e2).getIdPrOpera())
return -1;
return 1;
}
}
}
}else{
if (e1 instanceof Vacanze){
//vacanze vs
if (e2 instanceof BeniDiConsumo){
//vacanze vs bene
if (((Vacanze)e1).getIdViaggio() < ((BeniDiConsumo)e2).getIdBene())
return -1;
return 1;
}else{
if (e2 instanceof Vacanze){
//vacabnza vs vacanza
if (((Vacanze)e1).getIdViaggio() < ((Vacanze)e2).getIdViaggio())
return -1;
return 1;
}else{
//vacanza vs cena
if (e2 instanceof CeneInRistoranti){
if (((Vacanze)e1).getIdViaggio() < ((CeneInRistoranti)e2).getIdCena())
return -1;
return 1;
}else{
if (((Vacanze)e1).getIdViaggio() < ((PrestazioniDopera)e2).getIdPrOpera())
return -1;
return 1;
}
}
}
}else{
if (e1 instanceof CeneInRistoranti){
//Cene vs
if (e2 instanceof Vacanze){
//cena vs vacanza
if (((CeneInRistoranti)e1).getIdCena() < ((Vacanze)e2).getIdViaggio())
return -1;
return 1;
}else{
if (e2 instanceof CeneInRistoranti){
//cena vs cena
if (((CeneInRistoranti)e1).getIdCena() < ((CeneInRistoranti)e2).getIdCena())
return -1;
return 1;
}else{
//cena vs bene
if (e2 instanceof BeniDiConsumo){
if (((CeneInRistoranti)e1).getIdCena() < ((BeniDiConsumo)e2).getIdBene())
return -1;
return 1;
}else{
if (((CeneInRistoranti)e1).getIdCena() < ((PrestazioniDopera)e2).getIdPrOpera())
return -1;
return 1;
}
}
}
}else{
if (e2 instanceof Vacanze){
//prest vs vacanza
if (((PrestazioniDopera)e1).getIdPrOpera() < ((Vacanze)e2).getIdViaggio())
return -1;
return 1;
}else{
if (e2 instanceof CeneInRistoranti){
//prest vs cena
if (((PrestazioniDopera)e1).getIdPrOpera() < ((CeneInRistoranti)e2).getIdCena())
return -1;
return 1;
}else{
//prest vs bene
if (e2 instanceof BeniDiConsumo){
if (((PrestazioniDopera)e1).getIdPrOpera() < ((BeniDiConsumo)e2).getIdBene())
return -1;
return 1;
}else{
if (((PrestazioniDopera)e1).getIdPrOpera() < ((PrestazioniDopera)e2).getIdPrOpera())
return -1;
return 1;
}
}
}
}
}
}
}
}
Collections.sort(arrayData, new CompareIDUser());
print_cat_user(arrayData, loggedUser.getLocation(), show_offers);
}
}