Skip to content

Commit

Permalink
New Feature: Save industry jobs history (optional, on by default)
Browse files Browse the repository at this point in the history
Merge Feature
  • Loading branch information
GoldenGnu committed May 12, 2024
2 parents 321f55e + d5caa77 commit 8c6498c
Show file tree
Hide file tree
Showing 34 changed files with 391 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public abstract class AbstractOwner implements OwnerType, Comparable<OwnerType>
private Set<MyMarketOrder> marketOrders = new HashSet<>();
private Set<MyTransaction> transactions = new HashSet<>();
private Set<MyJournal> journal = new HashSet<>();
private List<MyIndustryJob> industryJobs = new ArrayList<>();
private Set<MyIndustryJob> industryJobs = new HashSet<>();
private Map<MyContract, List<MyContractItem>> contracts = new HashMap<>();
private List<MyAsset> assets = new ArrayList<>();
private Map<Long, RawBlueprint> blueprints = new HashMap<>();
Expand Down Expand Up @@ -357,7 +357,7 @@ public final Set<MyJournal> getJournal() {
}

@Override
public final List<MyIndustryJob> getIndustryJobs() {
public final Set<MyIndustryJob> getIndustryJobs() {
return industryJobs;
}

Expand Down Expand Up @@ -425,7 +425,7 @@ public final void setBlueprints(final Map<Long, RawBlueprint> blueprints) {
}

@Override
public final void setIndustryJobs(final List<MyIndustryJob> industryJobs) {
public final void setIndustryJobs(final Set<MyIndustryJob> industryJobs) {
this.industryJobs = industryJobs;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public interface OwnerType extends Comparable<OwnerType> {
public Set<MyMarketOrder> getMarketOrders();
public Set<MyTransaction> getTransactions();
public Set<MyJournal> getJournal();
public List<MyIndustryJob> getIndustryJobs();
public Set<MyIndustryJob> getIndustryJobs();
public Map<MyContract, List<MyContractItem>> getContracts();
public List<MyAsset> getAssets();
public Map<Long, RawBlueprint> getBlueprints();
Expand All @@ -79,7 +79,7 @@ public interface OwnerType extends Comparable<OwnerType> {
public List<MyMining> getMining();
public List<MyExtraction> getExtractions();
public void setBlueprints(final Map<Long, RawBlueprint> blueprints);
public void setIndustryJobs(final List<MyIndustryJob> industryJobs);
public void setIndustryJobs(final Set<MyIndustryJob> industryJobs);
public void setTransactions(final Set<MyTransaction> transactions);
public void setJournal(final Set<MyJournal> journal);
public void setMarketOrders(final Set<MyMarketOrder> marketOrders);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,11 @@ public String getAvailabilityFormatted() {
}
}

@Override
public void archive() {
this.esi = false;
}

@Override
public boolean isESI() {
return esi;
Expand Down
165 changes: 71 additions & 94 deletions src/main/java/net/nikr/eve/jeveasset/data/api/my/MyIndustryJob.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,64 +31,13 @@
import net.nikr.eve.jeveasset.data.settings.types.BlueprintType;
import net.nikr.eve.jeveasset.data.settings.types.EditableLocationType;
import net.nikr.eve.jeveasset.data.settings.types.EditablePriceType;
import net.nikr.eve.jeveasset.data.settings.types.EsiType;
import net.nikr.eve.jeveasset.data.settings.types.ItemType;
import net.nikr.eve.jeveasset.data.settings.types.OwnersType;
import net.nikr.eve.jeveasset.i18n.DataModelIndustryJob;
import net.nikr.eve.jeveasset.io.shared.ApiIdConverter;

public class MyIndustryJob extends RawIndustryJob implements Comparable<MyIndustryJob>, EditableLocationType, ItemType, EditablePriceType, BlueprintType, OwnersType {

public enum IndustryJobState {
STATE_ALL() {
@Override
String getI18N() {
return DataModelIndustryJob.get().stateAll();
}
},
STATE_PAUSED() {
@Override
String getI18N() {
return DataModelIndustryJob.get().statePaused();
}
},
STATE_ACTIVE() {
@Override
String getI18N() {
return DataModelIndustryJob.get().stateActive();
}
},
STATE_DONE() {
@Override
String getI18N() {
return DataModelIndustryJob.get().stateDone();
}
},
STATE_DELIVERED() {
@Override
String getI18N() {
return DataModelIndustryJob.get().stateDelivered();
}
},
STATE_CANCELLED() {
@Override
String getI18N() {
return DataModelIndustryJob.get().stateCancelled();
}
},
STATE_REVERTED() {
@Override
String getI18N() {
return DataModelIndustryJob.get().stateReverted();
}
};

abstract String getI18N();

@Override
public String toString() {
return getI18N();
}
}
public class MyIndustryJob extends RawIndustryJob implements Comparable<MyIndustryJob>, EditableLocationType, ItemType, EditablePriceType, BlueprintType, OwnersType, EsiType {

public enum IndustryActivity {
ACTIVITY_ALL() {
Expand Down Expand Up @@ -192,7 +141,6 @@ public String getDescriptionOf(final MyIndustryJob job) {
}

private IndustryActivity activity;
private IndustryJobState state;
private final Item item;
private final Item output;
private final OwnerType owner;
Expand All @@ -205,6 +153,7 @@ public String getDescriptionOf(final MyIndustryJob job) {
private String completedCharacter = "";
private MyBlueprint blueprint;
private MyLocation location;
private boolean esi = true;
private boolean owned;

public MyIndustryJob(final RawIndustryJob rawIndustryJob, final Item item, final Item output, final OwnerType owner) {
Expand Down Expand Up @@ -254,37 +203,6 @@ public MyIndustryJob(final RawIndustryJob rawIndustryJob, final Item item, final
activity = IndustryActivity.ACTIVITY_UNKNOWN;
break;
}
IndustryJobStatus status = getStatus();
if (status == null) {
state = null;
} else {
switch (getStatus()) {
case ACTIVE: //Active
if (getEndDate().before(Settings.getNow())) {
state = IndustryJobState.STATE_DONE;
} else {
state = IndustryJobState.STATE_ACTIVE;
}
break;
case PAUSED:
state = IndustryJobState.STATE_PAUSED;
break;
case READY:
state = IndustryJobState.STATE_DONE;
break;
case DELIVERED:
state = IndustryJobState.STATE_DELIVERED;
break;
case CANCELLED:
state = IndustryJobState.STATE_CANCELLED;
break;
case REVERTED:
state = IndustryJobState.STATE_REVERTED;
break;
default:
state = null;
}
}
switch (activity) {
case ACTIVITY_MANUFACTURING:
outputCount = getRuns() * item.getProductQuantity();
Expand Down Expand Up @@ -358,16 +276,18 @@ public Integer getTypeID() {
}

public final boolean isCompletedSuccessful() {
return getState() == IndustryJobState.STATE_DELIVERED;
return getStatus() == IndustryJobStatus.DELIVERED;
}

public final boolean isDone() {
return getState() == IndustryJobState.STATE_DELIVERED
|| getState() == IndustryJobState.STATE_CANCELLED
|| getState() == IndustryJobState.STATE_REVERTED
return getStatus() == IndustryJobStatus.DELIVERED
|| getStatus() == IndustryJobStatus.CANCELLED
|| getStatus() == IndustryJobStatus.REVERTED
|| getStatus() == IndustryJobStatus.ARCHIVED
;
}


public final boolean isNotDeliveredToAssets() {
return owner.getAssetLastUpdate() == null //if null -> never updated -> not delivered to assets -> true
|| getCompletedDate() == null //if null -> not completed -> not delivered to assets -> true
Expand Down Expand Up @@ -406,14 +326,53 @@ public IndustryActivity getActivity() {
return activity;
}

public IndustryJobState getState() {
//Update STATE_DONE (may have changed after loading profile)
if (getEndDate().before(Settings.getNow()) && state == IndustryJobState.STATE_ACTIVE) {
state = IndustryJobState.STATE_DONE;
public boolean isExpired() {
return getEndDate().before(Settings.getNow());
}

@Override
public IndustryJobStatus getStatus() {
//Update READY (may have changed after loading profile)
if (isExpired() && super.getStatus() == IndustryJobStatus.ACTIVE) {
setStatus(IndustryJobStatus.READY);
}
return state;
return super.getStatus();
}

public String getStatusFormatted() {
return getStatusName(getStatus(), isExpired());
}

public static String getStatusName(IndustryJobStatus status) {
return getStatusName(status, false);
}

public static String getStatusName(IndustryJobStatus status, boolean expired) {
switch (status) {
case ACTIVE: //Active
if (expired) {
return DataModelIndustryJob.get().statusDone();
} else {
return DataModelIndustryJob.get().statusActive();
}
case PAUSED:
return DataModelIndustryJob.get().statusPaused();
case READY:
return DataModelIndustryJob.get().statusDone();
case DELIVERED:
return DataModelIndustryJob.get().statusDelivered();
case CANCELLED:
return DataModelIndustryJob.get().statusCancelled();
case REVERTED:
return DataModelIndustryJob.get().statusReverted();
case ARCHIVED:
return DataModelIndustryJob.get().statusArchived();
default:
return DataModelIndustryJob.get().statusUnknown();
}
}


@Override
public void setDynamicPrice(double price) {
this.price = price;
Expand Down Expand Up @@ -519,6 +478,24 @@ public int getProductQuantity() {
return item.getProductQuantity();
}

@Override
public void archive() {
if (esi && (getStatus() == IndustryJobStatus.READY || getStatus() == IndustryJobStatus.ACTIVE)) {
setStatus(IndustryJobStatus.ARCHIVED);
}
this.esi = false;
}

@Override
public boolean isESI() {
return esi;
}

@Override
public void setESI(boolean esi) {
this.esi = esi;
}

@Override
public Item getItem() {
return item;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public MyMarketOrder(final RawMarketOrder rawMarketOrder, final Item item, final
this.owned = !rawMarketOrder.isCorp();
}

public void close() {
@Override
public void archive() {
if (esi && getState() == MarketOrderState.OPEN) { //Only do once, as the user can set the state to open
setState(MarketOrderState.UNKNOWN);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public enum IndustryJobStatus {
DELIVERED("delivered"),
PAUSED("paused"),
READY("ready"),
REVERTED("reverted");
REVERTED("reverted"),
ARCHIVED("archived");

private final String value;

Expand Down Expand Up @@ -333,7 +334,7 @@ public void setStationID(Long stationId) {
this.stationId = stationId;
}

public final IndustryJobStatus getStatus() {
public IndustryJobStatus getStatus() {
return statusEnum;
}

Expand Down
28 changes: 21 additions & 7 deletions src/main/java/net/nikr/eve/jeveasset/data/settings/Settings.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import java.util.TreeMap;
import net.nikr.eve.jeveasset.SplashUpdater;
import net.nikr.eve.jeveasset.data.api.my.MyIndustryJob;
import net.nikr.eve.jeveasset.data.api.raw.RawIndustryJob.IndustryJobStatus;
import net.nikr.eve.jeveasset.data.api.raw.RawMarketOrder.MarketOrderRange;
import net.nikr.eve.jeveasset.data.settings.tag.Tag;
import net.nikr.eve.jeveasset.data.settings.tag.TagID;
Expand Down Expand Up @@ -102,7 +103,8 @@ public static enum SettingFlag {
FLAG_EASY_CHART_COLORS,
FLAG_CONTAINERS_SHOW_ITEM_ID,
FLAG_LOCK_TOOLS,
FLAG_SHOW_SUBPILE_TREE
FLAG_SHOW_SUBPILE_TREE,
FLAG_INDUSTRY_JOBS_HISTORY
}

public static enum TransactionProfitPrice {
Expand Down Expand Up @@ -301,6 +303,7 @@ protected Settings() {
flags.put(SettingFlag.FLAG_CONTAINERS_SHOW_ITEM_ID, true);
flags.put(SettingFlag.FLAG_LOCK_TOOLS, false);
flags.put(SettingFlag.FLAG_SHOW_SUBPILE_TREE, true);
flags.put(SettingFlag.FLAG_INDUSTRY_JOBS_HISTORY, true);
cacheFlags();
//Default Filters
List<Filter> filter;
Expand All @@ -327,14 +330,16 @@ protected Settings() {
//Industry Jobs: Default Filters
Map<String, List<Filter>> industryJobsTabDefaultFilters = new HashMap<>();
filter = new ArrayList<>();
filter.add(new Filter(Filter.LogicType.AND, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS_NOT, MyIndustryJob.IndustryJobState.STATE_DELIVERED.toString()));
filter.add(new Filter(Filter.LogicType.AND, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS_NOT, MyIndustryJob.IndustryJobState.STATE_CANCELLED.toString()));
filter.add(new Filter(Filter.LogicType.AND, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS_NOT, MyIndustryJob.IndustryJobState.STATE_REVERTED.toString()));
filter.add(new Filter(Filter.LogicType.AND, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS_NOT, MyIndustryJob.getStatusName(IndustryJobStatus.DELIVERED)));
filter.add(new Filter(Filter.LogicType.AND, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS_NOT, MyIndustryJob.getStatusName(IndustryJobStatus.CANCELLED)));
filter.add(new Filter(Filter.LogicType.AND, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS_NOT, MyIndustryJob.getStatusName(IndustryJobStatus.REVERTED)));
filter.add(new Filter(Filter.LogicType.AND, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS_NOT, MyIndustryJob.getStatusName(IndustryJobStatus.ARCHIVED)));
industryJobsTabDefaultFilters.put(TabsJobs.get().active(), filter);
filter = new ArrayList<>();
filter.add(new Filter(Filter.LogicType.OR, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS, MyIndustryJob.IndustryJobState.STATE_DELIVERED.toString()));
filter.add(new Filter(Filter.LogicType.OR, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS, MyIndustryJob.IndustryJobState.STATE_CANCELLED.toString()));
filter.add(new Filter(Filter.LogicType.OR, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS, MyIndustryJob.IndustryJobState.STATE_REVERTED.toString()));
filter.add(new Filter(Filter.LogicType.OR, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS, MyIndustryJob.getStatusName(IndustryJobStatus.DELIVERED)));
filter.add(new Filter(Filter.LogicType.OR, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS, MyIndustryJob.getStatusName(IndustryJobStatus.CANCELLED)));
filter.add(new Filter(Filter.LogicType.OR, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS, MyIndustryJob.getStatusName(IndustryJobStatus.REVERTED)));
filter.add(new Filter(Filter.LogicType.OR, IndustryJobTableFormat.STATE, Filter.CompareType.EQUALS, MyIndustryJob.getStatusName(IndustryJobStatus.ARCHIVED)));
industryJobsTabDefaultFilters.put(TabsJobs.get().completed(), filter);
defaultTableFilters.put(IndustryJobsTab.NAME, industryJobsTabDefaultFilters);
//Extractions Default Filters
Expand Down Expand Up @@ -900,6 +905,15 @@ public boolean isJournalHistory() {
public void setJournalHistory(final boolean journalHistory) {
flags.put(SettingFlag.FLAG_JOURNAL_HISTORY, journalHistory);
}

public boolean isIndustryJobsHistory() {
return flags.get(SettingFlag.FLAG_INDUSTRY_JOBS_HISTORY);
}

public void setIndustryJobsHistory(final boolean journalHistory) {
flags.put(SettingFlag.FLAG_INDUSTRY_JOBS_HISTORY, journalHistory);
}

public boolean isMarketOrderHistory() {
return flags.get(SettingFlag.FLAG_MARKET_ORDER_HISTORY);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@


public interface EsiType {
public void archive();
public void setESI(boolean esi);
public boolean isESI();
}
Loading

0 comments on commit 8c6498c

Please sign in to comment.