private void checkConfiguration(final Object[] keyValueConfiguration) throws BaleenException { if (keyValueConfiguration == null) { return; } if (keyValueConfiguration.length % 2 == 1) { throw new BaleenException( "Format is key,value,key,value must be an even number of entries in the array"); } }
@SuppressWarnings("unchecked") private Object addNodeToModel(OntModel model, Vertex v) { try { String label = v.label(); if (EVENT.equals(label)) { return addIndividual(model, v, EVENT); } if (ENTITY.equals(label)) { Iterator<VertexProperty<Object>> properties = v.properties("type"); List<?> types = Lists.newArrayList(properties) .stream() .filter(VertexProperty::isPresent) .map(VertexProperty::value) .collect(Collectors.toList()); Optional<String> aggregate = mode.aggregate((List<String>) types); if (aggregate.isPresent()) { return addIndividual(model, v, aggregate.get()); } getMonitor().warn("Not type information for {} using entity", v); return addIndividual(model, v, ENTITY); } getMonitor().warn("Unrecognized Label {}", label); } catch (BaleenException e) { getMonitor().warn("Error adding node {} - {} ", v, e.getMessage()); } return null; }
@SuppressWarnings("unchecked") private Object addNodeToModel(OntModel model, Vertex v) { try { String label = v.label(); if (EVENT.equals(label)) { return addIndividual(model, v, EVENT); } if (ENTITY.equals(label)) { Iterator<VertexProperty<Object>> properties = v.properties("type"); List<?> types = Lists.newArrayList(properties) .stream() .filter(VertexProperty::isPresent) .map(VertexProperty::value) .collect(Collectors.toList()); Optional<String> aggregate = mode.aggregate((List<String>) types); if (aggregate.isPresent()) { return addIndividual(model, v, aggregate.get()); } getMonitor().warn("Not type information for {} using entity", v); return addIndividual(model, v, ENTITY); } getMonitor().warn("Unrecognized Label {}", label); } catch (BaleenException e) { getMonitor().warn("Error adding node {} - {} ", v, e.getMessage()); } return null; }
private void checkConfiguration(final Object[] keyValueConfiguration) throws BaleenException { if (keyValueConfiguration == null) { return; } if (keyValueConfiguration.length % 2 == 1) { throw new BaleenException( "Format is key,value,key,value must be an even number of entries in the array"); } }
@Override public void start() throws BaleenException { if (server != null) { LOGGER.debug("Starting server"); try { server.start(); } catch (Exception e) { throw new BaleenException("Unable to start server", e); } LOGGER.info("Server started"); } else { throw new BaleenException("Server has not yet been configured"); } }
@Override public void start() throws BaleenException { if (server != null) { LOGGER.debug("Starting server"); try { server.start(); } catch (Exception e) { throw new BaleenException("Unable to start server", e); } LOGGER.info("Server started"); } else { throw new BaleenException("Server has not yet been configured"); } }
private Class<? extends Base> getTextClass() throws ResourceInitializationException { if (extractedFrom.equals(SENTENCES)) { return Sentence.class; } else if (extractedFrom.equals(PARAGRAPHS)) { return Paragraph.class; } throw new ResourceInitializationException( new BaleenException( "Invalid " + PARAM_TEXT_BLOCK_EXTRACTED_FROM + " parameter. Should be " + "either " + SENTENCES + " (default) or " + PARAGRAPHS)); }
@Override public Optional<String> aggregate(List<?> values) throws BaleenException { if (CollectionUtils.isEmpty(values)) { return Optional.empty(); } try { return Optional.of(mapper.writeValueAsString(values)); } catch (JsonProcessingException e) { throw new BaleenException(e); } } }
@Override public void stop() throws BaleenException { try { if (server != null) { server.stop(); } constraints.clear(); constraintMappings.clear(); LOGGER.info("Server stopped"); } catch (Exception e) { throw new BaleenException("Unable to stop server", e); } }
@Override public Optional<String> aggregate(List<?> values) throws BaleenException { if (CollectionUtils.isEmpty(values)) { return Optional.empty(); } try { return Optional.of(mapper.writeValueAsString(values)); } catch (JsonProcessingException e) { throw new BaleenException(e); } } }
@Override public void doInitialize(final UimaContext aContext) throws ResourceInitializationException { if (Strings.isNullOrEmpty(outputFolderString)) { outputFolderString = System.getProperty("user.dir"); } outputFolder = new File(outputFolderString); if (!outputFolder.exists()) { final Boolean ret = outputFolder.mkdirs(); if (!ret) { throw new ResourceInitializationException( new BaleenException("Unable to create output folder")); } } if (!outputFolder.isDirectory() || !outputFolder.canWrite()) { throw new ResourceInitializationException(new BaleenException("Unable to write to folder")); } }
@Override public void stop() throws BaleenException { try { if (server != null) { server.stop(); } constraints.clear(); constraintMappings.clear(); LOGGER.info("Server stopped"); } catch (Exception e) { throw new BaleenException("Unable to stop server", e); } }
@Override public void close() throws BaleenException { if (mongoFactory != null) { try { mongoFactory.close(); } catch (Exception e) { throw new BaleenException(e); } } } }
/** * Get a Map of String key/values from a varied number of String arguments * * @return Map of Strings of key value pairs * @throws BaleenException if an odd number of arguments are provided */ public Map<String, String> createStringsMap() throws BaleenException { if (argumentPairs.length % 2 != 0) { LOGGER.error("String arguments must be key value pairs"); throw new BaleenException("Invalid number of arguments. Arguments must be key value pairs"); } Map<String, String> map = new HashMap<>(); for (int i = 0; i < argumentPairs.length - 1; i += 2) { map.put(argumentPairs[i], argumentPairs[i + 1]); } return map; } }
/** * Get a Map of String key/values from a varied number of String arguments * * @return Map of Strings of key value pairs * @throws BaleenException if an odd number of arguments are provided */ public Map<String, String> createStringsMap() throws BaleenException { if (argumentPairs.length % 2 != 0) { LOGGER.error("String arguments must be key value pairs"); throw new BaleenException("Invalid number of arguments. Arguments must be key value pairs"); } Map<String, String> map = new HashMap<>(); for (int i = 0; i < argumentPairs.length - 1; i += 2) { map.put(argumentPairs[i], argumentPairs[i + 1]); } return map; } }
/** * Get the class of a specified type, that extends from the Entity base class * * @param typeName The name of the type, optionally including the package * @param jCas A JCas object containing the type system * @return The class associated with that type, which will extend from Entity * @throws BaleenException is thrown if a suitable class can't be found */ @SuppressWarnings("unchecked") public static Class<? extends Entity> getEntityClass(String typeName, JCas jCas) throws BaleenException { Class<? extends AnnotationBase> at = getType(typeName, jCas); if (at == null) { throw new BaleenException("Couldn't find type '" + typeName + "'"); } if (!Entity.class.isAssignableFrom(at)) { throw new BaleenException("Entity type '" + typeName + "' does not inherit from Entity"); } return (Class<? extends Entity>) at; }
@Override protected void createQueue() throws BaleenException { try { consumer = mqResource.createConsumer(topic, null); } catch (final JMSException e) { throw new BaleenException(e); } }
@Override protected void createQueue() throws BaleenException { try { supplier = mqResource.createSupplier(exchangeName, routingKey, topic); } catch (final IOException e) { throw new BaleenException(e); } }
@Override protected void createQueue() throws BaleenException { try { consumer = mqResource.createConsumer(exchangeName, routingKey, topic); } catch (final IOException e) { throw new BaleenException(e); } }
@Override protected void createQueue() throws BaleenException { try { consumer = mqResource.createConsumer(exchangeName, routingKey, topic); } catch (final IOException e) { throw new BaleenException(e); } }