Skip to content

Commit

Permalink
Fixed a bug where the componentList.json files would contain all comp…
Browse files Browse the repository at this point in the history
…onents currently loaded.

And not just the components in the respective repository.
  • Loading branch information
khituras committed Jul 11, 2019
1 parent d8847e2 commit c5611f2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public interface IComponentMetaInformationService {

Set<MavenArtifact> getArtifacts() throws GithubInformationException;

Collection<MetaDescription> getMetaInformation(ComponentRepository repository) throws GithubInformationException;

/**
* Lists all exposed components of the module this ComponentMetaInformation object belongs to/
* was created from.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,14 @@ public void loadMetaInformationFromDisk(ComponentRepository repository) throws G
InputStream infile = null;
File metaFile = Repositories.getMetaFile(repository);
logger.trace("Loading component meta description file {} for module {}:{}", metaFile, repository);
System.out.println(metaFile.getAbsolutePath());
try {
infile = FileUtilities.getInputStreamFromFile(metaFile);
ObjectMapper objectMapper = new ObjectMapper();
List<MetaDescription> asList = objectMapper.readValue(
infile, new TypeReference<List<MetaDescription>>() {
});
// asList.stream().map(MetaDescription::getName).forEach(md -> {System.out.println(repository.getName() + ": " +md);});
asList.forEach(md -> this.metaInformation.put(md.getName(), md));
asList.forEach(md -> md.setModule(repository));
if (logger.isTraceEnabled()) {
Expand Down Expand Up @@ -157,6 +159,11 @@ public Set<MavenArtifact> getArtifacts() throws GithubInformationException {
return this.mavenDependencies;
}

@Override
public Collection<MetaDescription> getMetaInformation(ComponentRepository repository) throws GithubInformationException {
return metaInformation.values().stream().filter(md -> md.getModule().getName().equals(repository.getName())).collect(Collectors.toList());
}

@Override
public Collection<MetaDescription> getMetaInformation() throws GithubInformationException {
return this.getMetaInformation(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public static void saveMetaInformationToDisk(ComponentRepository repository) thr
mapper.addMixIn(Description.class, DescriptionRepositoryStorageMixin.class);
// enable pretty printing
mapper.enable(SerializationFeature.INDENT_OUTPUT);
mapper.writeValue(FileUtilities.getWriterToFile(metaFile), ComponentMetaInformationService.getInstance().getMetaInformation());
mapper.writeValue(FileUtilities.getWriterToFile(metaFile), ComponentMetaInformationService.getInstance().getMetaInformation(repository));
} catch (IOException e) {
throw new GithubInformationException(e);
}
Expand Down

0 comments on commit c5611f2

Please sign in to comment.