Skip to content

Commit

Permalink
Version 0.4.1. Code cleaning.
Browse files Browse the repository at this point in the history
  • Loading branch information
khituras committed Oct 5, 2020
1 parent f642dfe commit ca9f390
Show file tree
Hide file tree
Showing 54 changed files with 122 additions and 176 deletions.
4 changes: 2 additions & 2 deletions jcore-pipeline-builder-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<parent>
<groupId>de.julielab</groupId>
<artifactId>jcore-pipeline-modules</artifactId>
<version>0.4.1-SNAPSHOT</version>
<version>0.4.1</version>
</parent>

<build>
Expand Down Expand Up @@ -109,7 +109,7 @@
<dependency>
<groupId>de.julielab</groupId>
<artifactId>julielab-maven-aether-utilities</artifactId>
<version>1.1.1-SNAPSHOT</version>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class PipelineParameterChecker {
private PipelineParameterChecker() {
}

public static void main(String args[]) throws PipelineIOException, IOException {
public static void main(String[] args) throws PipelineIOException, IOException {
if (args.length != 1) {
System.out.println("Usage: " + PipelineParameterChecker.class.getSimpleName() + " <root directory of the JCoRe pipeline>");
System.exit(1);
Expand Down Expand Up @@ -89,8 +89,7 @@ public static List<MissingComponentConfiguration> findMissingResources(ResourceC
getConfigurationParameters();
// Map the values to their names so for each parameter declaration we can quickly check the value
Map<String, NameValuePair> settings = Stream.of(configurableDataResourceSpecifier.getMetaData().getConfigurationParameterSettings().getParameterSettings()).flatMap(Stream::of).collect(Collectors.toMap(NameValuePair::getName, Function.identity()));
for (int i = 0; i < declarations.length; i++) {
ConfigurationParameter declaration = declarations[i];
for (ConfigurationParameter declaration : declarations) {
String name = declaration.getName();
Object value = Optional.ofNullable(settings.get(name)).orElseGet(NameValuePair_impl::new).getValue();
if (declaration.isMandatory() && (value == null || StringUtils.isBlank(value.toString())))
Expand Down Expand Up @@ -158,7 +157,7 @@ else if (pipeline.getAaeDesc() != null) {
Stream<Description> aeStream = pipeline.getAeDelegates() != null ? pipeline.getAeDelegates().stream() : Stream.empty();
Stream<Description> ccStream = pipeline.getCcDelegates() != null ? pipeline.getCcDelegates().stream() : Stream.empty();
Stream<Description> aes = Stream.concat(Stream.concat(cmStream, aeStream), ccStream).filter(d -> d.getDescriptor() instanceof AnalysisEngineDescription);
Map<String, List<ExternalResourceDescription>> resourcesByName = aes.map(Description::getDescriptorAsAnalysisEngineDescription).filter(ae -> ae.getResourceManagerConfiguration() != null).filter(ae -> ae.getResourceManagerConfiguration().getExternalResources() != null).flatMap(ae -> Stream.of(ae.getResourceManagerConfiguration().getExternalResources())).collect(Collectors.groupingBy(er -> er.getName()));
Map<String, List<ExternalResourceDescription>> resourcesByName = aes.map(Description::getDescriptorAsAnalysisEngineDescription).filter(ae -> ae.getResourceManagerConfiguration() != null).filter(ae -> ae.getResourceManagerConfiguration().getExternalResources() != null).flatMap(ae -> Stream.of(ae.getResourceManagerConfiguration().getExternalResources())).collect(Collectors.groupingBy(ExternalResourceDescription::getName));
resourcesByName.entrySet().stream().filter(e -> e.getValue().size() > 1).forEach(e -> list.add(new MissingComponentConfiguration(Missing.DUPLICATE_EXTERNAL_RESOURCE_NAME, null, e.getKey()) ));
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import de.julielab.jcore.pipeline.builder.base.main.GitHubRepository;
import de.julielab.jcore.pipeline.builder.base.main.MetaDescription;
import de.julielab.xml.JulieXMLTools;
import java_cup.version;
import org.apache.http.client.utils.URIBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -27,7 +26,7 @@
public class GitHubConnector {

private static Map<String, MetaDescription> componentMap = null;
private static Logger log = LoggerFactory.getLogger(GitHubConnector.class);
private static final Logger log = LoggerFactory.getLogger(GitHubConnector.class);

/**
* Builds a URL of the form "https://raw.githubusercontent.com/JULIELab/{@code module}/{@code version}/{@code name}/component.meta
Expand Down Expand Up @@ -148,7 +147,7 @@ private static URLConnection connectWithHeader(URL url) throws IOException, Gith
connection.addRequestProperty("User-Agent", "JCoRe Pipeline Builder");
try {
Integer rateLimit = Integer.parseInt(connection.getHeaderField("X-RateLimit-Limit"));
Integer rateLimitRemaining = Integer.parseInt(connection.getHeaderField("X-RateLimit-Remaining"));
int rateLimitRemaining = Integer.parseInt(connection.getHeaderField("X-RateLimit-Remaining"));
log.debug("GitHub API requests rate limit: {} of {} remaining", rateLimitRemaining, rateLimit);
if (rateLimitRemaining == 0)
throw new GithubInformationException("Cannot request JCoRe component meta data from GitHub due to " +
Expand Down Expand Up @@ -243,9 +242,7 @@ public static InputStream getGitHubContentStream(GitHubRepository repository) th
URL meta = getRepoContentsURL(repository);
try {
return connectWithHeader(meta).getInputStream();
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) {
} catch (IOException | NullPointerException e) {
e.printStackTrace();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import org.apache.uima.resource.metadata.impl.Import_impl;

public class CPE {
private CpeDescription cpe;
private final CpeDescription cpe;

public CPE() {
cpe = new CpeDescriptionImpl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
import java.util.stream.Collectors;

public class ComponentMetaInformationService implements IComponentMetaInformationService, Serializable {
private static Logger logger = LoggerFactory.getLogger(ComponentMetaInformationService.class);
private static final Logger logger = LoggerFactory.getLogger(ComponentMetaInformationService.class);
private static ComponentMetaInformationService instance;
private String mvnLocal;
private Map<String, MetaDescription> metaInformation = new HashMap<>();
private Set<MavenArtifact> mavenDependencies = new HashSet<>();
private final String mvnLocal;
private final Map<String, MetaDescription> metaInformation = new HashMap<>();
private final Set<MavenArtifact> mavenDependencies = new HashSet<>();

private ComponentMetaInformationService() {
this.mvnLocal = Paths.get(System.getProperty("user.home"), Maven.LOCAL_REPO).toString();
Expand All @@ -57,13 +57,13 @@ public void loadMetaInformationFromDisk(ComponentRepository repository) throws G
String eMessage = null;
InputStream infile = null;
File metaFile = Repositories.getMetaFile(repository);
logger.trace("Loading component meta description file {} for module {}:{}", metaFile, repository);
logger.trace("Loading component meta description file {} for module {}:{}", metaFile, repository.getName(), repository.getVersion());
System.out.println(metaFile.getAbsolutePath());
try {
infile = FileUtilities.getInputStreamFromFile(metaFile);
ObjectMapper objectMapper = new ObjectMapper();
List<MetaDescription> asList = objectMapper.readValue(
infile, new TypeReference<List<MetaDescription>>() {
infile, new TypeReference<>() {
});
// asList.stream().map(MetaDescription::getName).forEach(md -> {System.out.println(repository.getName() + ": " +md);});
asList.forEach(md -> this.metaInformation.put(md.getName(), md));
Expand Down Expand Up @@ -113,8 +113,8 @@ public void loadComponentMetaInformation(Boolean loadNew, ComponentRepository re
public void loadComponentMetaInformation(Boolean loadNew) throws GithubInformationException {
metaInformation.clear();
final List<ComponentRepository> gitHubRepositories = getRepositories();
for (Integer i = 0; i < gitHubRepositories.size(); i++) {
loadComponentMetaInformation(loadNew, gitHubRepositories.get(i));
for (ComponentRepository gitHubRepository : gitHubRepositories) {
loadComponentMetaInformation(loadNew, gitHubRepository);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.PROPERTY,
property = "type")
@JsonSubTypes({
@JsonSubTypes.Type(value = GitHubRepository.class, name = "GitHubRepository"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class Description implements Serializable, Cloneable {
* incompatible with older version.
*/
private static final long serialVersionUID = 2019_01_21_001L;
private static Logger logger = LoggerFactory.getLogger(Description.class);
private static final Logger logger = LoggerFactory.getLogger(Description.class);
/**
* The URI of the original UIMA descriptor within a JAR.
*/
Expand All @@ -62,7 +62,7 @@ public class Description implements Serializable, Cloneable {
* The descriptor category as read from the actual descriptor.
*/
private String descriptorType;
private Map<String, ArrayList<String>> capabilities = new HashMap<String, ArrayList<String>>() {{
private final Map<String, ArrayList<String>> capabilities = new HashMap<>() {{
put(Descriptor.CAPABILITIES_IN, new ArrayList<>());
put(Descriptor.CAPABILITIES_OUT, new ArrayList<>());
}};
Expand Down
Loading

0 comments on commit ca9f390

Please sign in to comment.