2018-07-06 15:30:00 +02:00
|
|
|
package com.eu.habbo.habbohotel.catalog;
|
|
|
|
|
|
|
|
import com.eu.habbo.messages.ISerialize;
|
|
|
|
import com.eu.habbo.messages.ServerMessage;
|
|
|
|
import gnu.trove.TCollections;
|
|
|
|
import gnu.trove.list.array.TIntArrayList;
|
|
|
|
import gnu.trove.map.TIntObjectMap;
|
|
|
|
import gnu.trove.map.hash.THashMap;
|
|
|
|
import gnu.trove.map.hash.TIntObjectHashMap;
|
2020-05-04 22:24:09 +02:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
2018-07-06 15:30:00 +02:00
|
|
|
|
|
|
|
import java.sql.ResultSet;
|
|
|
|
import java.sql.SQLException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public abstract class CatalogPage implements Comparable<CatalogPage>, ISerialize {
|
2020-05-04 22:24:09 +02:00
|
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(CatalogPage.class);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
protected final TIntArrayList offerIds = new TIntArrayList();
|
|
|
|
protected final THashMap<Integer, CatalogPage> childPages = new THashMap<>();
|
|
|
|
private final TIntObjectMap<CatalogItem> catalogItems = TCollections.synchronizedMap(new TIntObjectHashMap<>());
|
|
|
|
private final ArrayList<Integer> included = new ArrayList<>();
|
2018-07-06 15:30:00 +02:00
|
|
|
protected int id;
|
|
|
|
protected int parentId;
|
|
|
|
protected int rank;
|
|
|
|
protected String caption;
|
|
|
|
protected String pageName;
|
|
|
|
protected int iconColor;
|
|
|
|
protected int iconImage;
|
|
|
|
protected int orderNum;
|
|
|
|
protected boolean visible;
|
|
|
|
protected boolean enabled;
|
|
|
|
protected boolean clubOnly;
|
|
|
|
protected String layout;
|
|
|
|
protected String headerImage;
|
|
|
|
protected String teaserImage;
|
|
|
|
protected String specialImage;
|
|
|
|
protected String textOne;
|
|
|
|
protected String textTwo;
|
|
|
|
protected String textDetails;
|
|
|
|
protected String textTeaser;
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public CatalogPage() {
|
2019-05-24 00:57:22 +02:00
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public CatalogPage(ResultSet set) throws SQLException {
|
2018-07-06 15:30:00 +02:00
|
|
|
if (set == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this.id = set.getInt("id");
|
2019-05-26 20:14:53 +02:00
|
|
|
this.parentId = set.getInt("parent_id");
|
|
|
|
this.rank = set.getInt("min_rank");
|
|
|
|
this.caption = set.getString("caption");
|
|
|
|
this.pageName = set.getString("caption_save");
|
|
|
|
this.iconColor = set.getInt("icon_color");
|
|
|
|
this.iconImage = set.getInt("icon_image");
|
|
|
|
this.orderNum = set.getInt("order_num");
|
|
|
|
this.visible = set.getBoolean("visible");
|
|
|
|
this.enabled = set.getBoolean("enabled");
|
|
|
|
this.clubOnly = set.getBoolean("club_only");
|
|
|
|
this.layout = set.getString("page_layout");
|
|
|
|
this.headerImage = set.getString("page_headline");
|
|
|
|
this.teaserImage = set.getString("page_teaser");
|
2018-07-06 15:30:00 +02:00
|
|
|
this.specialImage = set.getString("page_special");
|
2019-05-26 20:14:53 +02:00
|
|
|
this.textOne = set.getString("page_text1");
|
|
|
|
this.textTwo = set.getString("page_text2");
|
|
|
|
this.textDetails = set.getString("page_text_details");
|
|
|
|
this.textTeaser = set.getString("page_text_teaser");
|
|
|
|
|
|
|
|
if (!set.getString("includes").isEmpty()) {
|
|
|
|
for (String id : set.getString("includes").split(";")) {
|
|
|
|
try {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.included.add(Integer.valueOf(id));
|
2019-05-26 20:14:53 +02:00
|
|
|
} catch (Exception e) {
|
2020-05-04 22:24:09 +02:00
|
|
|
LOGGER.error("Caught exception", e);
|
|
|
|
LOGGER.error("Failed to parse includes column value of (" + id + ") for catalog page (" + this.id + ")");
|
2018-07-06 15:30:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getId() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.id;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getParentId() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.parentId;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getRank() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.rank;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void setRank(int rank) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.rank = rank;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getCaption() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.caption;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getPageName() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.pageName;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getIconColor() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.iconColor;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getIconImage() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.iconImage;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public int getOrderNum() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.orderNum;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isVisible() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.visible;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isEnabled() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.enabled;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public boolean isClubOnly() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.clubOnly;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getLayout() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.layout;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getHeaderImage() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.headerImage;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getTeaserImage() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.teaserImage;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getSpecialImage() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.specialImage;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getTextOne() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.textOne;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getTextTwo() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.textTwo;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getTextDetails() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.textDetails;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public String getTextTeaser() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.textTeaser;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public TIntArrayList getOfferIds() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.offerIds;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void addOfferId(int offerId) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.offerIds.add(offerId);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void addItem(CatalogItem item) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.catalogItems.put(item.getId(), item);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public TIntObjectMap<CatalogItem> getCatalogItems() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.catalogItems;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public CatalogItem getCatalogItem(int id) {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.catalogItems.get(id);
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public ArrayList<Integer> getIncluded() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.included;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public THashMap<Integer, CatalogPage> getChildPages() {
|
2018-07-06 15:30:00 +02:00
|
|
|
return this.childPages;
|
|
|
|
}
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
public void addChildPage(CatalogPage page) {
|
2018-07-06 15:30:00 +02:00
|
|
|
this.childPages.put(page.getId(), page);
|
|
|
|
|
2019-05-26 20:14:53 +02:00
|
|
|
if (page.getRank() < this.getRank()) {
|
2018-07-06 15:30:00 +02:00
|
|
|
page.setRank(this.getRank());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@SuppressWarnings("NullableProblems")
|
|
|
|
@Override
|
|
|
|
public int compareTo(CatalogPage page) {
|
|
|
|
return this.getOrderNum() - page.getOrderNum();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public abstract void serialize(ServerMessage message);
|
|
|
|
}
|