|
3 | 3 | import org.apache.commons.lang3.NotImplementedException;
|
4 | 4 | import org.hydev.mcpm.client.database.boundary.CheckForUpdatesBoundary;
|
5 | 5 | import org.hydev.mcpm.client.database.inputs.CheckForUpdatesInput;
|
| 6 | +import org.hydev.mcpm.client.database.inputs.CheckForUpdatesResult; |
6 | 7 | import org.hydev.mcpm.client.database.model.PluginVersionState;
|
7 | 8 | import org.hydev.mcpm.client.models.PluginYml;
|
8 | 9 | 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; |
9 | 13 |
|
10 | 14 | import java.util.List;
|
11 | 15 | import java.util.ArrayList;
|
| 16 | +import java.util.Collection; |
| 17 | +import java.util.OptionalLong; |
12 | 18 |
|
13 | 19 | /**
|
14 | 20 | * Implementation to the ListAll functionality
|
@@ -42,9 +48,47 @@ public List<PluginYml> listAll(String parameter, CheckForUpdatesBoundary checkFo
|
42 | 48 | return installed.stream().filter(it -> local.contains(it.name())).toList();
|
43 | 49 |
|
44 | 50 | 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"); |
48 | 92 |
|
49 | 93 | default:
|
50 | 94 | return null;
|
|
0 commit comments