1
- package org .hydev .mcpm .client .database ;
1
+ package org .hydev .mcpm .client .list ;
2
2
3
- import org .apache .commons .lang3 .NotImplementedException ;
4
- import org .hydev .mcpm .client .database .boundary .CheckForUpdatesBoundary ;
5
- import org .hydev .mcpm .client .database .inputs .CheckForUpdatesInput ;
6
- import org .hydev .mcpm .client .database .inputs .CheckForUpdatesResult ;
7
- import org .hydev .mcpm .client .database .model .PluginVersionState ;
8
3
import org .hydev .mcpm .client .models .PluginYml ;
9
4
import org .hydev .mcpm .client .updater .CheckForUpdatesBoundary ;
5
+ import org .hydev .mcpm .client .database .tracker .SuperPluginTracker ;
10
6
11
7
import java .util .List ;
12
- import java .util .ArrayList ;
13
- import java .util .Collection ;
14
- import java .util .OptionalLong ;
15
8
16
9
/**
17
10
* Implementation to the ListAll functionality
18
11
*
19
12
* @author Kevin (https://github.com/kchprog)
20
13
* @since 2022-11-20
21
14
*/
22
- public record ListAllInteractor (PluginTracker tracker ) implements ListAllBoundary {
15
+ public record ListAllInteractor (SuperPluginTracker pluginTracker ) implements ListAllBoundary {
23
16
/**
24
17
* listAllInteractor interacts with the LocalPluginTracker to get the list of
25
18
* plugins, according to a specified
@@ -33,57 +26,23 @@ public record ListAllInteractor(PluginTracker tracker) implements ListAllBoundar
33
26
* outdated.
34
27
*/
35
28
public List <PluginYml > listAll (String parameter , CheckForUpdatesBoundary checkForUpdatesBoundary ) {
36
- var installed = tracker .listInstalled ();
29
+ var installed = pluginTracker .listInstalled ();
37
30
switch (parameter ) {
38
31
case "all" :
39
32
return installed ;
40
33
41
34
case "manual" :
42
- var local = localPluginTracker .listManuallyInstalled ();
35
+ var local = pluginTracker .listManuallyInstalled ();
43
36
return installed .stream ().filter (it -> local .contains (it .name ())).toList ();
44
37
38
+ case "automatic" :
39
+ var manual = pluginTracker .listManuallyInstalled ();
40
+ return installed .stream ().filter (it -> !manual .contains (it .name ())).toList ();
41
+
45
42
case "outdated" :
46
- /*
47
- * ArrayList<PluginVersionState> temp = new ArrayList<>();
48
- * ArrayList<PluginTrackerModel> installedModels =
49
- * localPluginTracker.listInstalledAsModels();
50
- *
51
- * for (PluginTrackerModel installedModel : installedModels) {
52
- * PluginVersionId pluginVersionId = new PluginVersionId(
53
- * OptionalLong.of(Long.parseLong(installedModel.getVersionId())), null);
54
- *
55
- * PluginModelId pluginModelId = new PluginModelId(
56
- * OptionalLong.of(Long.parseLong(installedModel.getPluginId())),
57
- * installedModel.getName(),
58
- * null);
59
- *
60
- * temp.add(new PluginVersionState(pluginModelId, pluginVersionId));
61
- * }
62
- *
63
- * CheckForUpdatesInput input = new CheckForUpdatesInput(temp, false);
64
- *
65
- * // Read the list of installedModels and create a CheckForUpdatesInput object
66
- * // with state equal
67
- * // to the list of PluginTrackerModels's version
68
- *
69
- * CheckForUpdatesResult rawResult = checkForUpdatesBoundary.updates(input);
70
- *
71
- * if (rawResult.state() == CheckForUpdatesResult.State.SUCCESS) {
72
- * Collection<PluginModel> result = rawResult.updatable().values();
73
- *
74
- * // get the ids of the plugins that are outdated from result
75
- * ArrayList<String> outdated = new ArrayList<>();
76
- * for (PluginModel pluginModel : result) {
77
- * outdated.add(pluginModel.id() + "");
78
- * }
79
- *
80
- * // filter the installed plugins by the outdated ids
81
- *
82
- * }
83
- * // Need to associate the IDs of the outdated plugins with the installed
84
- * plugin YML files, and return all matches
85
- */
86
- throw new NotImplementedException ("Not implemented yet" );
43
+ ListUpdateableBoundary listUpdateableBoundary = new ListUpdateableHelper ();
44
+ var outdated = listUpdateableBoundary .listUpdateable (pluginTracker , checkForUpdatesBoundary );
45
+ return installed .stream ().filter (it -> outdated .contains (it .name ())).toList ();
87
46
88
47
default :
89
48
return null ;
0 commit comments