From 0511258bc9b3672d163367a8168d15f7a00cf613 Mon Sep 17 00:00:00 2001 From: GoldenGnu Date: Sun, 27 Oct 2024 14:14:54 +0100 Subject: [PATCH 1/4] Code: Removed contract expired status and added archived Contracts now work the same way as industry jobs. Setting archived status on active contracts the first time they're no longer in ESI. Allowing people to change the status later themself --- .../eve/jeveasset/data/api/my/MyContract.java | 31 +++++++------------ .../jeveasset/data/api/raw/RawContract.java | 3 +- .../eve/jeveasset/i18n/TabsContracts.java | 2 +- .../eve/jeveasset/io/local/ProfileReader.java | 5 +++ .../eve/jeveasset/io/local/ProfileWriter.java | 1 + .../jeveasset/i18n/TabsContracts.properties | 2 +- .../nikr/eve/jeveasset/data/raw/RawUtil.java | 4 +++ .../io/shared/ConverterTestUtil.java | 3 ++ 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/main/java/net/nikr/eve/jeveasset/data/api/my/MyContract.java b/src/main/java/net/nikr/eve/jeveasset/data/api/my/MyContract.java index d6edb8b3c..a1d1e2ee3 100644 --- a/src/main/java/net/nikr/eve/jeveasset/data/api/my/MyContract.java +++ b/src/main/java/net/nikr/eve/jeveasset/data/api/my/MyContract.java @@ -185,13 +185,13 @@ public boolean isIgnoreContract() { } public boolean isOpen() { - //in ESI (if not in ESI, the status is unknown) and open (Note: expired isn't a contract completion) - return esi && getStatus() == ContractStatus.OUTSTANDING; + //Note: expired isn't a contract completion + return getStatus() == ContractStatus.OUTSTANDING; } public boolean isInProgress() { - //in ESI (if not in ESI, the status is unknown) and open (Note: expired isn't a contract completion) - return esi && getStatus() == ContractStatus.IN_PROGRESS; + //Note: expired isn't a contract completion + return getStatus() == ContractStatus.IN_PROGRESS; } public boolean isDeleted() { @@ -215,14 +215,10 @@ public void setOwned(boolean owned) { } public String getStatusFormatted() { - return getStatusName(super.getStatus(), isExpired()); + return getStatusName(super.getStatus()); } public static String getStatusName(ContractStatus status) { - return getStatusName(status, false); - } - - public static String getStatusName(ContractStatus status, boolean expired) { switch (status) { case CANCELLED: return TabsContracts.get().statusCancelled(); @@ -237,21 +233,15 @@ public static String getStatusName(ContractStatus status, boolean expired) { case FAILED: return TabsContracts.get().statusFailed(); case IN_PROGRESS: - if (expired) { - return TabsContracts.get().statusExpired(); - } else { - return TabsContracts.get().statusInProgress(); - } + return TabsContracts.get().statusInProgress(); case OUTSTANDING: - if (expired) { - return TabsContracts.get().statusExpired(); - } else { - return TabsContracts.get().statusOutstanding(); - } + return TabsContracts.get().statusOutstanding(); case REJECTED: return TabsContracts.get().statusRejected(); case REVERSED: return TabsContracts.get().statusReversed(); + case ARCHIVED: + return TabsContracts.get().statusArchived(); default: return TabsContracts.get().statusUnknown(); } @@ -267,6 +257,9 @@ public String getAvailabilityFormatted() { @Override public void archive() { + if (esi && (getStatus() == ContractStatus.OUTSTANDING || getStatus() == ContractStatus.IN_PROGRESS)) { + setStatus(ContractStatus.ARCHIVED); + } this.esi = false; } diff --git a/src/main/java/net/nikr/eve/jeveasset/data/api/raw/RawContract.java b/src/main/java/net/nikr/eve/jeveasset/data/api/raw/RawContract.java index d6097b1bc..c680268c7 100644 --- a/src/main/java/net/nikr/eve/jeveasset/data/api/raw/RawContract.java +++ b/src/main/java/net/nikr/eve/jeveasset/data/api/raw/RawContract.java @@ -54,7 +54,8 @@ public enum ContractStatus { REJECTED("rejected"), FAILED("failed"), DELETED("deleted"), - REVERSED("reversed"); + REVERSED("reversed"), + ARCHIVED("archived"); private final String value; diff --git a/src/main/java/net/nikr/eve/jeveasset/i18n/TabsContracts.java b/src/main/java/net/nikr/eve/jeveasset/i18n/TabsContracts.java index 4efd6a080..c91657323 100644 --- a/src/main/java/net/nikr/eve/jeveasset/i18n/TabsContracts.java +++ b/src/main/java/net/nikr/eve/jeveasset/i18n/TabsContracts.java @@ -104,6 +104,7 @@ public TabsContracts(final Locale locale) { public abstract String sellingAssets(); public abstract String sold(); public abstract String status(); + public abstract String statusArchived(); public abstract String statusCancelled(); public abstract String statusCompleted(); public abstract String statusCompletedByContractor(); @@ -114,7 +115,6 @@ public TabsContracts(final Locale locale) { public abstract String statusOutstanding(); public abstract String statusRejected(); public abstract String statusReversed(); - public abstract String statusExpired(); public abstract String statusUnknown(); public abstract String title(); public abstract String type(); diff --git a/src/main/java/net/nikr/eve/jeveasset/io/local/ProfileReader.java b/src/main/java/net/nikr/eve/jeveasset/io/local/ProfileReader.java index 97b72f745..b7a8b490b 100644 --- a/src/main/java/net/nikr/eve/jeveasset/io/local/ProfileReader.java +++ b/src/main/java/net/nikr/eve/jeveasset/io/local/ProfileReader.java @@ -50,6 +50,7 @@ import net.nikr.eve.jeveasset.data.api.raw.RawAsset; import net.nikr.eve.jeveasset.data.api.raw.RawBlueprint; import net.nikr.eve.jeveasset.data.api.raw.RawContract; +import net.nikr.eve.jeveasset.data.api.raw.RawContract.ContractStatus; import net.nikr.eve.jeveasset.data.api.raw.RawContractItem; import net.nikr.eve.jeveasset.data.api.raw.RawExtraction; import net.nikr.eve.jeveasset.data.api.raw.RawIndustryJob; @@ -352,10 +353,14 @@ private void parseContracts(final Element element, final OwnerType owner) throws Map> contracts = new HashMap<>(); for (int a = 0; a < contractsNodes.getLength(); a++) { Element contractsNode = (Element) contractsNodes.item(a); + boolean archivedMigrated = getBooleanNotNull(contractsNode, "archived", false); NodeList contractNodes = contractsNode.getElementsByTagName("contract"); for (int b = 0; b < contractNodes.getLength(); b++) { Element contractNode = (Element) contractNodes.item(b); MyContract contract = parseContract(contractNode); + if (!archivedMigrated && !contract.isESI() && (contract.isOpen() || contract.isInProgress())) { + contract.setStatus(ContractStatus.ARCHIVED); + } NodeList itemNodes = contractNode.getElementsByTagName("contractitem"); List contractItems = new ArrayList<>(); for (int c = 0; c < itemNodes.getLength(); c++) { diff --git a/src/main/java/net/nikr/eve/jeveasset/io/local/ProfileWriter.java b/src/main/java/net/nikr/eve/jeveasset/io/local/ProfileWriter.java index 9e8dcee28..b9547a4b4 100644 --- a/src/main/java/net/nikr/eve/jeveasset/io/local/ProfileWriter.java +++ b/src/main/java/net/nikr/eve/jeveasset/io/local/ProfileWriter.java @@ -238,6 +238,7 @@ private void writeActiveShip(Document xmldoc, Element parentNode, MyShip activeS private void writeContractItems(Document xmldoc, Element parentNode, Map> contractItems) { Element contractsNode = xmldoc.createElement("contracts"); + setAttribute(contractsNode, "archived", true); parentNode.appendChild(contractsNode); for (Map.Entry> entry : contractItems.entrySet()) { MyContract contract = entry.getKey(); diff --git a/src/main/resources/net/nikr/eve/jeveasset/i18n/TabsContracts.properties b/src/main/resources/net/nikr/eve/jeveasset/i18n/TabsContracts.properties index 915688e34..1dc4f78e9 100644 --- a/src/main/resources/net/nikr/eve/jeveasset/i18n/TabsContracts.properties +++ b/src/main/resources/net/nikr/eve/jeveasset/i18n/TabsContracts.properties @@ -67,6 +67,7 @@ sellingPrice=Total price of shown outstanding sell contracts sellingAssets=Total value of assets in shown outstanding sell contracts sold=Total price of shown completed sell contracts status=Status +statusArchived=Archived statusCancelled=Cancelled statusCompleted=Completed statusCompletedByContractor=Completed by Contractor @@ -77,7 +78,6 @@ statusInProgress=In Progress statusOutstanding=Outstanding statusRejected=Rejected statusReversed=Reversed -statusExpired=Expired statusUnknown=Unknown title=Contracts type=Type diff --git a/src/test/java/net/nikr/eve/jeveasset/data/raw/RawUtil.java b/src/test/java/net/nikr/eve/jeveasset/data/raw/RawUtil.java index ce8b65d3e..b33bc1e13 100644 --- a/src/test/java/net/nikr/eve/jeveasset/data/raw/RawUtil.java +++ b/src/test/java/net/nikr/eve/jeveasset/data/raw/RawUtil.java @@ -30,6 +30,7 @@ import java.util.Set; import net.nikr.eve.jeveasset.data.api.raw.RawAsset; import net.nikr.eve.jeveasset.data.api.raw.RawBlueprint; +import net.nikr.eve.jeveasset.data.api.raw.RawContract.ContractStatus; import net.nikr.eve.jeveasset.data.api.raw.RawContractItem; import net.nikr.eve.jeveasset.data.api.raw.RawIndustryJob; import net.nikr.eve.jeveasset.data.api.raw.RawIndustryJob.IndustryJobStatus; @@ -202,6 +203,9 @@ private static Set getNames(Enum[] ... values) { if (e.equals(IndustryJobStatus.ARCHIVED)) { //jEveAssets value continue; } + if (e.equals(ContractStatus.ARCHIVED)) { //jEveAssets value + continue; + } names.add(e.name()); } } diff --git a/src/test/java/net/nikr/eve/jeveasset/io/shared/ConverterTestUtil.java b/src/test/java/net/nikr/eve/jeveasset/io/shared/ConverterTestUtil.java index 536c6e3d2..b3c3c79cd 100644 --- a/src/test/java/net/nikr/eve/jeveasset/io/shared/ConverterTestUtil.java +++ b/src/test/java/net/nikr/eve/jeveasset/io/shared/ConverterTestUtil.java @@ -488,6 +488,9 @@ public static void testValues(Object object, ConverterTestOptions options, Class || options.getContractAvailabilityRaw() == RawContract.ContractAvailability.ALLIANCE)) { myContract.setAvailability(options.getContractAvailabilityRaw()); } + if (myContract.getStatus() != null) { + myContract.setStatus(options.getContractStatusRaw()); + } } if (object instanceof MyContractItem) { MyContractItem myContractItem = (MyContractItem) object; From 6d1cbc8aba7f85b9c42318bb11c6ad105ccb0a0c Mon Sep 17 00:00:00 2001 From: GoldenGnu Date: Sun, 27 Oct 2024 14:50:10 +0100 Subject: [PATCH 2/4] Bug Fix: Delivered industry jobs was included in assets and stockpiles (Issue #480) --- .../nikr/eve/jeveasset/data/api/my/MyIndustryJob.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/nikr/eve/jeveasset/data/api/my/MyIndustryJob.java b/src/main/java/net/nikr/eve/jeveasset/data/api/my/MyIndustryJob.java index c72dfa2eb..4cf9c3a45 100644 --- a/src/main/java/net/nikr/eve/jeveasset/data/api/my/MyIndustryJob.java +++ b/src/main/java/net/nikr/eve/jeveasset/data/api/my/MyIndustryJob.java @@ -288,18 +288,17 @@ public final boolean isDone() { } public final boolean isNotDeliveredToAssets() { - return getStatus() != IndustryJobStatus.ARCHIVED //if ARCHIVED -> unknown if delivered or not -> false + return !isDone() //if not done -> not delivered to assets -> true && (owner.getAssetLastUpdate() == null //if null -> never updated -> not delivered to assets -> true || getCompletedDate() == null //if null -> not completed -> not delivered to assets -> true - || owner.getAssetLastUpdate().before(getCompletedDate() //if assets last updated before completed date -> not delivered to assets -> true - )); + || owner.getAssetLastUpdate().before(getCompletedDate()) //if assets last updated before completed date -> not delivered to assets -> true + ); } public final boolean isRemovedFromAssets() { return owner.getAssetLastUpdate() != null //if null -> never updated -> not removed from assets -> false && getStartDate() != null //if null -> not started -> not removed from assets -> false - && owner.getAssetLastUpdate().after(getStartDate() //if assets last updated after started date -> removed from assets -> true - ); + && owner.getAssetLastUpdate().after(getStartDate()); //if assets last updated after started date -> removed from assets -> true } public final boolean isManufacturing() { From b21783f4682063caa7625aff015131a35abede43 Mon Sep 17 00:00:00 2001 From: GoldenGnu Date: Sun, 27 Oct 2024 15:00:20 +0100 Subject: [PATCH 3/4] Bug Fix: Contract/Industry jobs assets was not updated on user status change --- .../eve/jeveasset/gui/tabs/contracts/ContractsTab.java | 7 ++++++- .../nikr/eve/jeveasset/gui/tabs/jobs/IndustryJobsTab.java | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/main/java/net/nikr/eve/jeveasset/gui/tabs/contracts/ContractsTab.java b/src/main/java/net/nikr/eve/jeveasset/gui/tabs/contracts/ContractsTab.java index 0d494f9b4..4707460cc 100644 --- a/src/main/java/net/nikr/eve/jeveasset/gui/tabs/contracts/ContractsTab.java +++ b/src/main/java/net/nikr/eve/jeveasset/gui/tabs/contracts/ContractsTab.java @@ -287,8 +287,13 @@ public void actionPerformed(ActionEvent e) { if (contract == null || contract.isESI() || status == contract.getStatus()) { return; } + boolean before = contract.isOpen(); contract.setStatus(status); - tableModel.fireTableDataChanged(); + if (before != contract.isOpen()) { + program.updateEventListsWithProgress(); + } else { + tableModel.fireTableDataChanged(); + } program.saveProfile(); } }); diff --git a/src/main/java/net/nikr/eve/jeveasset/gui/tabs/jobs/IndustryJobsTab.java b/src/main/java/net/nikr/eve/jeveasset/gui/tabs/jobs/IndustryJobsTab.java index 66b5d670b..e32cc9b43 100644 --- a/src/main/java/net/nikr/eve/jeveasset/gui/tabs/jobs/IndustryJobsTab.java +++ b/src/main/java/net/nikr/eve/jeveasset/gui/tabs/jobs/IndustryJobsTab.java @@ -217,8 +217,13 @@ public void actionPerformed(ActionEvent e) { if (industryJob == null || industryJob.isESI() || industryJob.getStatus() == status) { return; } + boolean before = industryJob.isNotDeliveredToAssets(); industryJob.setStatus(status); - tableModel.fireTableDataChanged(); + if (before != industryJob.isNotDeliveredToAssets()) { + program.updateEventListsWithProgress(); + } else { + tableModel.fireTableDataChanged(); + } program.saveProfile(); } }); From d32274596ed9b4ca444dfe844b0b887d6a2fc33c Mon Sep 17 00:00:00 2001 From: GoldenGnu Date: Sun, 27 Oct 2024 15:06:39 +0100 Subject: [PATCH 4/4] Code: Fixed tests --- .../net/nikr/eve/jeveasset/io/shared/DataConverterTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/net/nikr/eve/jeveasset/io/shared/DataConverterTest.java b/src/test/java/net/nikr/eve/jeveasset/io/shared/DataConverterTest.java index f3c6ca6d0..40f89a490 100644 --- a/src/test/java/net/nikr/eve/jeveasset/io/shared/DataConverterTest.java +++ b/src/test/java/net/nikr/eve/jeveasset/io/shared/DataConverterTest.java @@ -70,7 +70,7 @@ public void testAssetIndustryJob() { industryJob.setStationID(options.getLocationTypeEveApi()); industryJob.setCompletedDate(new Date(date.getTime() + 1L)); List assets = DataConverter.assetIndustryJob(Collections.singletonList(industryJob), true, true); - if (options.getIndustryJobStatusRaw() == IndustryJobStatus.ARCHIVED) { + if (industryJob.isDone()) { assertTrue(assets.isEmpty()); continue; }