Skip to content

Commit

Permalink
Merge branch 'main' into native
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldenGnu committed Oct 27, 2024
2 parents 08e5e3b + d322745 commit f1db5b3
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 30 deletions.
31 changes: 12 additions & 19 deletions src/main/java/net/nikr/eve/jeveasset/data/api/my/MyContract.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
Expand All @@ -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();
}
Expand All @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ public enum ContractStatus {
REJECTED("rejected"),
FAILED("failed"),
DELETED("deleted"),
REVERSED("reversed");
REVERSED("reversed"),
ARCHIVED("archived");

private final String value;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -352,10 +353,14 @@ private void parseContracts(final Element element, final OwnerType owner) throws
Map<MyContract, List<MyContractItem>> 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<MyContractItem> contractItems = new ArrayList<>();
for (int c = 0; c < itemNodes.getLength(); c++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ private void writeActiveShip(Document xmldoc, Element parentNode, MyShip activeS

private void writeContractItems(Document xmldoc, Element parentNode, Map<MyContract, List<MyContractItem>> contractItems) {
Element contractsNode = xmldoc.createElement("contracts");
setAttribute(contractsNode, "archived", true);
parentNode.appendChild(contractsNode);
for (Map.Entry<MyContract, List<MyContractItem>> entry : contractItems.entrySet()) {
MyContract contract = entry.getKey();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -77,7 +78,6 @@ statusInProgress=In Progress
statusOutstanding=Outstanding
statusRejected=Rejected
statusReversed=Reversed
statusExpired=Expired
statusUnknown=Unknown
title=Contracts
type=Type
Expand Down
4 changes: 4 additions & 0 deletions src/test/java/net/nikr/eve/jeveasset/data/raw/RawUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -202,6 +203,9 @@ private static Set<String> getNames(Enum<?>[] ... values) {
if (e.equals(IndustryJobStatus.ARCHIVED)) { //jEveAssets value
continue;
}
if (e.equals(ContractStatus.ARCHIVED)) { //jEveAssets value
continue;
}
names.add(e.name());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void testAssetIndustryJob() {
industryJob.setStationID(options.getLocationTypeEveApi());
industryJob.setCompletedDate(new Date(date.getTime() + 1L));
List<MyAsset> assets = DataConverter.assetIndustryJob(Collections.singletonList(industryJob), true, true);
if (options.getIndustryJobStatusRaw() == IndustryJobStatus.ARCHIVED) {
if (industryJob.isDone()) {
assertTrue(assets.isEmpty());
continue;
}
Expand Down

0 comments on commit f1db5b3

Please sign in to comment.