Skip to content

Commit 60ed54d

Browse files
committed
added groundwork for update-checking use case (tentative)
1 parent fbdd13b commit 60ed54d

File tree

3 files changed

+50
-5
lines changed

3 files changed

+50
-5
lines changed

src/main/java/org/hydev/mcpm/client/commands/entries/ListController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public ListController(ListAllBoundary listAllBoundary, CheckForUpdatesBoundary c
3535
* @param log Logger
3636
*/
3737
public void listAll(String parameter, Consumer<String> log) {
38-
var list = listAllBoundary.listAll(parameter);
38+
var list = listAllBoundary.listAll(parameter, checkForUpdatesBoundary);
3939

4040
// Tabulate result
4141
var table = tabulate(list.stream().map(p -> List.of("&a" + p.name(), "&e"

src/main/java/org/hydev/mcpm/client/database/ListAllBoundary.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.hydev.mcpm.client.database;
22

3+
import org.hydev.mcpm.client.database.boundary.CheckForUpdatesBoundary;
34
import org.hydev.mcpm.client.models.PluginYml;
45

56
import java.util.List;
@@ -24,5 +25,5 @@ public interface ListAllBoundary {
2425
* a request to list all manually installed plugins that are
2526
* outdated.
2627
*/
27-
List<PluginYml> listAll(String parameter);
28+
List<PluginYml> listAll(String parameter, CheckForUpdatesBoundary checkForUpdatesBoundary);
2829
}

src/main/java/org/hydev/mcpm/client/database/ListAllInteractor.java

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
import org.apache.commons.lang3.NotImplementedException;
44
import org.hydev.mcpm.client.database.boundary.CheckForUpdatesBoundary;
55
import org.hydev.mcpm.client.database.inputs.CheckForUpdatesInput;
6+
import org.hydev.mcpm.client.database.inputs.CheckForUpdatesResult;
67
import org.hydev.mcpm.client.database.model.PluginVersionState;
78
import org.hydev.mcpm.client.models.PluginYml;
89
import org.hydev.mcpm.client.models.PluginTrackerModel;
10+
import org.hydev.mcpm.client.database.model.PluginVersionId;
11+
import org.hydev.mcpm.client.database.model.PluginModelId;
12+
import org.hydev.mcpm.client.models.PluginModel;
913

1014
import java.util.List;
1115
import java.util.ArrayList;
16+
import java.util.Collection;
17+
import java.util.OptionalLong;
1218

1319
/**
1420
* Implementation to the ListAll functionality
@@ -42,9 +48,47 @@ public List<PluginYml> listAll(String parameter, CheckForUpdatesBoundary checkFo
4248
return installed.stream().filter(it -> local.contains(it.name())).toList();
4349

4450
case "outdated":
45-
CheckForUpdatesInput input = new CheckForUpdatesInput(null, false);
46-
47-
ArrayList<PluginTrackerModel> installedAsModels = localPluginTracker.listInstalledAsModels();
51+
/*
52+
* ArrayList<PluginVersionState> temp = new ArrayList<>();
53+
* ArrayList<PluginTrackerModel> installedModels =
54+
* localPluginTracker.listInstalledAsModels();
55+
*
56+
* for (PluginTrackerModel installedModel : installedModels) {
57+
* PluginVersionId pluginVersionId = new PluginVersionId(
58+
* OptionalLong.of(Long.parseLong(installedModel.getVersionId())), null);
59+
*
60+
* PluginModelId pluginModelId = new PluginModelId(
61+
* OptionalLong.of(Long.parseLong(installedModel.getPluginId())),
62+
* installedModel.getName(),
63+
* null);
64+
*
65+
* temp.add(new PluginVersionState(pluginModelId, pluginVersionId));
66+
* }
67+
*
68+
* CheckForUpdatesInput input = new CheckForUpdatesInput(temp, false);
69+
*
70+
* // Read the list of installedModels and create a CheckForUpdatesInput object
71+
* // with state equal
72+
* // to the list of PluginTrackerModels's version
73+
*
74+
* CheckForUpdatesResult rawResult = checkForUpdatesBoundary.updates(input);
75+
*
76+
* if (rawResult.state() == CheckForUpdatesResult.State.SUCCESS) {
77+
* Collection<PluginModel> result = rawResult.updatable().values();
78+
*
79+
* // get the ids of the plugins that are outdated from result
80+
* ArrayList<String> outdated = new ArrayList<>();
81+
* for (PluginModel pluginModel : result) {
82+
* outdated.add(pluginModel.id() + "");
83+
* }
84+
*
85+
* // filter the installed plugins by the outdated ids
86+
*
87+
* }
88+
* // Need to associate the IDs of the outdated plugins with the installed
89+
* plugin YML files, and return all matches
90+
*/
91+
throw new NotImplementedException("Not implemented yet");
4892

4993
default:
5094
return null;

0 commit comments

Comments
 (0)