repo_name
stringlengths 7
104
| file_path
stringlengths 13
198
| context
stringlengths 67
7.15k
| import_statement
stringlengths 16
4.43k
| code
stringlengths 40
6.98k
| prompt
stringlengths 227
8.27k
| next_line
stringlengths 8
795
|
---|---|---|---|---|---|---|
nowucca/SimpleAffableBean
|
src/main/java/business/customer/CustomerDaoJdbc.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
|
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static business.JdbcUtils.getConnection;
|
private static final String FIND_ALL_SQL =
"SELECT " +
"c.customer_id, c.name, c.email, " +
"c.phone, c.address, c.city_region, c.cc_number " +
"FROM " +
"customer c";
private static final String FIND_BY_CUSTOMER_ID_SQL =
"SELECT " +
"c.customer_id, c.name, c.email, " +
"c.phone, c.address, c.city_region, c.cc_number " +
"FROM " +
"customer c " +
"WHERE " +
"c.customer_id = ?";
@Override
public long create(final Connection connection, CustomerForm customerForm) {
try (PreparedStatement statement =
connection.prepareStatement(CREATE_CUSTOMER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, customerForm.getName());
statement.setString(2, customerForm.getEmail());
statement.setString(3, customerForm.getPhone());
statement.setString(4, customerForm.getAddress());
statement.setString(5, customerForm.getCityRegion());
statement.setString(6, customerForm.getCcNumber());
int affected = statement.executeUpdate();
if (affected != 1) {
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
// Path: src/main/java/business/customer/CustomerDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static business.JdbcUtils.getConnection;
private static final String FIND_ALL_SQL =
"SELECT " +
"c.customer_id, c.name, c.email, " +
"c.phone, c.address, c.city_region, c.cc_number " +
"FROM " +
"customer c";
private static final String FIND_BY_CUSTOMER_ID_SQL =
"SELECT " +
"c.customer_id, c.name, c.email, " +
"c.phone, c.address, c.city_region, c.cc_number " +
"FROM " +
"customer c " +
"WHERE " +
"c.customer_id = ?";
@Override
public long create(final Connection connection, CustomerForm customerForm) {
try (PreparedStatement statement =
connection.prepareStatement(CREATE_CUSTOMER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, customerForm.getName());
statement.setString(2, customerForm.getEmail());
statement.setString(3, customerForm.getPhone());
statement.setString(4, customerForm.getAddress());
statement.setString(5, customerForm.getCityRegion());
statement.setString(6, customerForm.getCcNumber());
int affected = statement.executeUpdate();
if (affected != 1) {
|
throw new SimpleAffableUpdateDbException("Failed to insert a customer, affected row count = "
|
nowucca/SimpleAffableBean
|
src/main/java/business/customer/CustomerDaoJdbc.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
|
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static business.JdbcUtils.getConnection;
|
private static final String FIND_BY_CUSTOMER_ID_SQL =
"SELECT " +
"c.customer_id, c.name, c.email, " +
"c.phone, c.address, c.city_region, c.cc_number " +
"FROM " +
"customer c " +
"WHERE " +
"c.customer_id = ?";
@Override
public long create(final Connection connection, CustomerForm customerForm) {
try (PreparedStatement statement =
connection.prepareStatement(CREATE_CUSTOMER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, customerForm.getName());
statement.setString(2, customerForm.getEmail());
statement.setString(3, customerForm.getPhone());
statement.setString(4, customerForm.getAddress());
statement.setString(5, customerForm.getCityRegion());
statement.setString(6, customerForm.getCcNumber());
int affected = statement.executeUpdate();
if (affected != 1) {
throw new SimpleAffableUpdateDbException("Failed to insert a customer, affected row count = "
+ affected);
}
long customerId;
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
customerId = rs.getLong(1);
} else {
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
// Path: src/main/java/business/customer/CustomerDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static business.JdbcUtils.getConnection;
private static final String FIND_BY_CUSTOMER_ID_SQL =
"SELECT " +
"c.customer_id, c.name, c.email, " +
"c.phone, c.address, c.city_region, c.cc_number " +
"FROM " +
"customer c " +
"WHERE " +
"c.customer_id = ?";
@Override
public long create(final Connection connection, CustomerForm customerForm) {
try (PreparedStatement statement =
connection.prepareStatement(CREATE_CUSTOMER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, customerForm.getName());
statement.setString(2, customerForm.getEmail());
statement.setString(3, customerForm.getPhone());
statement.setString(4, customerForm.getAddress());
statement.setString(5, customerForm.getCityRegion());
statement.setString(6, customerForm.getCcNumber());
int affected = statement.executeUpdate();
if (affected != 1) {
throw new SimpleAffableUpdateDbException("Failed to insert a customer, affected row count = "
+ affected);
}
long customerId;
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
customerId = rs.getLong(1);
} else {
|
throw new SimpleAffableQueryDbException("Failed to retrieve customerId auto-generated key");
|
nowucca/SimpleAffableBean
|
src/main/java/business/customer/CustomerDaoJdbc.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
|
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static business.JdbcUtils.getConnection;
|
try (PreparedStatement statement =
connection.prepareStatement(CREATE_CUSTOMER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, customerForm.getName());
statement.setString(2, customerForm.getEmail());
statement.setString(3, customerForm.getPhone());
statement.setString(4, customerForm.getAddress());
statement.setString(5, customerForm.getCityRegion());
statement.setString(6, customerForm.getCcNumber());
int affected = statement.executeUpdate();
if (affected != 1) {
throw new SimpleAffableUpdateDbException("Failed to insert a customer, affected row count = "
+ affected);
}
long customerId;
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
customerId = rs.getLong(1);
} else {
throw new SimpleAffableQueryDbException("Failed to retrieve customerId auto-generated key");
}
return customerId;
} catch (SQLException e) {
throw new SimpleAffableUpdateDbException("Encountered problem creating a new customer ", e);
}
}
@Override
public Customer findByCustomerId(long customerId) {
Customer result = null;
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
// Path: src/main/java/business/customer/CustomerDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static business.JdbcUtils.getConnection;
try (PreparedStatement statement =
connection.prepareStatement(CREATE_CUSTOMER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setString(1, customerForm.getName());
statement.setString(2, customerForm.getEmail());
statement.setString(3, customerForm.getPhone());
statement.setString(4, customerForm.getAddress());
statement.setString(5, customerForm.getCityRegion());
statement.setString(6, customerForm.getCcNumber());
int affected = statement.executeUpdate();
if (affected != 1) {
throw new SimpleAffableUpdateDbException("Failed to insert a customer, affected row count = "
+ affected);
}
long customerId;
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
customerId = rs.getLong(1);
} else {
throw new SimpleAffableQueryDbException("Failed to retrieve customerId auto-generated key");
}
return customerId;
} catch (SQLException e) {
throw new SimpleAffableUpdateDbException("Encountered problem creating a new customer ", e);
}
}
@Override
public Customer findByCustomerId(long customerId) {
Customer result = null;
|
try (Connection connection = getConnection();
|
nowucca/SimpleAffableBean
|
src/main/java/controller/SimpleAffableBeanContextListener.java
|
// Path: src/main/java/business/ApplicationContext.java
// public final class ApplicationContext {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
//
// private ProductService productService;
//
// private CategoryService categoryService;
//
// private CustomerService customerService;
//
// private CustomerOrderService customerOrderService;
//
// private ScheduledExecutorService executorService;
//
// public static ApplicationContext INSTANCE = new ApplicationContext();
//
// private ApplicationContext() {
//
// executorService = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors());
//
// // wire up the business.dao layer "by hand"
// ProductDao productDao = new ProductDaoJdbc();
//
// ProductDaoGuava cachedProductDao = new ProductDaoGuava(productDao);
//
// productService = new DefaultProductService();
// ((DefaultProductService) productService).setProductDao(cachedProductDao);
//
// CategoryDao categoryDao = new CategoryDaoJdbc();
//
// CategoryDaoGuava cachedCategoryDao = new CategoryDaoGuava(categoryDao);
//
// categoryService = new DefaultCategoryService();
// ((DefaultCategoryService) categoryService).setCategoryDao(cachedCategoryDao);
//
// CustomerDao customerDao = new CustomerDaoJdbc();
// customerService = new DefaultCustomerService();
// ((DefaultCustomerService) customerService).setCustomerDao(customerDao);
//
// CustomerOrderLineItemDao customerOrderLineItemDao = new CustomerOrderLineItemDaoJdbc();
// CustomerOrderDao customerOrderDao = new CustomerOrderDaoJdbc();
//
// customerOrderService = new DefaultCustomerOrderService();
// DefaultCustomerOrderService service = (DefaultCustomerOrderService) customerOrderService;
// service.setProductDao(cachedProductDao);
// service.setCustomerService(customerService);
// service.setCustomerOrderDao(customerOrderDao);
// service.setCustomerOrderLineItemDao(customerOrderLineItemDao);
//
// executorService.scheduleWithFixedDelay(() -> {
// try {
// logger.info("Refreshing category and product caches....commencing");
// cachedCategoryDao.bulkload();
// cachedProductDao.clear();
// logger.info("Refreshing category and product caches....complete!");
// } catch (Throwable t) {
// logger.error("Encountered trouble refreshing category and product caches.", t);
// }
// }, 10, 60, TimeUnit.MINUTES);
// }
//
//
//
// public ProductService getProductService() {
// return productService;
// }
//
// public CategoryService getCategoryService() {
// return categoryService;
// }
//
// public CustomerService getCustomerService() {
// return customerService;
// }
//
// public CustomerOrderService getCustomerOrderService() {
// return customerOrderService;
// }
//
// public void shutdown() {
// executorService.shutdown();
// }
// }
|
import business.ApplicationContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller; /**
*/
public class SimpleAffableBeanContextListener implements ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {
private Logger logger = LoggerFactory.getLogger(getClass());
// Public constructor is required by servlet spec
public SimpleAffableBeanContextListener() {
}
// -------------------------------------------------------
// ServletContextListener implementation
// -------------------------------------------------------
public void contextInitialized(ServletContextEvent sce) {
/* This method is called when the servlet context is
initialized(when the Web application is deployed).
You can initialize servlet context related data here.
*/
logger.info("Servlet context initializing.");
// initialize servlet with configuration information
|
// Path: src/main/java/business/ApplicationContext.java
// public final class ApplicationContext {
//
// private final Logger logger = LoggerFactory.getLogger(getClass());
//
// private ProductService productService;
//
// private CategoryService categoryService;
//
// private CustomerService customerService;
//
// private CustomerOrderService customerOrderService;
//
// private ScheduledExecutorService executorService;
//
// public static ApplicationContext INSTANCE = new ApplicationContext();
//
// private ApplicationContext() {
//
// executorService = new ScheduledThreadPoolExecutor(Runtime.getRuntime().availableProcessors());
//
// // wire up the business.dao layer "by hand"
// ProductDao productDao = new ProductDaoJdbc();
//
// ProductDaoGuava cachedProductDao = new ProductDaoGuava(productDao);
//
// productService = new DefaultProductService();
// ((DefaultProductService) productService).setProductDao(cachedProductDao);
//
// CategoryDao categoryDao = new CategoryDaoJdbc();
//
// CategoryDaoGuava cachedCategoryDao = new CategoryDaoGuava(categoryDao);
//
// categoryService = new DefaultCategoryService();
// ((DefaultCategoryService) categoryService).setCategoryDao(cachedCategoryDao);
//
// CustomerDao customerDao = new CustomerDaoJdbc();
// customerService = new DefaultCustomerService();
// ((DefaultCustomerService) customerService).setCustomerDao(customerDao);
//
// CustomerOrderLineItemDao customerOrderLineItemDao = new CustomerOrderLineItemDaoJdbc();
// CustomerOrderDao customerOrderDao = new CustomerOrderDaoJdbc();
//
// customerOrderService = new DefaultCustomerOrderService();
// DefaultCustomerOrderService service = (DefaultCustomerOrderService) customerOrderService;
// service.setProductDao(cachedProductDao);
// service.setCustomerService(customerService);
// service.setCustomerOrderDao(customerOrderDao);
// service.setCustomerOrderLineItemDao(customerOrderLineItemDao);
//
// executorService.scheduleWithFixedDelay(() -> {
// try {
// logger.info("Refreshing category and product caches....commencing");
// cachedCategoryDao.bulkload();
// cachedProductDao.clear();
// logger.info("Refreshing category and product caches....complete!");
// } catch (Throwable t) {
// logger.error("Encountered trouble refreshing category and product caches.", t);
// }
// }, 10, 60, TimeUnit.MINUTES);
// }
//
//
//
// public ProductService getProductService() {
// return productService;
// }
//
// public CategoryService getCategoryService() {
// return categoryService;
// }
//
// public CustomerService getCustomerService() {
// return customerService;
// }
//
// public CustomerOrderService getCustomerOrderService() {
// return customerOrderService;
// }
//
// public void shutdown() {
// executorService.shutdown();
// }
// }
// Path: src/main/java/controller/SimpleAffableBeanContextListener.java
import business.ApplicationContext;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.http.HttpSessionAttributeListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller; /**
*/
public class SimpleAffableBeanContextListener implements ServletContextListener, HttpSessionListener, HttpSessionAttributeListener {
private Logger logger = LoggerFactory.getLogger(getClass());
// Public constructor is required by servlet spec
public SimpleAffableBeanContextListener() {
}
// -------------------------------------------------------
// ServletContextListener implementation
// -------------------------------------------------------
public void contextInitialized(ServletContextEvent sce) {
/* This method is called when the servlet context is
initialized(when the Web application is deployed).
You can initialize servlet context related data here.
*/
logger.info("Servlet context initializing.");
// initialize servlet with configuration information
|
ApplicationContext applicationContext = ApplicationContext.INSTANCE;
|
nowucca/SimpleAffableBean
|
src/main/java/business/category/CategoryDaoJdbc.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
|
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static business.JdbcUtils.getConnection;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.category;
/**
*/
public class CategoryDaoJdbc implements CategoryDao {
private static final String FIND_ALL_SQL =
"SELECT " +
"c.category_id, " +
"c.name " +
"FROM " +
"category c";
private static final String FIND_BY_CATEGORY_ID_SQL =
"SELECT " +
"c.category_id, " +
"c.name " +
"FROM " +
"category c " +
"WHERE " +
"c.category_id = ?";
@Override
public Category findByCategoryId(long categoryId) {
Category result = null;
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
// Path: src/main/java/business/category/CategoryDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static business.JdbcUtils.getConnection;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.category;
/**
*/
public class CategoryDaoJdbc implements CategoryDao {
private static final String FIND_ALL_SQL =
"SELECT " +
"c.category_id, " +
"c.name " +
"FROM " +
"category c";
private static final String FIND_BY_CATEGORY_ID_SQL =
"SELECT " +
"c.category_id, " +
"c.name " +
"FROM " +
"category c " +
"WHERE " +
"c.category_id = ?";
@Override
public Category findByCategoryId(long categoryId) {
Category result = null;
|
try (Connection connection = getConnection();
|
nowucca/SimpleAffableBean
|
src/main/java/business/category/CategoryDaoJdbc.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
|
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static business.JdbcUtils.getConnection;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.category;
/**
*/
public class CategoryDaoJdbc implements CategoryDao {
private static final String FIND_ALL_SQL =
"SELECT " +
"c.category_id, " +
"c.name " +
"FROM " +
"category c";
private static final String FIND_BY_CATEGORY_ID_SQL =
"SELECT " +
"c.category_id, " +
"c.name " +
"FROM " +
"category c " +
"WHERE " +
"c.category_id = ?";
@Override
public Category findByCategoryId(long categoryId) {
Category result = null;
try (Connection connection = getConnection();
PreparedStatement statement = connection.prepareStatement(FIND_BY_CATEGORY_ID_SQL)) {
statement.setLong(1, categoryId);
try (ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) {
result = readCategory(resultSet);
}
}
} catch (SQLException e) {
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
// Path: src/main/java/business/category/CategoryDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import static business.JdbcUtils.getConnection;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.category;
/**
*/
public class CategoryDaoJdbc implements CategoryDao {
private static final String FIND_ALL_SQL =
"SELECT " +
"c.category_id, " +
"c.name " +
"FROM " +
"category c";
private static final String FIND_BY_CATEGORY_ID_SQL =
"SELECT " +
"c.category_id, " +
"c.name " +
"FROM " +
"category c " +
"WHERE " +
"c.category_id = ?";
@Override
public Category findByCategoryId(long categoryId) {
Category result = null;
try (Connection connection = getConnection();
PreparedStatement statement = connection.prepareStatement(FIND_BY_CATEGORY_ID_SQL)) {
statement.setLong(1, categoryId);
try (ResultSet resultSet = statement.executeQuery()) {
if (resultSet.next()) {
result = readCategory(resultSet);
}
}
} catch (SQLException e) {
|
throw new SimpleAffableQueryDbException("Encountered problem finding category " + categoryId, e);
|
nowucca/SimpleAffableBean
|
src/main/java/business/order/CustomerOrderDaoJdbc.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
|
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static business.JdbcUtils.getConnection;
|
"SELECT " +
"co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
"FROM " +
"customer_order co";
private static final String FIND_BY_CUSTOMER_ID_SQL =
"SELECT " +
"co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
"FROM " +
"customer_order co " +
"WHERE " +
"co.customer_id = ?";
private static final String FIND_BY_CUSTOMER_ORDER_ID_SQL =
"SELECT " +
"co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
"FROM " +
"customer_order co " +
"WHERE " +
"co.customer_order_id = ?";
@Override
public long create(final Connection connection, long customerId, int amount, int confirmationNumber) {
try (PreparedStatement statement =
connection.prepareStatement(CREATE_ORDER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, amount);
statement.setLong(2, customerId);
statement.setInt(3, confirmationNumber);
int affected = statement.executeUpdate();
if (affected != 1) {
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
// Path: src/main/java/business/order/CustomerOrderDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static business.JdbcUtils.getConnection;
"SELECT " +
"co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
"FROM " +
"customer_order co";
private static final String FIND_BY_CUSTOMER_ID_SQL =
"SELECT " +
"co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
"FROM " +
"customer_order co " +
"WHERE " +
"co.customer_id = ?";
private static final String FIND_BY_CUSTOMER_ORDER_ID_SQL =
"SELECT " +
"co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
"FROM " +
"customer_order co " +
"WHERE " +
"co.customer_order_id = ?";
@Override
public long create(final Connection connection, long customerId, int amount, int confirmationNumber) {
try (PreparedStatement statement =
connection.prepareStatement(CREATE_ORDER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, amount);
statement.setLong(2, customerId);
statement.setInt(3, confirmationNumber);
int affected = statement.executeUpdate();
if (affected != 1) {
|
throw new SimpleAffableUpdateDbException("Failed to insert an order, affected row count = "
|
nowucca/SimpleAffableBean
|
src/main/java/business/order/CustomerOrderDaoJdbc.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
|
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static business.JdbcUtils.getConnection;
|
"FROM " +
"customer_order co " +
"WHERE " +
"co.customer_id = ?";
private static final String FIND_BY_CUSTOMER_ORDER_ID_SQL =
"SELECT " +
"co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
"FROM " +
"customer_order co " +
"WHERE " +
"co.customer_order_id = ?";
@Override
public long create(final Connection connection, long customerId, int amount, int confirmationNumber) {
try (PreparedStatement statement =
connection.prepareStatement(CREATE_ORDER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, amount);
statement.setLong(2, customerId);
statement.setInt(3, confirmationNumber);
int affected = statement.executeUpdate();
if (affected != 1) {
throw new SimpleAffableUpdateDbException("Failed to insert an order, affected row count = "
+ affected);
}
long customerOrderId;
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
customerOrderId = rs.getLong(1);
} else {
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
// Path: src/main/java/business/order/CustomerOrderDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static business.JdbcUtils.getConnection;
"FROM " +
"customer_order co " +
"WHERE " +
"co.customer_id = ?";
private static final String FIND_BY_CUSTOMER_ORDER_ID_SQL =
"SELECT " +
"co.customer_order_id, co.customer_id, co.amount, co.date_created, co.confirmation_number " +
"FROM " +
"customer_order co " +
"WHERE " +
"co.customer_order_id = ?";
@Override
public long create(final Connection connection, long customerId, int amount, int confirmationNumber) {
try (PreparedStatement statement =
connection.prepareStatement(CREATE_ORDER_SQL, Statement.RETURN_GENERATED_KEYS)) {
statement.setInt(1, amount);
statement.setLong(2, customerId);
statement.setInt(3, confirmationNumber);
int affected = statement.executeUpdate();
if (affected != 1) {
throw new SimpleAffableUpdateDbException("Failed to insert an order, affected row count = "
+ affected);
}
long customerOrderId;
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
customerOrderId = rs.getLong(1);
} else {
|
throw new SimpleAffableQueryDbException("Failed to retrieve customerOrderId auto-generated key");
|
nowucca/SimpleAffableBean
|
src/main/java/business/order/CustomerOrderDaoJdbc.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
|
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static business.JdbcUtils.getConnection;
|
throw new SimpleAffableUpdateDbException("Failed to insert an order, affected row count = "
+ affected);
}
long customerOrderId;
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
customerOrderId = rs.getLong(1);
} else {
throw new SimpleAffableQueryDbException("Failed to retrieve customerOrderId auto-generated key");
}
return customerOrderId;
} catch (SQLException e) {
throw new SimpleAffableUpdateDbException("Encountered problem creating a new customer ", e);
}
}
@Override
public CustomerOrder findByCustomerId(long customerId) {
return getCustomerOrderBy(FIND_BY_CUSTOMER_ID_SQL, customerId);
}
@Override
public CustomerOrder findByCustomerOrderId(long customerOrderId) {
return getCustomerOrderBy(FIND_BY_CUSTOMER_ORDER_ID_SQL, customerOrderId);
}
@Override
public Collection<CustomerOrder> findAll() {
List<CustomerOrder> result = new ArrayList<>(16);
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
//
// Path: src/main/java/business/JdbcUtils.java
// public static Connection getConnection() {
// if (dataSource == null) {
// dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
// }
//
// try {
// return dataSource.getConnection();
// } catch (SQLException e) {
// throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
// }
//
// }
// Path: src/main/java/business/order/CustomerOrderDaoJdbc.java
import business.SimpleAffableDbException.SimpleAffableQueryDbException;
import business.SimpleAffableDbException.SimpleAffableUpdateDbException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import static business.JdbcUtils.getConnection;
throw new SimpleAffableUpdateDbException("Failed to insert an order, affected row count = "
+ affected);
}
long customerOrderId;
ResultSet rs = statement.getGeneratedKeys();
if (rs.next()) {
customerOrderId = rs.getLong(1);
} else {
throw new SimpleAffableQueryDbException("Failed to retrieve customerOrderId auto-generated key");
}
return customerOrderId;
} catch (SQLException e) {
throw new SimpleAffableUpdateDbException("Encountered problem creating a new customer ", e);
}
}
@Override
public CustomerOrder findByCustomerId(long customerId) {
return getCustomerOrderBy(FIND_BY_CUSTOMER_ID_SQL, customerId);
}
@Override
public CustomerOrder findByCustomerOrderId(long customerOrderId) {
return getCustomerOrderBy(FIND_BY_CUSTOMER_ORDER_ID_SQL, customerOrderId);
}
@Override
public Collection<CustomerOrder> findAll() {
List<CustomerOrder> result = new ArrayList<>(16);
|
try (Connection connection = getConnection();
|
nowucca/SimpleAffableBean
|
src/main/java/controller/admin/AdminCustomersServlet.java
|
// Path: src/main/java/viewmodel/admin/AdminCustomersViewModel.java
// public class AdminCustomersViewModel extends BaseAdminViewModel {
//
// private List<Customer> customerList;
//
// public AdminCustomersViewModel(HttpServletRequest request) {
// super(request);
//
// this.customerList = customerService.findAll();
// }
//
// public List<Customer> getCustomerList() {
// return customerList;
// }
//
// }
|
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import viewmodel.admin.AdminCustomersViewModel;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller.admin;
/**
*
*/
@WebServlet(name = "AdminCustomersServlet",
urlPatterns = {"/admin/customers"})
@ServletSecurity(
@HttpConstraint(transportGuarantee = TransportGuarantee.CONFIDENTIAL,
rolesAllowed = {"simpleAffableBeanAdmin"})
)
public class AdminCustomersServlet extends AdminServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
|
// Path: src/main/java/viewmodel/admin/AdminCustomersViewModel.java
// public class AdminCustomersViewModel extends BaseAdminViewModel {
//
// private List<Customer> customerList;
//
// public AdminCustomersViewModel(HttpServletRequest request) {
// super(request);
//
// this.customerList = customerService.findAll();
// }
//
// public List<Customer> getCustomerList() {
// return customerList;
// }
//
// }
// Path: src/main/java/controller/admin/AdminCustomersServlet.java
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import viewmodel.admin.AdminCustomersViewModel;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller.admin;
/**
*
*/
@WebServlet(name = "AdminCustomersServlet",
urlPatterns = {"/admin/customers"})
@ServletSecurity(
@HttpConstraint(transportGuarantee = TransportGuarantee.CONFIDENTIAL,
rolesAllowed = {"simpleAffableBeanAdmin"})
)
public class AdminCustomersServlet extends AdminServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
|
request.setAttribute("p", new AdminCustomersViewModel(request));
|
nowucca/SimpleAffableBean
|
src/main/java/controller/ErrorServlet.java
|
// Path: src/main/java/viewmodel/ErrorViewModel.java
// public class ErrorViewModel extends BaseViewModel {
// private String servletName;
// private String requestUri;
// private Integer statusCode;
// private Throwable throwable;
// private boolean isServiceRequest;
//
// public ErrorViewModel(HttpServletRequest request) {
// super(request);
// // Analyze the servlet exception
// throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
// statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
// servletName = (String) request.getAttribute("javax.servlet.error.servlet_name");
// if (servletName == null) {
// servletName = "Unknown";
// }
// requestUri = (String) request.getAttribute("javax.servlet.error.request_uri");
// if (requestUri == null) {
// requestUri = "Unknown";
// }
// isServiceRequest = requestUri.toLowerCase().contains("/service");
// }
//
// public boolean isServiceRequest() {
// return isServiceRequest;
// }
//
// public String getServletName() {
// return servletName;
// }
//
// public String getRequestUri() {
// return requestUri;
// }
//
// public Integer getStatusCode() {
// return statusCode;
// }
//
// public Throwable getThrowable() {
// return throwable;
// }
//
// public String getMessage() {
// if (throwable == null) {
// return "N/A";
// } else {
// return throwable.getMessage();
// }
// }
// }
|
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import viewmodel.ErrorViewModel;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller;
@WebServlet(name = "ErrorServlet", urlPatterns = {"/Error"})
public class ErrorServlet extends SimpleAffableBeanServlet {
private static final Logger logger = LoggerFactory.getLogger(ErrorServlet.class);
// Method to handle GET method request.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
// Path: src/main/java/viewmodel/ErrorViewModel.java
// public class ErrorViewModel extends BaseViewModel {
// private String servletName;
// private String requestUri;
// private Integer statusCode;
// private Throwable throwable;
// private boolean isServiceRequest;
//
// public ErrorViewModel(HttpServletRequest request) {
// super(request);
// // Analyze the servlet exception
// throwable = (Throwable) request.getAttribute("javax.servlet.error.exception");
// statusCode = (Integer) request.getAttribute("javax.servlet.error.status_code");
// servletName = (String) request.getAttribute("javax.servlet.error.servlet_name");
// if (servletName == null) {
// servletName = "Unknown";
// }
// requestUri = (String) request.getAttribute("javax.servlet.error.request_uri");
// if (requestUri == null) {
// requestUri = "Unknown";
// }
// isServiceRequest = requestUri.toLowerCase().contains("/service");
// }
//
// public boolean isServiceRequest() {
// return isServiceRequest;
// }
//
// public String getServletName() {
// return servletName;
// }
//
// public String getRequestUri() {
// return requestUri;
// }
//
// public Integer getStatusCode() {
// return statusCode;
// }
//
// public Throwable getThrowable() {
// return throwable;
// }
//
// public String getMessage() {
// if (throwable == null) {
// return "N/A";
// } else {
// return throwable.getMessage();
// }
// }
// }
// Path: src/main/java/controller/ErrorServlet.java
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import viewmodel.ErrorViewModel;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller;
@WebServlet(name = "ErrorServlet", urlPatterns = {"/Error"})
public class ErrorServlet extends SimpleAffableBeanServlet {
private static final Logger logger = LoggerFactory.getLogger(ErrorServlet.class);
// Method to handle GET method request.
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
ErrorViewModel errorViewModel = new ErrorViewModel(request);
|
nowucca/SimpleAffableBean
|
src/main/java/business/customer/DefaultCustomerService.java
|
// Path: src/main/java/business/ValidationException.java
// public class ValidationException extends Exception {
//
//
// private List<String> invalidFieldNames = new ArrayList<>();
//
// public ValidationException() {
// }
//
// public ValidationException(String invalidFieldName) {
// super();
// fieldError(invalidFieldName);
// }
//
// public ValidationException fieldError(String fieldName) {
// invalidFieldNames.add(fieldName);
// return this;
// }
//
//
// public boolean hasErrors() {
// return !invalidFieldNames.isEmpty();
// }
//
// public List<String> getInvalidFieldNames() {
// return invalidFieldNames;
// }
//
// public boolean hasInvalidField(String name) {
// return invalidFieldNames.contains(name);
// }
// }
|
import business.ValidationException;
import java.sql.Connection;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.customer;
/**
*/
public class DefaultCustomerService implements CustomerService {
private CustomerDao customerDao;
private static final Logger logger =
LoggerFactory.getLogger(DefaultCustomerService.class);
private void validateForm(CustomerForm customerForm)
|
// Path: src/main/java/business/ValidationException.java
// public class ValidationException extends Exception {
//
//
// private List<String> invalidFieldNames = new ArrayList<>();
//
// public ValidationException() {
// }
//
// public ValidationException(String invalidFieldName) {
// super();
// fieldError(invalidFieldName);
// }
//
// public ValidationException fieldError(String fieldName) {
// invalidFieldNames.add(fieldName);
// return this;
// }
//
//
// public boolean hasErrors() {
// return !invalidFieldNames.isEmpty();
// }
//
// public List<String> getInvalidFieldNames() {
// return invalidFieldNames;
// }
//
// public boolean hasInvalidField(String name) {
// return invalidFieldNames.contains(name);
// }
// }
// Path: src/main/java/business/customer/DefaultCustomerService.java
import business.ValidationException;
import java.sql.Connection;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.customer;
/**
*/
public class DefaultCustomerService implements CustomerService {
private CustomerDao customerDao;
private static final Logger logger =
LoggerFactory.getLogger(DefaultCustomerService.class);
private void validateForm(CustomerForm customerForm)
|
throws ValidationException {
|
nowucca/SimpleAffableBean
|
src/main/java/viewmodel/ConfirmationViewModel.java
|
// Path: src/main/java/business/order/CustomerOrderDetails.java
// public class CustomerOrderDetails {
//
// private CustomerOrder customerOrder;
// private Customer customer;
// private List<Product> products;
// private List<CustomerOrderLineItem> lineItems;
//
// public CustomerOrderDetails(CustomerOrder customerOrder, Customer customer, List<Product> products, List
// <CustomerOrderLineItem> lineItems) {
// this.customerOrder = customerOrder;
// this.customer = customer;
// this.products = products;
// this.lineItems = lineItems;
// }
//
// public CustomerOrder getCustomerOrder() {
// return customerOrder;
// }
//
// public Customer getCustomer() {
// return customer;
// }
//
// public List<Product> getProducts() {
// return Collections.unmodifiableList(products);
// }
//
// public List<CustomerOrderLineItem> getCustomerOrderLineItems() {
// return Collections.unmodifiableList(lineItems);
// }
// }
|
import business.order.CustomerOrderDetails;
import javax.servlet.http.HttpServletRequest;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel;
/**
*
*/
@SuppressWarnings("unchecked")
public class ConfirmationViewModel extends BaseViewModel {
private Long orderId;
|
// Path: src/main/java/business/order/CustomerOrderDetails.java
// public class CustomerOrderDetails {
//
// private CustomerOrder customerOrder;
// private Customer customer;
// private List<Product> products;
// private List<CustomerOrderLineItem> lineItems;
//
// public CustomerOrderDetails(CustomerOrder customerOrder, Customer customer, List<Product> products, List
// <CustomerOrderLineItem> lineItems) {
// this.customerOrder = customerOrder;
// this.customer = customer;
// this.products = products;
// this.lineItems = lineItems;
// }
//
// public CustomerOrder getCustomerOrder() {
// return customerOrder;
// }
//
// public Customer getCustomer() {
// return customer;
// }
//
// public List<Product> getProducts() {
// return Collections.unmodifiableList(products);
// }
//
// public List<CustomerOrderLineItem> getCustomerOrderLineItems() {
// return Collections.unmodifiableList(lineItems);
// }
// }
// Path: src/main/java/viewmodel/ConfirmationViewModel.java
import business.order.CustomerOrderDetails;
import javax.servlet.http.HttpServletRequest;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel;
/**
*
*/
@SuppressWarnings("unchecked")
public class ConfirmationViewModel extends BaseViewModel {
private Long orderId;
|
private CustomerOrderDetails orderDetails;
|
nowucca/SimpleAffableBean
|
src/main/java/business/order/CustomerOrderDetails.java
|
// Path: src/main/java/business/customer/Customer.java
// public class Customer {
//
// private long customerId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private String address;
//
// private String cityRegion;
//
// private String ccNumber;
//
// public Customer(long customerId, String name, String email,
// String phone, String address, String cityRegion, String ccNumber) {
// this.customerId = customerId;
// this.name = name;
// this.email = email;
// this.phone = phone;
// this.address = address;
// this.cityRegion = cityRegion;
// this.ccNumber = ccNumber;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getCityRegion() {
// return cityRegion;
// }
//
// public String getCcNumber() {
// return ccNumber;
// }
//
// @Override
// public String toString() {
// return "business.customer.Customer[customerId=" + customerId + "]";
// }
//
// }
//
// Path: src/main/java/business/product/Product.java
// public class Product {
//
// private long productId;
// private String name;
// private int price;
// private Date lastUpdate;
//
// public Product(long productId, String name, int price, Date lastUpdate) {
// this.productId = productId;
// this.name = name;
// this.price = price;
// this.lastUpdate = lastUpdate;
// }
//
// public long getProductId() {
// return productId;
// }
// public String getName() {
// return name;
// }
//
// public int getPrice() {
// return price;
// }
//
// public Date getLastUpdate() {
// return lastUpdate;
// }
//
// @Override
// public String toString() {
// return "business.product.Product[product_id=" + productId + "]";
// }
//
// }
|
import business.customer.Customer;
import business.product.Product;
import java.util.Collections;
import java.util.List;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.order;
/**
*/
public class CustomerOrderDetails {
private CustomerOrder customerOrder;
|
// Path: src/main/java/business/customer/Customer.java
// public class Customer {
//
// private long customerId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private String address;
//
// private String cityRegion;
//
// private String ccNumber;
//
// public Customer(long customerId, String name, String email,
// String phone, String address, String cityRegion, String ccNumber) {
// this.customerId = customerId;
// this.name = name;
// this.email = email;
// this.phone = phone;
// this.address = address;
// this.cityRegion = cityRegion;
// this.ccNumber = ccNumber;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getCityRegion() {
// return cityRegion;
// }
//
// public String getCcNumber() {
// return ccNumber;
// }
//
// @Override
// public String toString() {
// return "business.customer.Customer[customerId=" + customerId + "]";
// }
//
// }
//
// Path: src/main/java/business/product/Product.java
// public class Product {
//
// private long productId;
// private String name;
// private int price;
// private Date lastUpdate;
//
// public Product(long productId, String name, int price, Date lastUpdate) {
// this.productId = productId;
// this.name = name;
// this.price = price;
// this.lastUpdate = lastUpdate;
// }
//
// public long getProductId() {
// return productId;
// }
// public String getName() {
// return name;
// }
//
// public int getPrice() {
// return price;
// }
//
// public Date getLastUpdate() {
// return lastUpdate;
// }
//
// @Override
// public String toString() {
// return "business.product.Product[product_id=" + productId + "]";
// }
//
// }
// Path: src/main/java/business/order/CustomerOrderDetails.java
import business.customer.Customer;
import business.product.Product;
import java.util.Collections;
import java.util.List;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.order;
/**
*/
public class CustomerOrderDetails {
private CustomerOrder customerOrder;
|
private Customer customer;
|
nowucca/SimpleAffableBean
|
src/main/java/business/order/CustomerOrderDetails.java
|
// Path: src/main/java/business/customer/Customer.java
// public class Customer {
//
// private long customerId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private String address;
//
// private String cityRegion;
//
// private String ccNumber;
//
// public Customer(long customerId, String name, String email,
// String phone, String address, String cityRegion, String ccNumber) {
// this.customerId = customerId;
// this.name = name;
// this.email = email;
// this.phone = phone;
// this.address = address;
// this.cityRegion = cityRegion;
// this.ccNumber = ccNumber;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getCityRegion() {
// return cityRegion;
// }
//
// public String getCcNumber() {
// return ccNumber;
// }
//
// @Override
// public String toString() {
// return "business.customer.Customer[customerId=" + customerId + "]";
// }
//
// }
//
// Path: src/main/java/business/product/Product.java
// public class Product {
//
// private long productId;
// private String name;
// private int price;
// private Date lastUpdate;
//
// public Product(long productId, String name, int price, Date lastUpdate) {
// this.productId = productId;
// this.name = name;
// this.price = price;
// this.lastUpdate = lastUpdate;
// }
//
// public long getProductId() {
// return productId;
// }
// public String getName() {
// return name;
// }
//
// public int getPrice() {
// return price;
// }
//
// public Date getLastUpdate() {
// return lastUpdate;
// }
//
// @Override
// public String toString() {
// return "business.product.Product[product_id=" + productId + "]";
// }
//
// }
|
import business.customer.Customer;
import business.product.Product;
import java.util.Collections;
import java.util.List;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.order;
/**
*/
public class CustomerOrderDetails {
private CustomerOrder customerOrder;
private Customer customer;
|
// Path: src/main/java/business/customer/Customer.java
// public class Customer {
//
// private long customerId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private String address;
//
// private String cityRegion;
//
// private String ccNumber;
//
// public Customer(long customerId, String name, String email,
// String phone, String address, String cityRegion, String ccNumber) {
// this.customerId = customerId;
// this.name = name;
// this.email = email;
// this.phone = phone;
// this.address = address;
// this.cityRegion = cityRegion;
// this.ccNumber = ccNumber;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getCityRegion() {
// return cityRegion;
// }
//
// public String getCcNumber() {
// return ccNumber;
// }
//
// @Override
// public String toString() {
// return "business.customer.Customer[customerId=" + customerId + "]";
// }
//
// }
//
// Path: src/main/java/business/product/Product.java
// public class Product {
//
// private long productId;
// private String name;
// private int price;
// private Date lastUpdate;
//
// public Product(long productId, String name, int price, Date lastUpdate) {
// this.productId = productId;
// this.name = name;
// this.price = price;
// this.lastUpdate = lastUpdate;
// }
//
// public long getProductId() {
// return productId;
// }
// public String getName() {
// return name;
// }
//
// public int getPrice() {
// return price;
// }
//
// public Date getLastUpdate() {
// return lastUpdate;
// }
//
// @Override
// public String toString() {
// return "business.product.Product[product_id=" + productId + "]";
// }
//
// }
// Path: src/main/java/business/order/CustomerOrderDetails.java
import business.customer.Customer;
import business.product.Product;
import java.util.Collections;
import java.util.List;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.order;
/**
*/
public class CustomerOrderDetails {
private CustomerOrder customerOrder;
private Customer customer;
|
private List<Product> products;
|
nowucca/SimpleAffableBean
|
src/main/java/viewmodel/CategoryViewModel.java
|
// Path: src/main/java/business/category/Category.java
// public class Category {
//
// private long categoryId;
// private String name;
//
// public Category(long categoryId, String name) {
// this.categoryId = categoryId;
// this.name = name;
// }
//
// public long getCategoryId() {
// return categoryId;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return "business.category.Category[id=" + categoryId + "]";
// }
//
// }
//
// Path: src/main/java/business/product/Product.java
// public class Product {
//
// private long productId;
// private String name;
// private int price;
// private Date lastUpdate;
//
// public Product(long productId, String name, int price, Date lastUpdate) {
// this.productId = productId;
// this.name = name;
// this.price = price;
// this.lastUpdate = lastUpdate;
// }
//
// public long getProductId() {
// return productId;
// }
// public String getName() {
// return name;
// }
//
// public int getPrice() {
// return price;
// }
//
// public Date getLastUpdate() {
// return lastUpdate;
// }
//
// @Override
// public String toString() {
// return "business.product.Product[product_id=" + productId + "]";
// }
//
// }
|
import business.category.Category;
import business.product.Product;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel;
/**
*/
@SuppressWarnings("unchecked")
public class CategoryViewModel extends BaseViewModel {
|
// Path: src/main/java/business/category/Category.java
// public class Category {
//
// private long categoryId;
// private String name;
//
// public Category(long categoryId, String name) {
// this.categoryId = categoryId;
// this.name = name;
// }
//
// public long getCategoryId() {
// return categoryId;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return "business.category.Category[id=" + categoryId + "]";
// }
//
// }
//
// Path: src/main/java/business/product/Product.java
// public class Product {
//
// private long productId;
// private String name;
// private int price;
// private Date lastUpdate;
//
// public Product(long productId, String name, int price, Date lastUpdate) {
// this.productId = productId;
// this.name = name;
// this.price = price;
// this.lastUpdate = lastUpdate;
// }
//
// public long getProductId() {
// return productId;
// }
// public String getName() {
// return name;
// }
//
// public int getPrice() {
// return price;
// }
//
// public Date getLastUpdate() {
// return lastUpdate;
// }
//
// @Override
// public String toString() {
// return "business.product.Product[product_id=" + productId + "]";
// }
//
// }
// Path: src/main/java/viewmodel/CategoryViewModel.java
import business.category.Category;
import business.product.Product;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel;
/**
*/
@SuppressWarnings("unchecked")
public class CategoryViewModel extends BaseViewModel {
|
private Category selectedCategory;
|
nowucca/SimpleAffableBean
|
src/main/java/viewmodel/CategoryViewModel.java
|
// Path: src/main/java/business/category/Category.java
// public class Category {
//
// private long categoryId;
// private String name;
//
// public Category(long categoryId, String name) {
// this.categoryId = categoryId;
// this.name = name;
// }
//
// public long getCategoryId() {
// return categoryId;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return "business.category.Category[id=" + categoryId + "]";
// }
//
// }
//
// Path: src/main/java/business/product/Product.java
// public class Product {
//
// private long productId;
// private String name;
// private int price;
// private Date lastUpdate;
//
// public Product(long productId, String name, int price, Date lastUpdate) {
// this.productId = productId;
// this.name = name;
// this.price = price;
// this.lastUpdate = lastUpdate;
// }
//
// public long getProductId() {
// return productId;
// }
// public String getName() {
// return name;
// }
//
// public int getPrice() {
// return price;
// }
//
// public Date getLastUpdate() {
// return lastUpdate;
// }
//
// @Override
// public String toString() {
// return "business.product.Product[product_id=" + productId + "]";
// }
//
// }
|
import business.category.Category;
import business.product.Product;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel;
/**
*/
@SuppressWarnings("unchecked")
public class CategoryViewModel extends BaseViewModel {
private Category selectedCategory;
|
// Path: src/main/java/business/category/Category.java
// public class Category {
//
// private long categoryId;
// private String name;
//
// public Category(long categoryId, String name) {
// this.categoryId = categoryId;
// this.name = name;
// }
//
// public long getCategoryId() {
// return categoryId;
// }
//
// public String getName() {
// return name;
// }
//
// @Override
// public String toString() {
// return "business.category.Category[id=" + categoryId + "]";
// }
//
// }
//
// Path: src/main/java/business/product/Product.java
// public class Product {
//
// private long productId;
// private String name;
// private int price;
// private Date lastUpdate;
//
// public Product(long productId, String name, int price, Date lastUpdate) {
// this.productId = productId;
// this.name = name;
// this.price = price;
// this.lastUpdate = lastUpdate;
// }
//
// public long getProductId() {
// return productId;
// }
// public String getName() {
// return name;
// }
//
// public int getPrice() {
// return price;
// }
//
// public Date getLastUpdate() {
// return lastUpdate;
// }
//
// @Override
// public String toString() {
// return "business.product.Product[product_id=" + productId + "]";
// }
//
// }
// Path: src/main/java/viewmodel/CategoryViewModel.java
import business.category.Category;
import business.product.Product;
import java.util.Collection;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel;
/**
*/
@SuppressWarnings("unchecked")
public class CategoryViewModel extends BaseViewModel {
private Category selectedCategory;
|
private Collection<Product> selectedCategoryProducts;
|
nowucca/SimpleAffableBean
|
src/main/java/viewmodel/admin/AdminCustomerViewModel.java
|
// Path: src/main/java/business/customer/Customer.java
// public class Customer {
//
// private long customerId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private String address;
//
// private String cityRegion;
//
// private String ccNumber;
//
// public Customer(long customerId, String name, String email,
// String phone, String address, String cityRegion, String ccNumber) {
// this.customerId = customerId;
// this.name = name;
// this.email = email;
// this.phone = phone;
// this.address = address;
// this.cityRegion = cityRegion;
// this.ccNumber = ccNumber;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getCityRegion() {
// return cityRegion;
// }
//
// public String getCcNumber() {
// return ccNumber;
// }
//
// @Override
// public String toString() {
// return "business.customer.Customer[customerId=" + customerId + "]";
// }
//
// }
//
// Path: src/main/java/business/order/CustomerOrder.java
// public class CustomerOrder {
//
// private long customerOrderId;
// private long customerId;
// private int amount;
// private Date dateCreated;
// private int confirmationNumber;
//
//
// public CustomerOrder() {
// }
//
//
// public CustomerOrder(long customerOrderId, long customerId, int amount, Date dateCreated, int confirmationNumber) {
// this.customerOrderId = customerOrderId;
// this.customerId = customerId;
// this.amount = amount;
// this.dateCreated = dateCreated;
// this.confirmationNumber = confirmationNumber;
// }
//
// public long getCustomerOrderId() {
// return customerOrderId;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public int getAmount() {
// return amount;
// }
//
// public Date getDateCreated() {
// return dateCreated;
// }
//
// public int getConfirmationNumber() {
// return confirmationNumber;
// }
//
//
// @Override
// public String toString() {
// return "business.order.CustomerOrder[customerOrderId=" + customerOrderId + "]";
// }
//
// }
//
// Path: src/main/java/viewmodel/admin/BaseAdminViewModel.java
// public class BaseAdminViewModel {
//
// // The relative path to product images
// // private static final String PRODUCT_IMAGE_PATH = "/img/products/";
// private static final String PRODUCT_IMAGE_PATH = BaseViewModel.PRODUCT_IMAGE_PATH;
//
// // Every view model knows the request and session
// protected HttpServletRequest request;
// protected HttpSession session;
//
// // All customer/order pages need the following service objects
// protected CustomerService customerService;
// protected CustomerOrderService customerOrderService;
//
// // Delivery surcharge
// protected int deliverySurcharge;
//
// @SuppressWarnings("unchecked")
// public BaseAdminViewModel(HttpServletRequest request) {
// ApplicationContext applicationContext = ApplicationContext.INSTANCE;
// customerService = applicationContext.getCustomerService();
// customerOrderService = applicationContext.getCustomerOrderService();
//
// this.request = request;
// this.session = request.getSession(true);
// this.deliverySurcharge = Integer.valueOf(request.getServletContext().getInitParameter("deliverySurcharge"));
// }
//
// public HttpSession getSession() {
// return session;
// }
//
// public CustomerService getCustomerService() {
// return customerService;
// }
//
// public CustomerOrderService getCustomerOrderService() {
// return customerOrderService;
// }
//
// public String getProductImagePath() {
// return PRODUCT_IMAGE_PATH;
// }
//
// public int getDeliverySurcharge() {
// return deliverySurcharge;
// }
//
// }
|
import business.customer.Customer;
import business.order.CustomerOrder;
import viewmodel.BaseAdminViewModel;
import javax.servlet.http.HttpServletRequest;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel.admin;
public class AdminCustomerViewModel extends BaseAdminViewModel {
private String customerId;
|
// Path: src/main/java/business/customer/Customer.java
// public class Customer {
//
// private long customerId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private String address;
//
// private String cityRegion;
//
// private String ccNumber;
//
// public Customer(long customerId, String name, String email,
// String phone, String address, String cityRegion, String ccNumber) {
// this.customerId = customerId;
// this.name = name;
// this.email = email;
// this.phone = phone;
// this.address = address;
// this.cityRegion = cityRegion;
// this.ccNumber = ccNumber;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getCityRegion() {
// return cityRegion;
// }
//
// public String getCcNumber() {
// return ccNumber;
// }
//
// @Override
// public String toString() {
// return "business.customer.Customer[customerId=" + customerId + "]";
// }
//
// }
//
// Path: src/main/java/business/order/CustomerOrder.java
// public class CustomerOrder {
//
// private long customerOrderId;
// private long customerId;
// private int amount;
// private Date dateCreated;
// private int confirmationNumber;
//
//
// public CustomerOrder() {
// }
//
//
// public CustomerOrder(long customerOrderId, long customerId, int amount, Date dateCreated, int confirmationNumber) {
// this.customerOrderId = customerOrderId;
// this.customerId = customerId;
// this.amount = amount;
// this.dateCreated = dateCreated;
// this.confirmationNumber = confirmationNumber;
// }
//
// public long getCustomerOrderId() {
// return customerOrderId;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public int getAmount() {
// return amount;
// }
//
// public Date getDateCreated() {
// return dateCreated;
// }
//
// public int getConfirmationNumber() {
// return confirmationNumber;
// }
//
//
// @Override
// public String toString() {
// return "business.order.CustomerOrder[customerOrderId=" + customerOrderId + "]";
// }
//
// }
//
// Path: src/main/java/viewmodel/admin/BaseAdminViewModel.java
// public class BaseAdminViewModel {
//
// // The relative path to product images
// // private static final String PRODUCT_IMAGE_PATH = "/img/products/";
// private static final String PRODUCT_IMAGE_PATH = BaseViewModel.PRODUCT_IMAGE_PATH;
//
// // Every view model knows the request and session
// protected HttpServletRequest request;
// protected HttpSession session;
//
// // All customer/order pages need the following service objects
// protected CustomerService customerService;
// protected CustomerOrderService customerOrderService;
//
// // Delivery surcharge
// protected int deliverySurcharge;
//
// @SuppressWarnings("unchecked")
// public BaseAdminViewModel(HttpServletRequest request) {
// ApplicationContext applicationContext = ApplicationContext.INSTANCE;
// customerService = applicationContext.getCustomerService();
// customerOrderService = applicationContext.getCustomerOrderService();
//
// this.request = request;
// this.session = request.getSession(true);
// this.deliverySurcharge = Integer.valueOf(request.getServletContext().getInitParameter("deliverySurcharge"));
// }
//
// public HttpSession getSession() {
// return session;
// }
//
// public CustomerService getCustomerService() {
// return customerService;
// }
//
// public CustomerOrderService getCustomerOrderService() {
// return customerOrderService;
// }
//
// public String getProductImagePath() {
// return PRODUCT_IMAGE_PATH;
// }
//
// public int getDeliverySurcharge() {
// return deliverySurcharge;
// }
//
// }
// Path: src/main/java/viewmodel/admin/AdminCustomerViewModel.java
import business.customer.Customer;
import business.order.CustomerOrder;
import viewmodel.BaseAdminViewModel;
import javax.servlet.http.HttpServletRequest;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel.admin;
public class AdminCustomerViewModel extends BaseAdminViewModel {
private String customerId;
|
private Customer customerRecord;
|
nowucca/SimpleAffableBean
|
src/main/java/viewmodel/admin/AdminCustomerViewModel.java
|
// Path: src/main/java/business/customer/Customer.java
// public class Customer {
//
// private long customerId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private String address;
//
// private String cityRegion;
//
// private String ccNumber;
//
// public Customer(long customerId, String name, String email,
// String phone, String address, String cityRegion, String ccNumber) {
// this.customerId = customerId;
// this.name = name;
// this.email = email;
// this.phone = phone;
// this.address = address;
// this.cityRegion = cityRegion;
// this.ccNumber = ccNumber;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getCityRegion() {
// return cityRegion;
// }
//
// public String getCcNumber() {
// return ccNumber;
// }
//
// @Override
// public String toString() {
// return "business.customer.Customer[customerId=" + customerId + "]";
// }
//
// }
//
// Path: src/main/java/business/order/CustomerOrder.java
// public class CustomerOrder {
//
// private long customerOrderId;
// private long customerId;
// private int amount;
// private Date dateCreated;
// private int confirmationNumber;
//
//
// public CustomerOrder() {
// }
//
//
// public CustomerOrder(long customerOrderId, long customerId, int amount, Date dateCreated, int confirmationNumber) {
// this.customerOrderId = customerOrderId;
// this.customerId = customerId;
// this.amount = amount;
// this.dateCreated = dateCreated;
// this.confirmationNumber = confirmationNumber;
// }
//
// public long getCustomerOrderId() {
// return customerOrderId;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public int getAmount() {
// return amount;
// }
//
// public Date getDateCreated() {
// return dateCreated;
// }
//
// public int getConfirmationNumber() {
// return confirmationNumber;
// }
//
//
// @Override
// public String toString() {
// return "business.order.CustomerOrder[customerOrderId=" + customerOrderId + "]";
// }
//
// }
//
// Path: src/main/java/viewmodel/admin/BaseAdminViewModel.java
// public class BaseAdminViewModel {
//
// // The relative path to product images
// // private static final String PRODUCT_IMAGE_PATH = "/img/products/";
// private static final String PRODUCT_IMAGE_PATH = BaseViewModel.PRODUCT_IMAGE_PATH;
//
// // Every view model knows the request and session
// protected HttpServletRequest request;
// protected HttpSession session;
//
// // All customer/order pages need the following service objects
// protected CustomerService customerService;
// protected CustomerOrderService customerOrderService;
//
// // Delivery surcharge
// protected int deliverySurcharge;
//
// @SuppressWarnings("unchecked")
// public BaseAdminViewModel(HttpServletRequest request) {
// ApplicationContext applicationContext = ApplicationContext.INSTANCE;
// customerService = applicationContext.getCustomerService();
// customerOrderService = applicationContext.getCustomerOrderService();
//
// this.request = request;
// this.session = request.getSession(true);
// this.deliverySurcharge = Integer.valueOf(request.getServletContext().getInitParameter("deliverySurcharge"));
// }
//
// public HttpSession getSession() {
// return session;
// }
//
// public CustomerService getCustomerService() {
// return customerService;
// }
//
// public CustomerOrderService getCustomerOrderService() {
// return customerOrderService;
// }
//
// public String getProductImagePath() {
// return PRODUCT_IMAGE_PATH;
// }
//
// public int getDeliverySurcharge() {
// return deliverySurcharge;
// }
//
// }
|
import business.customer.Customer;
import business.order.CustomerOrder;
import viewmodel.BaseAdminViewModel;
import javax.servlet.http.HttpServletRequest;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel.admin;
public class AdminCustomerViewModel extends BaseAdminViewModel {
private String customerId;
private Customer customerRecord;
|
// Path: src/main/java/business/customer/Customer.java
// public class Customer {
//
// private long customerId;
//
// private String name;
//
// private String email;
//
// private String phone;
//
// private String address;
//
// private String cityRegion;
//
// private String ccNumber;
//
// public Customer(long customerId, String name, String email,
// String phone, String address, String cityRegion, String ccNumber) {
// this.customerId = customerId;
// this.name = name;
// this.email = email;
// this.phone = phone;
// this.address = address;
// this.cityRegion = cityRegion;
// this.ccNumber = ccNumber;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public String getName() {
// return name;
// }
//
// public String getEmail() {
// return email;
// }
//
// public String getPhone() {
// return phone;
// }
//
// public String getAddress() {
// return address;
// }
//
// public String getCityRegion() {
// return cityRegion;
// }
//
// public String getCcNumber() {
// return ccNumber;
// }
//
// @Override
// public String toString() {
// return "business.customer.Customer[customerId=" + customerId + "]";
// }
//
// }
//
// Path: src/main/java/business/order/CustomerOrder.java
// public class CustomerOrder {
//
// private long customerOrderId;
// private long customerId;
// private int amount;
// private Date dateCreated;
// private int confirmationNumber;
//
//
// public CustomerOrder() {
// }
//
//
// public CustomerOrder(long customerOrderId, long customerId, int amount, Date dateCreated, int confirmationNumber) {
// this.customerOrderId = customerOrderId;
// this.customerId = customerId;
// this.amount = amount;
// this.dateCreated = dateCreated;
// this.confirmationNumber = confirmationNumber;
// }
//
// public long getCustomerOrderId() {
// return customerOrderId;
// }
//
// public long getCustomerId() {
// return customerId;
// }
//
// public int getAmount() {
// return amount;
// }
//
// public Date getDateCreated() {
// return dateCreated;
// }
//
// public int getConfirmationNumber() {
// return confirmationNumber;
// }
//
//
// @Override
// public String toString() {
// return "business.order.CustomerOrder[customerOrderId=" + customerOrderId + "]";
// }
//
// }
//
// Path: src/main/java/viewmodel/admin/BaseAdminViewModel.java
// public class BaseAdminViewModel {
//
// // The relative path to product images
// // private static final String PRODUCT_IMAGE_PATH = "/img/products/";
// private static final String PRODUCT_IMAGE_PATH = BaseViewModel.PRODUCT_IMAGE_PATH;
//
// // Every view model knows the request and session
// protected HttpServletRequest request;
// protected HttpSession session;
//
// // All customer/order pages need the following service objects
// protected CustomerService customerService;
// protected CustomerOrderService customerOrderService;
//
// // Delivery surcharge
// protected int deliverySurcharge;
//
// @SuppressWarnings("unchecked")
// public BaseAdminViewModel(HttpServletRequest request) {
// ApplicationContext applicationContext = ApplicationContext.INSTANCE;
// customerService = applicationContext.getCustomerService();
// customerOrderService = applicationContext.getCustomerOrderService();
//
// this.request = request;
// this.session = request.getSession(true);
// this.deliverySurcharge = Integer.valueOf(request.getServletContext().getInitParameter("deliverySurcharge"));
// }
//
// public HttpSession getSession() {
// return session;
// }
//
// public CustomerService getCustomerService() {
// return customerService;
// }
//
// public CustomerOrderService getCustomerOrderService() {
// return customerOrderService;
// }
//
// public String getProductImagePath() {
// return PRODUCT_IMAGE_PATH;
// }
//
// public int getDeliverySurcharge() {
// return deliverySurcharge;
// }
//
// }
// Path: src/main/java/viewmodel/admin/AdminCustomerViewModel.java
import business.customer.Customer;
import business.order.CustomerOrder;
import viewmodel.BaseAdminViewModel;
import javax.servlet.http.HttpServletRequest;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package viewmodel.admin;
public class AdminCustomerViewModel extends BaseAdminViewModel {
private String customerId;
private Customer customerRecord;
|
private CustomerOrder order;
|
nowucca/SimpleAffableBean
|
src/main/java/business/category/CategoryDaoGuava.java
|
// Path: src/main/java/business/GuavaUtils.java
// public final class GuavaUtils {
//
// private GuavaUtils() {
// }
//
// public static <K,V> LoadingCache<K,V> makeCache(com.google.common.base.Function<K,V> cacheLoadFunction) {
// return CacheBuilder.newBuilder().
// expireAfterWrite(1, TimeUnit.HOURS).
// concurrencyLevel(8).
// recordStats().
// maximumSize(1000).
// initialCapacity(100).
// build(CacheLoader.from(cacheLoadFunction));
// }
//
//
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public class SimpleAffableDbException extends RuntimeException {
//
// public SimpleAffableDbException(String message) {
// super(message);
// }
//
// public SimpleAffableDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public static class SimpleAffableConnectionDbException extends SimpleAffableDbException {
// public SimpleAffableConnectionDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// }
|
import business.GuavaUtils;
import business.SimpleAffableDbException;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Maps;
import java.util.Collection;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.category;
/**
*/
public class CategoryDaoGuava implements CategoryDao {
private CategoryDao origin;
private LoadingCache<Long, Category> cache;
@SuppressWarnings("ConstantConditions")
public CategoryDaoGuava(CategoryDao originCategoryDao) {
this.origin = originCategoryDao;
|
// Path: src/main/java/business/GuavaUtils.java
// public final class GuavaUtils {
//
// private GuavaUtils() {
// }
//
// public static <K,V> LoadingCache<K,V> makeCache(com.google.common.base.Function<K,V> cacheLoadFunction) {
// return CacheBuilder.newBuilder().
// expireAfterWrite(1, TimeUnit.HOURS).
// concurrencyLevel(8).
// recordStats().
// maximumSize(1000).
// initialCapacity(100).
// build(CacheLoader.from(cacheLoadFunction));
// }
//
//
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public class SimpleAffableDbException extends RuntimeException {
//
// public SimpleAffableDbException(String message) {
// super(message);
// }
//
// public SimpleAffableDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public static class SimpleAffableConnectionDbException extends SimpleAffableDbException {
// public SimpleAffableConnectionDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// }
// Path: src/main/java/business/category/CategoryDaoGuava.java
import business.GuavaUtils;
import business.SimpleAffableDbException;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Maps;
import java.util.Collection;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.category;
/**
*/
public class CategoryDaoGuava implements CategoryDao {
private CategoryDao origin;
private LoadingCache<Long, Category> cache;
@SuppressWarnings("ConstantConditions")
public CategoryDaoGuava(CategoryDao originCategoryDao) {
this.origin = originCategoryDao;
|
cache = GuavaUtils.makeCache((k)->origin.findByCategoryId(k));
|
nowucca/SimpleAffableBean
|
src/main/java/business/category/CategoryDaoGuava.java
|
// Path: src/main/java/business/GuavaUtils.java
// public final class GuavaUtils {
//
// private GuavaUtils() {
// }
//
// public static <K,V> LoadingCache<K,V> makeCache(com.google.common.base.Function<K,V> cacheLoadFunction) {
// return CacheBuilder.newBuilder().
// expireAfterWrite(1, TimeUnit.HOURS).
// concurrencyLevel(8).
// recordStats().
// maximumSize(1000).
// initialCapacity(100).
// build(CacheLoader.from(cacheLoadFunction));
// }
//
//
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public class SimpleAffableDbException extends RuntimeException {
//
// public SimpleAffableDbException(String message) {
// super(message);
// }
//
// public SimpleAffableDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public static class SimpleAffableConnectionDbException extends SimpleAffableDbException {
// public SimpleAffableConnectionDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// }
|
import business.GuavaUtils;
import business.SimpleAffableDbException;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Maps;
import java.util.Collection;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.category;
/**
*/
public class CategoryDaoGuava implements CategoryDao {
private CategoryDao origin;
private LoadingCache<Long, Category> cache;
@SuppressWarnings("ConstantConditions")
public CategoryDaoGuava(CategoryDao originCategoryDao) {
this.origin = originCategoryDao;
cache = GuavaUtils.makeCache((k)->origin.findByCategoryId(k));
bulkload();
}
public void bulkload() {
// Bulk-fill the cache at startup time and periodically
cache.putAll(Maps.uniqueIndex(origin.findAll(), Category::getCategoryId));
}
@Override
public Category findByCategoryId(long categoryId) {
try {
return cache.get(categoryId);
} catch (Exception e) {
|
// Path: src/main/java/business/GuavaUtils.java
// public final class GuavaUtils {
//
// private GuavaUtils() {
// }
//
// public static <K,V> LoadingCache<K,V> makeCache(com.google.common.base.Function<K,V> cacheLoadFunction) {
// return CacheBuilder.newBuilder().
// expireAfterWrite(1, TimeUnit.HOURS).
// concurrencyLevel(8).
// recordStats().
// maximumSize(1000).
// initialCapacity(100).
// build(CacheLoader.from(cacheLoadFunction));
// }
//
//
// }
//
// Path: src/main/java/business/SimpleAffableDbException.java
// public class SimpleAffableDbException extends RuntimeException {
//
// public SimpleAffableDbException(String message) {
// super(message);
// }
//
// public SimpleAffableDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// public static class SimpleAffableConnectionDbException extends SimpleAffableDbException {
// public SimpleAffableConnectionDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// public static class SimpleAffableQueryDbException extends SimpleAffableDbException {
// public SimpleAffableQueryDbException(String message) {
// super(message);
// }
//
// public SimpleAffableQueryDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// public static class SimpleAffableUpdateDbException extends SimpleAffableDbException {
// public SimpleAffableUpdateDbException(String message) {
// super(message);
// }
//
// public SimpleAffableUpdateDbException(String message, Throwable cause) {
// super(message, cause);
// }
//
// }
// }
// Path: src/main/java/business/category/CategoryDaoGuava.java
import business.GuavaUtils;
import business.SimpleAffableDbException;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Maps;
import java.util.Collection;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business.category;
/**
*/
public class CategoryDaoGuava implements CategoryDao {
private CategoryDao origin;
private LoadingCache<Long, Category> cache;
@SuppressWarnings("ConstantConditions")
public CategoryDaoGuava(CategoryDao originCategoryDao) {
this.origin = originCategoryDao;
cache = GuavaUtils.makeCache((k)->origin.findByCategoryId(k));
bulkload();
}
public void bulkload() {
// Bulk-fill the cache at startup time and periodically
cache.putAll(Maps.uniqueIndex(origin.findAll(), Category::getCategoryId));
}
@Override
public Category findByCategoryId(long categoryId) {
try {
return cache.get(categoryId);
} catch (Exception e) {
|
throw new SimpleAffableDbException("Encountered problem loading category id "+categoryId+" into cache", e);
|
nowucca/SimpleAffableBean
|
src/main/java/controller/admin/AdminCustomerServlet.java
|
// Path: src/main/java/viewmodel/admin/AdminCustomerViewModel.java
// public class AdminCustomerViewModel extends BaseAdminViewModel {
//
// private String customerId;
// private Customer customerRecord;
// private CustomerOrder order;
//
// public AdminCustomerViewModel(HttpServletRequest request) {
// super(request);
//
// this.customerId = request.getPathInfo().split("/")[1];
// this.customerRecord = customerService.findByCustomerId(Integer.parseInt(customerId));
// this.order = customerOrderService.findByCustomerId(Integer.parseInt(customerId));
// }
//
// public Customer getCustomerRecord() {
// return customerRecord;
// }
//
// public CustomerOrder getOrder() {
// return order;
// }
//
// }
|
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import viewmodel.admin.AdminCustomerViewModel;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller.admin;
/**
*
*/
@WebServlet(name = "AdminCustomerServlet",
urlPatterns = {"/admin/customer/*"})
@ServletSecurity(
@HttpConstraint(transportGuarantee = TransportGuarantee.CONFIDENTIAL,
rolesAllowed = {"simpleAffableBeanAdmin"})
)
public class AdminCustomerServlet extends AdminServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
|
// Path: src/main/java/viewmodel/admin/AdminCustomerViewModel.java
// public class AdminCustomerViewModel extends BaseAdminViewModel {
//
// private String customerId;
// private Customer customerRecord;
// private CustomerOrder order;
//
// public AdminCustomerViewModel(HttpServletRequest request) {
// super(request);
//
// this.customerId = request.getPathInfo().split("/")[1];
// this.customerRecord = customerService.findByCustomerId(Integer.parseInt(customerId));
// this.order = customerOrderService.findByCustomerId(Integer.parseInt(customerId));
// }
//
// public Customer getCustomerRecord() {
// return customerRecord;
// }
//
// public CustomerOrder getOrder() {
// return order;
// }
//
// }
// Path: src/main/java/controller/admin/AdminCustomerServlet.java
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.HttpConstraint;
import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import viewmodel.admin.AdminCustomerViewModel;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller.admin;
/**
*
*/
@WebServlet(name = "AdminCustomerServlet",
urlPatterns = {"/admin/customer/*"})
@ServletSecurity(
@HttpConstraint(transportGuarantee = TransportGuarantee.CONFIDENTIAL,
rolesAllowed = {"simpleAffableBeanAdmin"})
)
public class AdminCustomerServlet extends AdminServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
|
request.setAttribute("p", new AdminCustomerViewModel(request));
|
nowucca/SimpleAffableBean
|
src/main/java/controller/HomepageServlet.java
|
// Path: src/main/java/viewmodel/HomepageViewModel.java
// @SuppressWarnings("unchecked")
// public class HomepageViewModel extends BaseViewModel {
//
// public HomepageViewModel(HttpServletRequest request) {
// super(request);
// }
//
// }
|
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import viewmodel.HomepageViewModel;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller;
/**
*
*/
@WebServlet(name = "Homepage",
urlPatterns = {"/home"})
public class HomepageServlet extends SimpleAffableBeanServlet {
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// use RequestDispatcher to forward request internally
|
// Path: src/main/java/viewmodel/HomepageViewModel.java
// @SuppressWarnings("unchecked")
// public class HomepageViewModel extends BaseViewModel {
//
// public HomepageViewModel(HttpServletRequest request) {
// super(request);
// }
//
// }
// Path: src/main/java/controller/HomepageServlet.java
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import viewmodel.HomepageViewModel;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package controller;
/**
*
*/
@WebServlet(name = "Homepage",
urlPatterns = {"/home"})
public class HomepageServlet extends SimpleAffableBeanServlet {
/**
* Handles the HTTP <code>GET</code> method.
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// use RequestDispatcher to forward request internally
|
request.setAttribute("p", new HomepageViewModel(request));
|
nowucca/SimpleAffableBean
|
src/main/java/business/JdbcUtils.java
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableConnectionDbException extends SimpleAffableDbException {
// public SimpleAffableConnectionDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
|
import business.SimpleAffableDbException.SimpleAffableConnectionDbException;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
|
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business;
/**
*/
public final class JdbcUtils {
private JdbcUtils() {
}
static final String JDBC_SIMPLEAFFABLEBEAN = "jdbc/simpleaffablebean";
private static DataSource dataSource;
public static Connection getConnection() {
if (dataSource == null) {
dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
}
try {
return dataSource.getConnection();
} catch (SQLException e) {
|
// Path: src/main/java/business/SimpleAffableDbException.java
// public static class SimpleAffableConnectionDbException extends SimpleAffableDbException {
// public SimpleAffableConnectionDbException(String message, Throwable cause) {
// super(message, cause);
// }
// }
// Path: src/main/java/business/JdbcUtils.java
import business.SimpleAffableDbException.SimpleAffableConnectionDbException;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
/**
* BSD 3-Clause License
*
* Copyright (C) 2018 Steven Atkinson <[email protected]>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package business;
/**
*/
public final class JdbcUtils {
private JdbcUtils() {
}
static final String JDBC_SIMPLEAFFABLEBEAN = "jdbc/simpleaffablebean";
private static DataSource dataSource;
public static Connection getConnection() {
if (dataSource == null) {
dataSource = getDataSource(JDBC_SIMPLEAFFABLEBEAN);
}
try {
return dataSource.getConnection();
} catch (SQLException e) {
|
throw new SimpleAffableConnectionDbException("Encountered a SQL issue getting a connection", e);
|
aolshevskiy/songo
|
src/main/java/songo/model/streams/LocalStream.java
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.base.Throwables;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import songo.vk.Audio;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
|
package songo.model.streams;
public class LocalStream implements Stream {
private final RandomAccessFile file;
@Inject
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/model/streams/LocalStream.java
import com.google.common.base.Throwables;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import songo.vk.Audio;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
package songo.model.streams;
public class LocalStream implements Stream {
private final RandomAccessFile file;
@Inject
|
LocalStream(StreamUtil util, @Assisted Audio track) {
|
aolshevskiy/songo
|
src/main/java/songo/model/Player.java
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import songo.annotation.GlobalBus;
import songo.vk.Audio;
|
package songo.model;
@Singleton
public class Player {
private final EventBus bus;
private State state = State.STOPPED;
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/model/Player.java
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import songo.annotation.GlobalBus;
import songo.vk.Audio;
package songo.model;
@Singleton
public class Player {
private final EventBus bus;
private State state = State.STOPPED;
|
private Provider<Audio> audio;
|
aolshevskiy/songo
|
src/main/java/songo/model/streams/StreamUtil.java
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.inject.Inject;
import songo.annotation.RunningWindows;
import songo.vk.Audio;
import java.io.File;
import static songo.Constants.HOME_DIR;
|
package songo.model.streams;
public class StreamUtil {
private final File cacheDir = new File(HOME_DIR, "cache");
private final boolean runningWindows;
@Inject
StreamUtil(@RunningWindows Boolean runningWindows) {
this.runningWindows = runningWindows;
}
private static String escapeForWindows(String input) {
return input.replace("\"", "").trim();
}
private static String escapeForNonWindows(String input) {
return input.replace("/", "");
}
private String fixFilename(String input) {
if(runningWindows)
return escapeForWindows(input);
return escapeForNonWindows(input);
}
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/model/streams/StreamUtil.java
import com.google.inject.Inject;
import songo.annotation.RunningWindows;
import songo.vk.Audio;
import java.io.File;
import static songo.Constants.HOME_DIR;
package songo.model.streams;
public class StreamUtil {
private final File cacheDir = new File(HOME_DIR, "cache");
private final boolean runningWindows;
@Inject
StreamUtil(@RunningWindows Boolean runningWindows) {
this.runningWindows = runningWindows;
}
private static String escapeForWindows(String input) {
return input.replace("\"", "").trim();
}
private static String escapeForNonWindows(String input) {
return input.replace("/", "");
}
private String fixFilename(String input) {
if(runningWindows)
return escapeForWindows(input);
return escapeForNonWindows(input);
}
|
public File getTrackFile(Audio track) {
|
aolshevskiy/songo
|
src/main/java/songo/model/streams/StreamProvider.java
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import songo.vk.Audio;
|
package songo.model.streams;
@Singleton
public class StreamProvider implements Provider<Stream> {
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/model/streams/StreamProvider.java
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
import songo.vk.Audio;
package songo.model.streams;
@Singleton
public class StreamProvider implements Provider<Stream> {
|
private final Provider<Audio> audio;
|
aolshevskiy/songo
|
src/main/java/songo/model/streams/RemoteStream.java
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.base.Throwables;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.ning.http.client.*;
import org.slf4j.Logger;
import songo.annotation.BackgroundExecutor;
import songo.logging.InjectLogger;
import songo.vk.Audio;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.concurrent.ExecutorService;
|
package songo.model.streams;
public class RemoteStream implements Stream {
private final AsyncHttpClient client;
private final StreamFactory factory;
private final StreamManager manager;
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/model/streams/RemoteStream.java
import com.google.common.base.Throwables;
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
import com.ning.http.client.*;
import org.slf4j.Logger;
import songo.annotation.BackgroundExecutor;
import songo.logging.InjectLogger;
import songo.vk.Audio;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;
import java.util.concurrent.ExecutorService;
package songo.model.streams;
public class RemoteStream implements Stream {
private final AsyncHttpClient client;
private final StreamFactory factory;
private final StreamManager manager;
|
private final Audio track;
|
aolshevskiy/songo
|
src/main/java/songo/model/Playlist.java
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.servlet.SessionScoped;
import songo.annotation.GlobalBus;
import songo.vk.Audio;
import java.util.ArrayList;
import java.util.List;
|
package songo.model;
@SessionScoped
public class Playlist {
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/model/Playlist.java
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Lists;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.servlet.SessionScoped;
import songo.annotation.GlobalBus;
import songo.vk.Audio;
import java.util.ArrayList;
import java.util.List;
package songo.model;
@SessionScoped
public class Playlist {
|
private List<Audio> tracks = ImmutableList.of();
|
aolshevskiy/songo
|
src/main/java/songo/controller/MainController.java
|
// Path: src/main/java/songo/view/MainView.java
// @SessionScoped
// public class MainView implements View {
// private final Shell shell;
// private final SWTUtil util;
// private final TabItem searchTab;
// private final TabItem playlistTab;
// private final ShellAdapter hideOnClose;
//
// public TabItem getSearchTab() {
// return searchTab;
// }
//
// public TabItem getPlaylistTab() {
// return playlistTab;
// }
//
// @Inject
// MainView(final Shell shell, SWTUtil util, TrayView trayView, @SessionBus EventBus bus) {
// this.shell = shell;
// this.util = util;
// bus.register(this);
// hideOnClose = new ShellAdapter() {
// @Override
// public void shellClosed(ShellEvent shellEvent) {
// shell.setVisible(false);
// shellEvent.doit = false;
// }
// };
// shell.addShellListener(hideOnClose);
// shell.setText("Songo");
// shell.setLayout(new GridLayout());
// TabFolder tabs = new TabFolder(shell, SWT.NONE);
// tabs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// playlistTab = new TabItem(tabs, SWT.NONE);
// playlistTab.setText("Playlist");
// searchTab = new TabItem(tabs, SWT.NONE);
// searchTab.setText("Search");
// tabs.setSelection(1);
// trayView.setShell(shell);
// }
//
// @Subscribe
// public void restore(TrayView.Restore e) {
// shell.setVisible(!shell.getVisible());
// }
//
// @Subscribe
// public void close(TrayView.Exit e) {
// shell.removeShellListener(hideOnClose);
// util.exitOnClose(shell);
// shell.close();
// }
//
// @Override
// public Shell getShell() {
// return shell;
// }
// }
//
// Path: src/main/java/songo/view/View.java
// public interface View {
// Shell getShell();
// }
|
import com.google.inject.Inject;
import songo.view.MainView;
import songo.view.View;
|
package songo.controller;
public class MainController implements Controller {
private final MainView view;
@Inject
MainController(MainView view, SearchController searchController, PlaylistController playlistController,
PlayerController playerController) {
this.view = view;
}
@Override
|
// Path: src/main/java/songo/view/MainView.java
// @SessionScoped
// public class MainView implements View {
// private final Shell shell;
// private final SWTUtil util;
// private final TabItem searchTab;
// private final TabItem playlistTab;
// private final ShellAdapter hideOnClose;
//
// public TabItem getSearchTab() {
// return searchTab;
// }
//
// public TabItem getPlaylistTab() {
// return playlistTab;
// }
//
// @Inject
// MainView(final Shell shell, SWTUtil util, TrayView trayView, @SessionBus EventBus bus) {
// this.shell = shell;
// this.util = util;
// bus.register(this);
// hideOnClose = new ShellAdapter() {
// @Override
// public void shellClosed(ShellEvent shellEvent) {
// shell.setVisible(false);
// shellEvent.doit = false;
// }
// };
// shell.addShellListener(hideOnClose);
// shell.setText("Songo");
// shell.setLayout(new GridLayout());
// TabFolder tabs = new TabFolder(shell, SWT.NONE);
// tabs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// playlistTab = new TabItem(tabs, SWT.NONE);
// playlistTab.setText("Playlist");
// searchTab = new TabItem(tabs, SWT.NONE);
// searchTab.setText("Search");
// tabs.setSelection(1);
// trayView.setShell(shell);
// }
//
// @Subscribe
// public void restore(TrayView.Restore e) {
// shell.setVisible(!shell.getVisible());
// }
//
// @Subscribe
// public void close(TrayView.Exit e) {
// shell.removeShellListener(hideOnClose);
// util.exitOnClose(shell);
// shell.close();
// }
//
// @Override
// public Shell getShell() {
// return shell;
// }
// }
//
// Path: src/main/java/songo/view/View.java
// public interface View {
// Shell getShell();
// }
// Path: src/main/java/songo/controller/MainController.java
import com.google.inject.Inject;
import songo.view.MainView;
import songo.view.View;
package songo.controller;
public class MainController implements Controller {
private final MainView view;
@Inject
MainController(MainView view, SearchController searchController, PlaylistController playlistController,
PlayerController playerController) {
this.view = view;
}
@Override
|
public View getView() {
|
aolshevskiy/songo
|
src/main/java/songo/view/SearchView.java
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.SearchTab;
import songo.annotation.SessionBus;
import songo.vk.Audio;
import java.util.List;
|
package songo.view;
public class SearchView extends Composite {
private final Text searchField;
private final Table table;
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/view/SearchView.java
import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.SearchTab;
import songo.annotation.SessionBus;
import songo.vk.Audio;
import java.util.List;
package songo.view;
public class SearchView extends Composite {
private final Text searchField;
private final Table table;
|
private List<Audio> results = ImmutableList.of();
|
aolshevskiy/songo
|
src/main/java/songo/view/SearchView.java
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.SearchTab;
import songo.annotation.SessionBus;
import songo.vk.Audio;
import java.util.List;
|
add.setText("Add");
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
bus.post(new Add());
}
});
MenuItem replace = new MenuItem(menu, SWT.NONE);
replace.setText("Replace");
replace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
bus.post(new Replace());
}
});
table.setMenu(menu);
}
public String getSearchQuery() {
return searchField.getText();
}
public void setResults(List<Audio> results) {
this.results = results;
table.setRedraw(false);
table.removeAll();
for(Audio a : results) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[]{a.artist, a.title});
}
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/view/SearchView.java
import com.google.common.collect.ImmutableList;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.SearchTab;
import songo.annotation.SessionBus;
import songo.vk.Audio;
import java.util.List;
add.setText("Add");
add.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
bus.post(new Add());
}
});
MenuItem replace = new MenuItem(menu, SWT.NONE);
replace.setText("Replace");
replace.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
bus.post(new Replace());
}
});
table.setMenu(menu);
}
public String getSearchQuery() {
return searchField.getText();
}
public void setResults(List<Audio> results) {
this.results = results;
table.setRedraw(false);
table.removeAll();
for(Audio a : results) {
TableItem item = new TableItem(table, SWT.NONE);
item.setText(new String[]{a.artist, a.title});
}
|
TableUtil.packColumns(table);
|
aolshevskiy/songo
|
src/main/java/songo/view/TrayView.java
|
// Path: src/main/java/songo/ResourceUtil.java
// public class ResourceUtil {
// private ResourceUtil() {
//
// }
// public static InputStream iconStream(String name) {
// return ResourceUtil.class.getResourceAsStream("/songo/icons/dark/" + name + ".png");
// }
// }
//
// Path: src/main/java/songo/ResourceUtil.java
// public static InputStream iconStream(String name) {
// return ResourceUtil.class.getResourceAsStream("/songo/icons/dark/" + name + ".png");
// }
|
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;
import songo.ResourceUtil;
import songo.annotation.SessionBus;
import static songo.ResourceUtil.iconStream;
|
package songo.view;
public class TrayView {
private final TrayItem item;
private final EventBus bus;
@Inject
TrayView(Display display, @SessionBus final EventBus bus) {
this.bus = bus;
item = new TrayItem(display.getSystemTray(), SWT.NONE);
|
// Path: src/main/java/songo/ResourceUtil.java
// public class ResourceUtil {
// private ResourceUtil() {
//
// }
// public static InputStream iconStream(String name) {
// return ResourceUtil.class.getResourceAsStream("/songo/icons/dark/" + name + ".png");
// }
// }
//
// Path: src/main/java/songo/ResourceUtil.java
// public static InputStream iconStream(String name) {
// return ResourceUtil.class.getResourceAsStream("/songo/icons/dark/" + name + ".png");
// }
// Path: src/main/java/songo/view/TrayView.java
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MenuDetectEvent;
import org.eclipse.swt.events.MenuDetectListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.*;
import songo.ResourceUtil;
import songo.annotation.SessionBus;
import static songo.ResourceUtil.iconStream;
package songo.view;
public class TrayView {
private final TrayItem item;
private final EventBus bus;
@Inject
TrayView(Display display, @SessionBus final EventBus bus) {
this.bus = bus;
item = new TrayItem(display.getSystemTray(), SWT.NONE);
|
item.setImage(new Image(display, iconStream("tray")));
|
aolshevskiy/songo
|
src/main/java/songo/model/streams/StreamManager.java
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.inject.Singleton;
import songo.vk.Audio;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
|
package songo.model.streams;
@Singleton
public class StreamManager {
|
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/model/streams/StreamManager.java
import com.google.inject.Singleton;
import songo.vk.Audio;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
package songo.model.streams;
@Singleton
public class StreamManager {
|
private ConcurrentMap<Audio, RemoteStream> streams = new ConcurrentHashMap<Audio, RemoteStream>();
|
aolshevskiy/songo
|
src/main/java/songo/view/AuthDialog.java
|
// Path: src/main/java/songo/SWTUtil.java
// public class SWTUtil {
// private final SongoService service;
//
// @Inject
// SWTUtil(SongoService service) {
// this.service = service;
// }
//
// public void exitOnClose(Shell shell) {
// shell.addShellListener(new ShellAdapter() {
// @Override
// public void shellClosed(ShellEvent e) {
// service.stop();
// }
// });
// }
// }
|
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.servlet.SessionScoped;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.SWTUtil;
import songo.annotation.BrowserStyle;
import songo.annotation.SessionBus;
|
package songo.view;
@SessionScoped
public class AuthDialog implements View {
private final Shell shell;
private final Browser browser;
private static GridLayout gridLayout() {
return gridLayout(1);
}
private static GridLayout gridLayout(int cols) {
return new GridLayout(cols, false);
}
private static GridData horizontalFill() {
return new GridData(SWT.FILL, SWT.CENTER, true, false);
}
@Inject
|
// Path: src/main/java/songo/SWTUtil.java
// public class SWTUtil {
// private final SongoService service;
//
// @Inject
// SWTUtil(SongoService service) {
// this.service = service;
// }
//
// public void exitOnClose(Shell shell) {
// shell.addShellListener(new ShellAdapter() {
// @Override
// public void shellClosed(ShellEvent e) {
// service.stop();
// }
// });
// }
// }
// Path: src/main/java/songo/view/AuthDialog.java
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.servlet.SessionScoped;
import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.*;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.SWTUtil;
import songo.annotation.BrowserStyle;
import songo.annotation.SessionBus;
package songo.view;
@SessionScoped
public class AuthDialog implements View {
private final Shell shell;
private final Browser browser;
private static GridLayout gridLayout() {
return gridLayout(1);
}
private static GridLayout gridLayout(int cols) {
return new GridLayout(cols, false);
}
private static GridData horizontalFill() {
return new GridData(SWT.FILL, SWT.CENTER, true, false);
}
@Inject
|
AuthDialog(Shell shell, SWTUtil util, @BrowserStyle Integer browserStyle, @SessionBus final EventBus bus) {
|
aolshevskiy/songo
|
src/main/java/songo/view/PlaylistView.java
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/model/Playlist.java
// @SessionScoped
// public class Playlist {
// private List<Audio> tracks = ImmutableList.of();
// private int currentTrackIndex = -1;
// private final EventBus bus;
//
// public List<Audio> getTracks() {
// return tracks;
// }
//
// public void setTracks(List<Audio> tracks) {
// Audio track = getCurrentTrack();
// this.tracks = tracks;
// fixCurrentTrack(track);
// changed();
// }
//
// private void fixCurrentTrack(Audio track) {
// currentTrackIndex = -1;
// int i = 0;
// for(Audio t : tracks) {
// if(t == track) {
// currentTrackIndex = i;
// return;
// }
// i++;
// }
// }
//
// public Audio getCurrentTrack() {
// if(currentTrackIndex == -1)
// return null;
// return tracks.get(currentTrackIndex);
// }
//
// public int getCurrentTrackIndex() {
// return currentTrackIndex;
// }
//
// public void setCurrentTrackIndex(int currentTrackIndex) {
// this.currentTrackIndex = currentTrackIndex;
// changed();
// }
//
// @Inject
// Playlist(@GlobalBus EventBus bus) {
// this.bus = bus;
// }
//
// public void add(List<Audio> newTracks) {
// tracks = new ImmutableList.Builder<Audio>().addAll(tracks).addAll(newTracks).build();
// changed();
// }
//
// public void replace(List<Audio> selectedTracks) {
// tracks = selectedTracks;
// currentTrackIndex = -1;
// changed();
// }
//
// public void remove(int[] indices) {
// Audio current = getCurrentTrack();
// ArrayList<Audio> view = Lists.newArrayList(tracks);
// for(int i = indices.length - 1; i >= 0; i--)
// view.remove(indices[i]);
// tracks = ImmutableList.copyOf(view);
// fixCurrentTrack(current);
// changed();
// }
//
// private void changed() {
// bus.post(new Changed());
// }
//
// public static class Changed {
// private Changed() { }
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.GlobalBus;
import songo.annotation.PlaylistTab;
import songo.annotation.SessionBus;
import songo.model.Playlist;
import songo.vk.Audio;
|
package songo.view;
public class PlaylistView extends Composite {
private final Table table;
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/model/Playlist.java
// @SessionScoped
// public class Playlist {
// private List<Audio> tracks = ImmutableList.of();
// private int currentTrackIndex = -1;
// private final EventBus bus;
//
// public List<Audio> getTracks() {
// return tracks;
// }
//
// public void setTracks(List<Audio> tracks) {
// Audio track = getCurrentTrack();
// this.tracks = tracks;
// fixCurrentTrack(track);
// changed();
// }
//
// private void fixCurrentTrack(Audio track) {
// currentTrackIndex = -1;
// int i = 0;
// for(Audio t : tracks) {
// if(t == track) {
// currentTrackIndex = i;
// return;
// }
// i++;
// }
// }
//
// public Audio getCurrentTrack() {
// if(currentTrackIndex == -1)
// return null;
// return tracks.get(currentTrackIndex);
// }
//
// public int getCurrentTrackIndex() {
// return currentTrackIndex;
// }
//
// public void setCurrentTrackIndex(int currentTrackIndex) {
// this.currentTrackIndex = currentTrackIndex;
// changed();
// }
//
// @Inject
// Playlist(@GlobalBus EventBus bus) {
// this.bus = bus;
// }
//
// public void add(List<Audio> newTracks) {
// tracks = new ImmutableList.Builder<Audio>().addAll(tracks).addAll(newTracks).build();
// changed();
// }
//
// public void replace(List<Audio> selectedTracks) {
// tracks = selectedTracks;
// currentTrackIndex = -1;
// changed();
// }
//
// public void remove(int[] indices) {
// Audio current = getCurrentTrack();
// ArrayList<Audio> view = Lists.newArrayList(tracks);
// for(int i = indices.length - 1; i >= 0; i--)
// view.remove(indices[i]);
// tracks = ImmutableList.copyOf(view);
// fixCurrentTrack(current);
// changed();
// }
//
// private void changed() {
// bus.post(new Changed());
// }
//
// public static class Changed {
// private Changed() { }
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/view/PlaylistView.java
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.GlobalBus;
import songo.annotation.PlaylistTab;
import songo.annotation.SessionBus;
import songo.model.Playlist;
import songo.vk.Audio;
package songo.view;
public class PlaylistView extends Composite {
private final Table table;
|
private final Playlist playlist;
|
aolshevskiy/songo
|
src/main/java/songo/view/PlaylistView.java
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/model/Playlist.java
// @SessionScoped
// public class Playlist {
// private List<Audio> tracks = ImmutableList.of();
// private int currentTrackIndex = -1;
// private final EventBus bus;
//
// public List<Audio> getTracks() {
// return tracks;
// }
//
// public void setTracks(List<Audio> tracks) {
// Audio track = getCurrentTrack();
// this.tracks = tracks;
// fixCurrentTrack(track);
// changed();
// }
//
// private void fixCurrentTrack(Audio track) {
// currentTrackIndex = -1;
// int i = 0;
// for(Audio t : tracks) {
// if(t == track) {
// currentTrackIndex = i;
// return;
// }
// i++;
// }
// }
//
// public Audio getCurrentTrack() {
// if(currentTrackIndex == -1)
// return null;
// return tracks.get(currentTrackIndex);
// }
//
// public int getCurrentTrackIndex() {
// return currentTrackIndex;
// }
//
// public void setCurrentTrackIndex(int currentTrackIndex) {
// this.currentTrackIndex = currentTrackIndex;
// changed();
// }
//
// @Inject
// Playlist(@GlobalBus EventBus bus) {
// this.bus = bus;
// }
//
// public void add(List<Audio> newTracks) {
// tracks = new ImmutableList.Builder<Audio>().addAll(tracks).addAll(newTracks).build();
// changed();
// }
//
// public void replace(List<Audio> selectedTracks) {
// tracks = selectedTracks;
// currentTrackIndex = -1;
// changed();
// }
//
// public void remove(int[] indices) {
// Audio current = getCurrentTrack();
// ArrayList<Audio> view = Lists.newArrayList(tracks);
// for(int i = indices.length - 1; i >= 0; i--)
// view.remove(indices[i]);
// tracks = ImmutableList.copyOf(view);
// fixCurrentTrack(current);
// changed();
// }
//
// private void changed() {
// bus.post(new Changed());
// }
//
// public static class Changed {
// private Changed() { }
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.GlobalBus;
import songo.annotation.PlaylistTab;
import songo.annotation.SessionBus;
import songo.model.Playlist;
import songo.vk.Audio;
|
delete();
}
});
DragSource dragSource = new DragSource(table, DND.DROP_MOVE);
dragSource.setTransfer(new Transfer[]{TextTransfer.getInstance()});
dragSource.addDragListener(new DragSourceAdapter() {
@Override
public void dragSetData(DragSourceEvent event) {
event.data = "track";
}
});
final DropTarget dropTarget = new DropTarget(table, DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[]{TextTransfer.getInstance()});
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(DropTargetEvent event) {
for(TransferData t : event.dataTypes)
if(TextTransfer.getInstance().isSupportedType(t))
event.currentDataType = t;
}
@Override
public void dragOver(DropTargetEvent event) {
event.feedback = DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SCROLL;
}
@Override
public void drop(DropTargetEvent event) {
if(event.item == null)
return;
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/model/Playlist.java
// @SessionScoped
// public class Playlist {
// private List<Audio> tracks = ImmutableList.of();
// private int currentTrackIndex = -1;
// private final EventBus bus;
//
// public List<Audio> getTracks() {
// return tracks;
// }
//
// public void setTracks(List<Audio> tracks) {
// Audio track = getCurrentTrack();
// this.tracks = tracks;
// fixCurrentTrack(track);
// changed();
// }
//
// private void fixCurrentTrack(Audio track) {
// currentTrackIndex = -1;
// int i = 0;
// for(Audio t : tracks) {
// if(t == track) {
// currentTrackIndex = i;
// return;
// }
// i++;
// }
// }
//
// public Audio getCurrentTrack() {
// if(currentTrackIndex == -1)
// return null;
// return tracks.get(currentTrackIndex);
// }
//
// public int getCurrentTrackIndex() {
// return currentTrackIndex;
// }
//
// public void setCurrentTrackIndex(int currentTrackIndex) {
// this.currentTrackIndex = currentTrackIndex;
// changed();
// }
//
// @Inject
// Playlist(@GlobalBus EventBus bus) {
// this.bus = bus;
// }
//
// public void add(List<Audio> newTracks) {
// tracks = new ImmutableList.Builder<Audio>().addAll(tracks).addAll(newTracks).build();
// changed();
// }
//
// public void replace(List<Audio> selectedTracks) {
// tracks = selectedTracks;
// currentTrackIndex = -1;
// changed();
// }
//
// public void remove(int[] indices) {
// Audio current = getCurrentTrack();
// ArrayList<Audio> view = Lists.newArrayList(tracks);
// for(int i = indices.length - 1; i >= 0; i--)
// view.remove(indices[i]);
// tracks = ImmutableList.copyOf(view);
// fixCurrentTrack(current);
// changed();
// }
//
// private void changed() {
// bus.post(new Changed());
// }
//
// public static class Changed {
// private Changed() { }
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/view/PlaylistView.java
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.GlobalBus;
import songo.annotation.PlaylistTab;
import songo.annotation.SessionBus;
import songo.model.Playlist;
import songo.vk.Audio;
delete();
}
});
DragSource dragSource = new DragSource(table, DND.DROP_MOVE);
dragSource.setTransfer(new Transfer[]{TextTransfer.getInstance()});
dragSource.addDragListener(new DragSourceAdapter() {
@Override
public void dragSetData(DragSourceEvent event) {
event.data = "track";
}
});
final DropTarget dropTarget = new DropTarget(table, DND.DROP_MOVE);
dropTarget.setTransfer(new Transfer[]{TextTransfer.getInstance()});
dropTarget.addDropListener(new DropTargetAdapter() {
@Override
public void dragEnter(DropTargetEvent event) {
for(TransferData t : event.dataTypes)
if(TextTransfer.getInstance().isSupportedType(t))
event.currentDataType = t;
}
@Override
public void dragOver(DropTargetEvent event) {
event.feedback = DND.FEEDBACK_INSERT_BEFORE | DND.FEEDBACK_SCROLL;
}
@Override
public void drop(DropTargetEvent event) {
if(event.item == null)
return;
|
Audio track = (Audio) event.item.getData("track");
|
aolshevskiy/songo
|
src/main/java/songo/view/PlaylistView.java
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/model/Playlist.java
// @SessionScoped
// public class Playlist {
// private List<Audio> tracks = ImmutableList.of();
// private int currentTrackIndex = -1;
// private final EventBus bus;
//
// public List<Audio> getTracks() {
// return tracks;
// }
//
// public void setTracks(List<Audio> tracks) {
// Audio track = getCurrentTrack();
// this.tracks = tracks;
// fixCurrentTrack(track);
// changed();
// }
//
// private void fixCurrentTrack(Audio track) {
// currentTrackIndex = -1;
// int i = 0;
// for(Audio t : tracks) {
// if(t == track) {
// currentTrackIndex = i;
// return;
// }
// i++;
// }
// }
//
// public Audio getCurrentTrack() {
// if(currentTrackIndex == -1)
// return null;
// return tracks.get(currentTrackIndex);
// }
//
// public int getCurrentTrackIndex() {
// return currentTrackIndex;
// }
//
// public void setCurrentTrackIndex(int currentTrackIndex) {
// this.currentTrackIndex = currentTrackIndex;
// changed();
// }
//
// @Inject
// Playlist(@GlobalBus EventBus bus) {
// this.bus = bus;
// }
//
// public void add(List<Audio> newTracks) {
// tracks = new ImmutableList.Builder<Audio>().addAll(tracks).addAll(newTracks).build();
// changed();
// }
//
// public void replace(List<Audio> selectedTracks) {
// tracks = selectedTracks;
// currentTrackIndex = -1;
// changed();
// }
//
// public void remove(int[] indices) {
// Audio current = getCurrentTrack();
// ArrayList<Audio> view = Lists.newArrayList(tracks);
// for(int i = indices.length - 1; i >= 0; i--)
// view.remove(indices[i]);
// tracks = ImmutableList.copyOf(view);
// fixCurrentTrack(current);
// changed();
// }
//
// private void changed() {
// bus.post(new Changed());
// }
//
// public static class Changed {
// private Changed() { }
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
|
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.GlobalBus;
import songo.annotation.PlaylistTab;
import songo.annotation.SessionBus;
import songo.model.Playlist;
import songo.vk.Audio;
|
delete.setText("Remove");
delete.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
delete();
}
});
table.setMenu(menu);
updateTable();
}
private void delete() {
sessionBus.post(new Delete());
table.deselectAll();
}
public void updateTable() {
table.setRedraw(false);
int[] selection = table.getSelectionIndices();
table.setItemCount(playlist.getTracks().size());
int i = 0;
for(Audio track : playlist.getTracks()) {
TableItem item = table.getItem(i);
item.setFont(normalFont);
if(i == playlist.getCurrentTrackIndex())
item.setFont(boldFont);
item.setText(new String[]{track.artist, track.title});
item.setData("track", track);
i++;
}
|
// Path: src/main/java/songo/TableUtil.java
// public class TableUtil {
// public static void packColumns(Table table) {
// for(TableColumn column : table.getColumns())
// column.pack();
// }
// }
//
// Path: src/main/java/songo/model/Playlist.java
// @SessionScoped
// public class Playlist {
// private List<Audio> tracks = ImmutableList.of();
// private int currentTrackIndex = -1;
// private final EventBus bus;
//
// public List<Audio> getTracks() {
// return tracks;
// }
//
// public void setTracks(List<Audio> tracks) {
// Audio track = getCurrentTrack();
// this.tracks = tracks;
// fixCurrentTrack(track);
// changed();
// }
//
// private void fixCurrentTrack(Audio track) {
// currentTrackIndex = -1;
// int i = 0;
// for(Audio t : tracks) {
// if(t == track) {
// currentTrackIndex = i;
// return;
// }
// i++;
// }
// }
//
// public Audio getCurrentTrack() {
// if(currentTrackIndex == -1)
// return null;
// return tracks.get(currentTrackIndex);
// }
//
// public int getCurrentTrackIndex() {
// return currentTrackIndex;
// }
//
// public void setCurrentTrackIndex(int currentTrackIndex) {
// this.currentTrackIndex = currentTrackIndex;
// changed();
// }
//
// @Inject
// Playlist(@GlobalBus EventBus bus) {
// this.bus = bus;
// }
//
// public void add(List<Audio> newTracks) {
// tracks = new ImmutableList.Builder<Audio>().addAll(tracks).addAll(newTracks).build();
// changed();
// }
//
// public void replace(List<Audio> selectedTracks) {
// tracks = selectedTracks;
// currentTrackIndex = -1;
// changed();
// }
//
// public void remove(int[] indices) {
// Audio current = getCurrentTrack();
// ArrayList<Audio> view = Lists.newArrayList(tracks);
// for(int i = indices.length - 1; i >= 0; i--)
// view.remove(indices[i]);
// tracks = ImmutableList.copyOf(view);
// fixCurrentTrack(current);
// changed();
// }
//
// private void changed() {
// bus.post(new Changed());
// }
//
// public static class Changed {
// private Changed() { }
// }
// }
//
// Path: src/main/java/songo/vk/Audio.java
// public class Audio {
// public final String artist;
// public final String title;
// public final String url;
// public final int duration;
//
// Audio(String artist, String title, String url, int duration) {
// this.artist = artist;
// this.title = title;
// this.url = url;
// this.duration = duration;
// }
//
// @Override
// public int hashCode() {
// return Objects.hashCode(artist, title);
// }
//
// @Override
// public boolean equals(Object obj) {
// if(obj == null)
// return false;
// if(this == obj)
// return true;
// if(!(obj instanceof Audio))
// return false;
// Audio a = (Audio) obj;
// return artist.equals(a.artist) && title.equals(a.title);
// }
//
// @Override
// public String toString() {
// return Objects.toStringHelper(this)
// .add("artist", artist)
// .add("title", title)
// .add("url", url)
// .toString();
// }
// }
// Path: src/main/java/songo/view/PlaylistView.java
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import org.eclipse.swt.SWT;
import org.eclipse.swt.dnd.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.*;
import songo.TableUtil;
import songo.annotation.GlobalBus;
import songo.annotation.PlaylistTab;
import songo.annotation.SessionBus;
import songo.model.Playlist;
import songo.vk.Audio;
delete.setText("Remove");
delete.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
delete();
}
});
table.setMenu(menu);
updateTable();
}
private void delete() {
sessionBus.post(new Delete());
table.deselectAll();
}
public void updateTable() {
table.setRedraw(false);
int[] selection = table.getSelectionIndices();
table.setItemCount(playlist.getTracks().size());
int i = 0;
for(Audio track : playlist.getTracks()) {
TableItem item = table.getItem(i);
item.setFont(normalFont);
if(i == playlist.getCurrentTrackIndex())
item.setFont(boldFont);
item.setText(new String[]{track.artist, track.title});
item.setData("track", track);
i++;
}
|
TableUtil.packColumns(table);
|
aolshevskiy/songo
|
src/main/java/songo/view/MainView.java
|
// Path: src/main/java/songo/SWTUtil.java
// public class SWTUtil {
// private final SongoService service;
//
// @Inject
// SWTUtil(SongoService service) {
// this.service = service;
// }
//
// public void exitOnClose(Shell shell) {
// shell.addShellListener(new ShellAdapter() {
// @Override
// public void shellClosed(ShellEvent e) {
// service.stop();
// }
// });
// }
// }
|
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
import com.google.inject.servlet.SessionScoped;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import songo.SWTUtil;
import songo.annotation.SessionBus;
|
package songo.view;
@SessionScoped
public class MainView implements View {
private final Shell shell;
|
// Path: src/main/java/songo/SWTUtil.java
// public class SWTUtil {
// private final SongoService service;
//
// @Inject
// SWTUtil(SongoService service) {
// this.service = service;
// }
//
// public void exitOnClose(Shell shell) {
// shell.addShellListener(new ShellAdapter() {
// @Override
// public void shellClosed(ShellEvent e) {
// service.stop();
// }
// });
// }
// }
// Path: src/main/java/songo/view/MainView.java
import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
import com.google.inject.servlet.SessionScoped;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import songo.SWTUtil;
import songo.annotation.SessionBus;
package songo.view;
@SessionScoped
public class MainView implements View {
private final Shell shell;
|
private final SWTUtil util;
|
aolshevskiy/songo
|
src/main/java/songo/view/PlayerControl.java
|
// Path: src/main/java/songo/ResourceUtil.java
// public class ResourceUtil {
// private ResourceUtil() {
//
// }
// public static InputStream iconStream(String name) {
// return ResourceUtil.class.getResourceAsStream("/songo/icons/dark/" + name + ".png");
// }
// }
//
// Path: src/main/java/songo/ResourceUtil.java
// public static InputStream iconStream(String name) {
// return ResourceUtil.class.getResourceAsStream("/songo/icons/dark/" + name + ".png");
// }
|
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.servlet.SessionScoped;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ControlEditor;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.ResourceUtil;
import songo.annotation.GlobalBus;
import songo.annotation.SessionBus;
import static songo.ResourceUtil.iconStream;
|
package songo.view;
@SessionScoped
public class PlayerControl extends Composite {
private final EventBus globalBus;
private final ProgressBar progress;
private int duration = 0;
private ProgressBar downloadProgress;
private ToolItem playButton;
private Image playIcon;
private Image pauseIcon;
@Inject
public PlayerControl(MainView mainView, @GlobalBus EventBus globalBus, @SessionBus final EventBus sessionBus) {
super(mainView.getShell(), SWT.NONE);
this.globalBus = globalBus;
moveAbove(mainView.getShell().getChildren()[0]);
setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
GridLayout thisLayout = new GridLayout(2, false);
thisLayout.marginWidth = 0;
thisLayout.marginHeight = 0;
thisLayout.horizontalSpacing = 0;
thisLayout.verticalSpacing = 0;
setLayout(thisLayout);
ToolBar toolbar = new ToolBar(this, SWT.FLAT);
GridData toolbarData = new GridData(SWT.CENTER, SWT.FILL, false, true);
toolbarData.verticalSpan = 2;
toolbar.setLayoutData(toolbarData);
ToolItem prevButton = new ToolItem(toolbar, SWT.FLAT);
|
// Path: src/main/java/songo/ResourceUtil.java
// public class ResourceUtil {
// private ResourceUtil() {
//
// }
// public static InputStream iconStream(String name) {
// return ResourceUtil.class.getResourceAsStream("/songo/icons/dark/" + name + ".png");
// }
// }
//
// Path: src/main/java/songo/ResourceUtil.java
// public static InputStream iconStream(String name) {
// return ResourceUtil.class.getResourceAsStream("/songo/icons/dark/" + name + ".png");
// }
// Path: src/main/java/songo/view/PlayerControl.java
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
import com.google.inject.servlet.SessionScoped;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ControlEditor;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.FontMetrics;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import songo.ResourceUtil;
import songo.annotation.GlobalBus;
import songo.annotation.SessionBus;
import static songo.ResourceUtil.iconStream;
package songo.view;
@SessionScoped
public class PlayerControl extends Composite {
private final EventBus globalBus;
private final ProgressBar progress;
private int duration = 0;
private ProgressBar downloadProgress;
private ToolItem playButton;
private Image playIcon;
private Image pauseIcon;
@Inject
public PlayerControl(MainView mainView, @GlobalBus EventBus globalBus, @SessionBus final EventBus sessionBus) {
super(mainView.getShell(), SWT.NONE);
this.globalBus = globalBus;
moveAbove(mainView.getShell().getChildren()[0]);
setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false));
GridLayout thisLayout = new GridLayout(2, false);
thisLayout.marginWidth = 0;
thisLayout.marginHeight = 0;
thisLayout.horizontalSpacing = 0;
thisLayout.verticalSpacing = 0;
setLayout(thisLayout);
ToolBar toolbar = new ToolBar(this, SWT.FLAT);
GridData toolbarData = new GridData(SWT.CENTER, SWT.FILL, false, true);
toolbarData.verticalSpan = 2;
toolbar.setLayoutData(toolbarData);
ToolItem prevButton = new ToolItem(toolbar, SWT.FLAT);
|
prevButton.setImage(new Image(getDisplay(), iconStream("prev")));
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/AbstractInfoGraphRender.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
|
import java.util.Map;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.AbstractPlugin;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IPluginVisitor;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.providers.impl.RenderProvider;
|
package org.aksw.openqa.component.ui.render;
public abstract class AbstractInfoGraphRender extends AbstractPlugin implements InfoGraphRender {
public AbstractInfoGraphRender() {
}
public AbstractInfoGraphRender(Class<? extends IPlugin> c, Map<String, Object> params) {
super(c, params);
}
@Override
public void render(RenderProvider renderProvider, InfoNode result, IContext context, ServletOutputStream out) throws Exception {
printStart(renderProvider, result, context, out);
printContent(renderProvider, result, context, out);
printEnd(renderProvider, result, context, out);
}
@Override
public boolean canRender(IContext context, InfoNode node)
throws Exception {
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/AbstractInfoGraphRender.java
import java.util.Map;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.AbstractPlugin;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IPluginVisitor;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.providers.impl.RenderProvider;
package org.aksw.openqa.component.ui.render;
public abstract class AbstractInfoGraphRender extends AbstractPlugin implements InfoGraphRender {
public AbstractInfoGraphRender() {
}
public AbstractInfoGraphRender(Class<? extends IPlugin> c, Map<String, Object> params) {
super(c, params);
}
@Override
public void render(RenderProvider renderProvider, InfoNode result, IContext context, ServletOutputStream out) throws Exception {
printStart(renderProvider, result, context, out);
printContent(renderProvider, result, context, out);
printEnd(renderProvider, result, context, out);
}
@Override
public boolean canRender(IContext context, InfoNode node)
throws Exception {
|
IResult result = node.getResult();
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldMain.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
|
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
|
package org.aksw.openqa.examples.example3;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "how are you";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
ClassLoader contextClassLoader = HelloWorldMain.class.getClassLoader();
PluginManager pluginManager = new PluginManager(contextClassLoader);
pluginManager.setActive(true);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldMain.java
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
package org.aksw.openqa.examples.example3;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "how are you";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
ClassLoader contextClassLoader = HelloWorldMain.class.getClassLoader();
PluginManager pluginManager = new PluginManager(contextClassLoader);
pluginManager.setActive(true);
|
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldMain.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
|
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
|
package org.aksw.openqa.examples.example3;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "how are you";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
ClassLoader contextClassLoader = HelloWorldMain.class.getClassLoader();
PluginManager pluginManager = new PluginManager(contextClassLoader);
pluginManager.setActive(true);
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
QueryResult result;
result = queryProcessor.process(question);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldMain.java
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
package org.aksw.openqa.examples.example3;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "how are you";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
ClassLoader contextClassLoader = HelloWorldMain.class.getClassLoader();
PluginManager pluginManager = new PluginManager(contextClassLoader);
pluginManager.setActive(true);
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
QueryResult result;
result = queryProcessor.process(question);
|
List<? extends IResult> output = result.getOutput();
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa;
public class QAEngineProcessor implements IComponent {
private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
private ContextProvider contextProvider;
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa;
public class QAEngineProcessor implements IComponent {
private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
private ContextProvider contextProvider;
|
private ServiceProvider serviceProvider;
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa;
public class QAEngineProcessor implements IComponent {
private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
private ContextProvider contextProvider;
private ServiceProvider serviceProvider;
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa;
public class QAEngineProcessor implements IComponent {
private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
private ContextProvider contextProvider;
private ServiceProvider serviceProvider;
|
private InterpreterProvider interpreterProvider;
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa;
public class QAEngineProcessor implements IComponent {
private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
private ContextProvider contextProvider;
private ServiceProvider serviceProvider;
private InterpreterProvider interpreterProvider;
private RetrieverProvider retrieverProvider;
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa;
public class QAEngineProcessor implements IComponent {
private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
private ContextProvider contextProvider;
private ServiceProvider serviceProvider;
private InterpreterProvider interpreterProvider;
private RetrieverProvider retrieverProvider;
|
private SynthesizerProvider synthesizerProvider;
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa;
public class QAEngineProcessor implements IComponent {
private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
private ContextProvider contextProvider;
private ServiceProvider serviceProvider;
private InterpreterProvider interpreterProvider;
private RetrieverProvider retrieverProvider;
private SynthesizerProvider synthesizerProvider;
public QAEngineProcessor(PluginManager pluginManager) {
this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
}
public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
SynthesizerProvider synthesizerProvider) {
this.contextProvider = contextProvider;
this.serviceProvider = serviceProvider;
this.interpreterProvider = interpreterProvider;
this.retrieverProvider = retrieverProvider;
this.synthesizerProvider = synthesizerProvider;
}
public QueryResult process(String query) throws Exception {
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa;
public class QAEngineProcessor implements IComponent {
private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
private ContextProvider contextProvider;
private ServiceProvider serviceProvider;
private InterpreterProvider interpreterProvider;
private RetrieverProvider retrieverProvider;
private SynthesizerProvider synthesizerProvider;
public QAEngineProcessor(PluginManager pluginManager) {
this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
}
public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
SynthesizerProvider synthesizerProvider) {
this.contextProvider = contextProvider;
this.serviceProvider = serviceProvider;
this.interpreterProvider = interpreterProvider;
this.retrieverProvider = retrieverProvider;
this.synthesizerProvider = synthesizerProvider;
}
public QueryResult process(String query) throws Exception {
|
List<IParams> params = new ArrayList<IParams>();
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
SynthesizerProvider synthesizerProvider) {
this.contextProvider = contextProvider;
this.serviceProvider = serviceProvider;
this.interpreterProvider = interpreterProvider;
this.retrieverProvider = retrieverProvider;
this.synthesizerProvider = synthesizerProvider;
}
public QueryResult process(String query) throws Exception {
List<IParams> params = new ArrayList<IParams>();
Params param = new Params();
param.setParam(Properties.Literal.TEXT, query);
params.add(param);
return process(params);
}
protected QueryResult process(List<IParams> params) throws Exception {
IContext context = contextProvider.get(IContext.class);
Date start = new Date();
QueryResult queryResult = process(params, serviceProvider, context);
Date end = new Date();
queryResult.setRuntime(end.getTime() - start.getTime());
logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
return queryResult;
}
protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
Date start = new Date();
Throwable throwable = null;
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.aksw.openqa.component.IComponent;
import org.aksw.openqa.component.IProcess;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.ContextProvider;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.main.ProcessResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
SynthesizerProvider synthesizerProvider) {
this.contextProvider = contextProvider;
this.serviceProvider = serviceProvider;
this.interpreterProvider = interpreterProvider;
this.retrieverProvider = retrieverProvider;
this.synthesizerProvider = synthesizerProvider;
}
public QueryResult process(String query) throws Exception {
List<IParams> params = new ArrayList<IParams>();
Params param = new Params();
param.setParam(Properties.Literal.TEXT, query);
params.add(param);
return process(params);
}
protected QueryResult process(List<IParams> params) throws Exception {
IContext context = contextProvider.get(IContext.class);
Date start = new Date();
QueryResult queryResult = process(params, serviceProvider, context);
Date end = new Date();
queryResult.setRuntime(end.getTime() - start.getTime());
logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
return queryResult;
}
protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
Date start = new Date();
Throwable throwable = null;
|
List<? extends IResult> results = null;
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldInterpreter.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
|
package org.aksw.openqa.examples.example2;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter() {
super(null /* there is no params to be passed */);
}
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public String getVersion() {
return "sample2"; // version
}
@Override
public String getLabel() {
return "HelloWorldInterpreter"; // the label
}
@Override
public String getId() {
return getLabel() + " " + getVersion(); // id = label + version
}
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldInterpreter.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
package org.aksw.openqa.examples.example2;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter() {
super(null /* there is no params to be passed */);
}
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public String getVersion() {
return "sample2"; // version
}
@Override
public String getLabel() {
return "HelloWorldInterpreter"; // the label
}
@Override
public String getId() {
return getLabel() + " " + getVersion(); // id = label + version
}
@Override
|
public boolean canProcess(IParams param) {
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldInterpreter.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
|
package org.aksw.openqa.examples.example2;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter() {
super(null /* there is no params to be passed */);
}
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public String getVersion() {
return "sample2"; // version
}
@Override
public String getLabel() {
return "HelloWorldInterpreter"; // the label
}
@Override
public String getId() {
return getLabel() + " " + getVersion(); // id = label + version
}
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.Literal.TEXT, String.class);
}
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldInterpreter.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
package org.aksw.openqa.examples.example2;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter() {
super(null /* there is no params to be passed */);
}
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public String getVersion() {
return "sample2"; // version
}
@Override
public String getLabel() {
return "HelloWorldInterpreter"; // the label
}
@Override
public String getId() {
return getLabel() + " " + getVersion(); // id = label + version
}
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.Literal.TEXT, String.class);
}
@Override
|
public List<? extends IResult> process(IParams param,
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldInterpreter.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
|
package org.aksw.openqa.examples.example2;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter() {
super(null /* there is no params to be passed */);
}
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public String getVersion() {
return "sample2"; // version
}
@Override
public String getLabel() {
return "HelloWorldInterpreter"; // the label
}
@Override
public String getId() {
return getLabel() + " " + getVersion(); // id = label + version
}
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.Literal.TEXT, String.class);
}
@Override
public List<? extends IResult> process(IParams param,
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldInterpreter.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
package org.aksw.openqa.examples.example2;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter() {
super(null /* there is no params to be passed */);
}
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public String getVersion() {
return "sample2"; // version
}
@Override
public String getLabel() {
return "HelloWorldInterpreter"; // the label
}
@Override
public String getId() {
return getLabel() + " " + getVersion(); // id = label + version
}
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.Literal.TEXT, String.class);
}
@Override
public List<? extends IResult> process(IParams param,
|
ServiceProvider services, IContext context) throws Exception {
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldInterpreter.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
|
// removing punctuation (.,!,?)
while(
you.charAt(you.length()-1) == '.' ||
you.charAt(you.length()-1) == '!' ||
you.charAt(you.length()-1) == '?'
) {
you = you.substring(0, you.length()-1);
}
// eliminating white spaces, again :)
you.trim();
int j = 0;
while(response==0) {
// always check the questions from the position j*2 of the allowedQuestions matrix
if(inArray(you.toLowerCase(), allwedQuestions[j])) {
response = j;
break;
}
j++; // check next group of questions
// check if the allowed questions vector is finished
if(j*2==(allwedQuestions.length-1) && response == 0) {
response = j; // if it is, we did not find any match
}
}
} else
response = 2; // end of matrix
List<IResult> results = new ArrayList<>();
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldInterpreter.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
// removing punctuation (.,!,?)
while(
you.charAt(you.length()-1) == '.' ||
you.charAt(you.length()-1) == '!' ||
you.charAt(you.length()-1) == '?'
) {
you = you.substring(0, you.length()-1);
}
// eliminating white spaces, again :)
you.trim();
int j = 0;
while(response==0) {
// always check the questions from the position j*2 of the allowedQuestions matrix
if(inArray(you.toLowerCase(), allwedQuestions[j])) {
response = j;
break;
}
j++; // check next group of questions
// check if the allowed questions vector is finished
if(j*2==(allwedQuestions.length-1) && response == 0) {
response = j; // if it is, we did not find any match
}
}
} else
response = 2; // end of matrix
List<IResult> results = new ArrayList<>();
|
Result result = new Result();
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreter.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
|
package org.aksw.openqa.examples.example3;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreter.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
package org.aksw.openqa.examples.example3;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
|
public boolean canProcess(IParams param) {
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreter.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
|
package org.aksw.openqa.examples.example3;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.Literal.TEXT, String.class);
}
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreter.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
package org.aksw.openqa.examples.example3;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.Literal.TEXT, String.class);
}
@Override
|
public List<? extends IResult> process(IParams param,
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreter.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
|
package org.aksw.openqa.examples.example3;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.Literal.TEXT, String.class);
}
@Override
public List<? extends IResult> process(IParams param,
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreter.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
package org.aksw.openqa.examples.example3;
public class HelloWorldInterpreter extends AbstractInterpreter {
String[][] allwedQuestions= {
// standard greetings
{"hi", "hello", "hola", "ola", "howdy"},
// question greetings
{"how are you", "how r you", "how r u", "how are u"}
};
public HelloWorldInterpreter(Map<String, Object> params) {
super(params);
}
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.Literal.TEXT, String.class);
}
@Override
public List<? extends IResult> process(IParams param,
|
ServiceProvider services, IContext context) throws Exception {
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreter.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
|
// removing punctuation (.,!,?)
while(
you.charAt(you.length()-1) == '.' ||
you.charAt(you.length()-1) == '!' ||
you.charAt(you.length()-1) == '?'
) {
you = you.substring(0, you.length()-1);
}
// eliminating white spaces, again :)
you.trim();
int j = 0;
while(response==0) {
// always check the questions from the position j*2 of the allowedQuestions matrix
if(inArray(you.toLowerCase(), allwedQuestions[j])) {
response = j;
break;
}
j++; // check next group of questions
// check if the allowed questions array is finished
if(j==(allwedQuestions.length) && response == 0) {
response = j; // if it is, we did not find any match
}
}
} else
response = 2; // end of matrix
List<IResult> results = new ArrayList<>();
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreter.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractInterpreter;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.examples.HelloWorldParameters;
// removing punctuation (.,!,?)
while(
you.charAt(you.length()-1) == '.' ||
you.charAt(you.length()-1) == '!' ||
you.charAt(you.length()-1) == '?'
) {
you = you.substring(0, you.length()-1);
}
// eliminating white spaces, again :)
you.trim();
int j = 0;
while(response==0) {
// always check the questions from the position j*2 of the allowedQuestions matrix
if(inArray(you.toLowerCase(), allwedQuestions[j])) {
response = j;
break;
}
j++; // check next group of questions
// check if the allowed questions array is finished
if(j==(allwedQuestions.length) && response == 0) {
response = j; // if it is, we did not find any match
}
}
} else
response = 2; // end of matrix
List<IResult> results = new ArrayList<>();
|
Result result = new Result();
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultSynthesizerFactory.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizerFactorySpi.java
// public abstract class AbstractSynthesizerFactorySpi extends AbstractPluginFactory<ISynthesizer> implements ISynthesizerFactory {
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/ISynthesizer.java
// public interface ISynthesizer extends IPluginProcess {
// }
|
import java.util.Map;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizerFactorySpi;
import org.aksw.openqa.component.answerformulation.ISynthesizer;
|
package org.aksw.openqa.component.answerformulation.synthesizer.impl;
public class DefaultSynthesizerFactory extends AbstractSynthesizerFactorySpi {
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizerFactorySpi.java
// public abstract class AbstractSynthesizerFactorySpi extends AbstractPluginFactory<ISynthesizer> implements ISynthesizerFactory {
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/ISynthesizer.java
// public interface ISynthesizer extends IPluginProcess {
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultSynthesizerFactory.java
import java.util.Map;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizerFactorySpi;
import org.aksw.openqa.component.answerformulation.ISynthesizer;
package org.aksw.openqa.component.answerformulation.synthesizer.impl;
public class DefaultSynthesizerFactory extends AbstractSynthesizerFactorySpi {
@Override
|
public ISynthesizer create(Map<String, Object> params) {
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultRDFTermSynthesizer.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizer.java
// public abstract class AbstractSynthesizer extends AbstractQFProcessor implements ISynthesizer {
//
// public AbstractSynthesizer(Map<String, Object> params)
// throws IOException {
// super(params);
// }
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizer;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
|
package org.aksw.openqa.component.answerformulation.synthesizer.impl;
public class DefaultRDFTermSynthesizer extends AbstractSynthesizer {
public DefaultRDFTermSynthesizer(Map<String, Object> params)
throws IOException {
super(params);
}
Comparator<Entry<String, Candidate>> comparator = new Comparator<Entry<String, Candidate>>() {
public int compare(Entry<String, Candidate> e1, Entry<String, Candidate> e2) {
Candidate c1 = e1.getValue();
Candidate c2 = e2.getValue();
return c2.incidence - c1.incidence; // measuring the incidence
}
};
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizer.java
// public abstract class AbstractSynthesizer extends AbstractQFProcessor implements ISynthesizer {
//
// public AbstractSynthesizer(Map<String, Object> params)
// throws IOException {
// super(params);
// }
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultRDFTermSynthesizer.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizer;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
package org.aksw.openqa.component.answerformulation.synthesizer.impl;
public class DefaultRDFTermSynthesizer extends AbstractSynthesizer {
public DefaultRDFTermSynthesizer(Map<String, Object> params)
throws IOException {
super(params);
}
Comparator<Entry<String, Candidate>> comparator = new Comparator<Entry<String, Candidate>>() {
public int compare(Entry<String, Candidate> e1, Entry<String, Candidate> e2) {
Candidate c1 = e1.getValue();
Candidate c2 = e2.getValue();
return c2.incidence - c1.incidence; // measuring the incidence
}
};
@Override
|
public boolean canProcess(IParams param) {
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultRDFTermSynthesizer.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizer.java
// public abstract class AbstractSynthesizer extends AbstractQFProcessor implements ISynthesizer {
//
// public AbstractSynthesizer(Map<String, Object> params)
// throws IOException {
// super(params);
// }
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizer;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
|
package org.aksw.openqa.component.answerformulation.synthesizer.impl;
public class DefaultRDFTermSynthesizer extends AbstractSynthesizer {
public DefaultRDFTermSynthesizer(Map<String, Object> params)
throws IOException {
super(params);
}
Comparator<Entry<String, Candidate>> comparator = new Comparator<Entry<String, Candidate>>() {
public int compare(Entry<String, Candidate> e1, Entry<String, Candidate> e2) {
Candidate c1 = e1.getValue();
Candidate c2 = e2.getValue();
return c2.incidence - c1.incidence; // measuring the incidence
}
};
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.URI) ||
param.contains(Properties.Literal.NUMBER) ||
param.contains(Properties.Literal.DATE) ||
param.contains(Properties.Literal.BOOLEAN) ||
param.contains(Properties.Literal.TEXT) ||
param.contains(Properties.RESOURCE);
}
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizer.java
// public abstract class AbstractSynthesizer extends AbstractQFProcessor implements ISynthesizer {
//
// public AbstractSynthesizer(Map<String, Object> params)
// throws IOException {
// super(params);
// }
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultRDFTermSynthesizer.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizer;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
package org.aksw.openqa.component.answerformulation.synthesizer.impl;
public class DefaultRDFTermSynthesizer extends AbstractSynthesizer {
public DefaultRDFTermSynthesizer(Map<String, Object> params)
throws IOException {
super(params);
}
Comparator<Entry<String, Candidate>> comparator = new Comparator<Entry<String, Candidate>>() {
public int compare(Entry<String, Candidate> e1, Entry<String, Candidate> e2) {
Candidate c1 = e1.getValue();
Candidate c2 = e2.getValue();
return c2.incidence - c1.incidence; // measuring the incidence
}
};
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.URI) ||
param.contains(Properties.Literal.NUMBER) ||
param.contains(Properties.Literal.DATE) ||
param.contains(Properties.Literal.BOOLEAN) ||
param.contains(Properties.Literal.TEXT) ||
param.contains(Properties.RESOURCE);
}
@Override
|
public java.util.List<? extends IResult> process(java.util.List<? extends IParams> inputParams, ServiceProvider services,
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultRDFTermSynthesizer.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizer.java
// public abstract class AbstractSynthesizer extends AbstractQFProcessor implements ISynthesizer {
//
// public AbstractSynthesizer(Map<String, Object> params)
// throws IOException {
// super(params);
// }
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizer;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
|
package org.aksw.openqa.component.answerformulation.synthesizer.impl;
public class DefaultRDFTermSynthesizer extends AbstractSynthesizer {
public DefaultRDFTermSynthesizer(Map<String, Object> params)
throws IOException {
super(params);
}
Comparator<Entry<String, Candidate>> comparator = new Comparator<Entry<String, Candidate>>() {
public int compare(Entry<String, Candidate> e1, Entry<String, Candidate> e2) {
Candidate c1 = e1.getValue();
Candidate c2 = e2.getValue();
return c2.incidence - c1.incidence; // measuring the incidence
}
};
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.URI) ||
param.contains(Properties.Literal.NUMBER) ||
param.contains(Properties.Literal.DATE) ||
param.contains(Properties.Literal.BOOLEAN) ||
param.contains(Properties.Literal.TEXT) ||
param.contains(Properties.RESOURCE);
}
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizer.java
// public abstract class AbstractSynthesizer extends AbstractQFProcessor implements ISynthesizer {
//
// public AbstractSynthesizer(Map<String, Object> params)
// throws IOException {
// super(params);
// }
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultRDFTermSynthesizer.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizer;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
package org.aksw.openqa.component.answerformulation.synthesizer.impl;
public class DefaultRDFTermSynthesizer extends AbstractSynthesizer {
public DefaultRDFTermSynthesizer(Map<String, Object> params)
throws IOException {
super(params);
}
Comparator<Entry<String, Candidate>> comparator = new Comparator<Entry<String, Candidate>>() {
public int compare(Entry<String, Candidate> e1, Entry<String, Candidate> e2) {
Candidate c1 = e1.getValue();
Candidate c2 = e2.getValue();
return c2.incidence - c1.incidence; // measuring the incidence
}
};
@Override
public boolean canProcess(IParams param) {
return param.contains(Properties.URI) ||
param.contains(Properties.Literal.NUMBER) ||
param.contains(Properties.Literal.DATE) ||
param.contains(Properties.Literal.BOOLEAN) ||
param.contains(Properties.Literal.TEXT) ||
param.contains(Properties.RESOURCE);
}
@Override
|
public java.util.List<? extends IResult> process(java.util.List<? extends IParams> inputParams, ServiceProvider services,
|
AKSW/openQA
|
openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultRDFTermSynthesizer.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizer.java
// public abstract class AbstractSynthesizer extends AbstractQFProcessor implements ISynthesizer {
//
// public AbstractSynthesizer(Map<String, Object> params)
// throws IOException {
// super(params);
// }
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
|
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizer;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
|
else if (param.contains(Properties.Literal.TEXT))
attrValue = (String) param.getParam(Properties.Literal.TEXT);
else {
attrValue = (String) param.getParam(Properties.RESOURCE);
}
// there is no check for null, once canProcess assure that there is the attribute
if(attrKey == Properties.URI) {
attrValue = attrValue.substring(attrKey.lastIndexOf("/") + 1);
}
if(instanceIncidence.containsKey(attrValue)) {
Candidate candidate = instanceIncidence.get(attrValue);
candidate.incidence++;
instanceIncidence.put(attrValue, candidate);
} else {
Candidate candidate = new Candidate();
candidate.param = param;
candidate.incidence++;
instanceIncidence.put(attrValue, candidate);
}
}
List<Entry<String, Candidate>> intanceIncidenceList = new ArrayList<Entry<String, Candidate>>(instanceIncidence.entrySet());
Collections.sort(intanceIncidenceList, comparator);
List<IResult> results = new ArrayList<IResult>();
for(Entry<String, Candidate> entry: intanceIncidenceList) {
Candidate candidate = entry.getValue();
IParams inputParam = candidate.param;
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/AbstractSynthesizer.java
// public abstract class AbstractSynthesizer extends AbstractQFProcessor implements ISynthesizer {
//
// public AbstractSynthesizer(Map<String, Object> params)
// throws IOException {
// super(params);
// }
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/Result.java
// public class Result extends AbstractResult {
//
// protected IComponent source;
// protected IParams inputParam;
//
// public Result() {
// }
//
// public Result(Map<String, Object> params, IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// setProperties(params);
// }
//
// public Result(Map<String, Object> params) {
// // setting the source
// setProperties(params);
// }
//
// public Result(IParams inputParam, IComponent source) {
// // setting the source
// this.source = source;
// this.inputParam = inputParam;
// }
//
// @Override
// public IComponent getSource() {
// return source;
// }
//
// @Override
// public IParams getInputParam() {
// return inputParam;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/synthesizer/impl/DefaultRDFTermSynthesizer.java
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.answerformulation.AbstractSynthesizer;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Result;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
else if (param.contains(Properties.Literal.TEXT))
attrValue = (String) param.getParam(Properties.Literal.TEXT);
else {
attrValue = (String) param.getParam(Properties.RESOURCE);
}
// there is no check for null, once canProcess assure that there is the attribute
if(attrKey == Properties.URI) {
attrValue = attrValue.substring(attrKey.lastIndexOf("/") + 1);
}
if(instanceIncidence.containsKey(attrValue)) {
Candidate candidate = instanceIncidence.get(attrValue);
candidate.incidence++;
instanceIncidence.put(attrValue, candidate);
} else {
Candidate candidate = new Candidate();
candidate.param = param;
candidate.incidence++;
instanceIncidence.put(attrValue, candidate);
}
}
List<Entry<String, Candidate>> intanceIncidenceList = new ArrayList<Entry<String, Candidate>>(instanceIncidence.entrySet());
Collections.sort(intanceIncidenceList, comparator);
List<IResult> results = new ArrayList<IResult>();
for(Entry<String, Candidate> entry: intanceIncidenceList) {
Candidate candidate = entry.getValue();
IParams inputParam = candidate.param;
|
Result result = new Result(inputParam.getParameters(), inputParam, this);
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldMain.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
|
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
|
package org.aksw.openqa.examples.example2;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
HelloWorldInterpreter interpreter = new HelloWorldInterpreter();
HelloWorldRetriever retriever = new HelloWorldRetriever();
PluginManager pluginManager = new PluginManager();
pluginManager.register(interpreter);
pluginManager.register(retriever);
pluginManager.setActive(true, interpreter.getId());
pluginManager.setActive(true, retriever.getId());
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldMain.java
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
package org.aksw.openqa.examples.example2;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
HelloWorldInterpreter interpreter = new HelloWorldInterpreter();
HelloWorldRetriever retriever = new HelloWorldRetriever();
PluginManager pluginManager = new PluginManager();
pluginManager.register(interpreter);
pluginManager.register(retriever);
pluginManager.setActive(true, interpreter.getId());
pluginManager.setActive(true, retriever.getId());
|
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldMain.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
|
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
|
package org.aksw.openqa.examples.example2;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
HelloWorldInterpreter interpreter = new HelloWorldInterpreter();
HelloWorldRetriever retriever = new HelloWorldRetriever();
PluginManager pluginManager = new PluginManager();
pluginManager.register(interpreter);
pluginManager.register(retriever);
pluginManager.setActive(true, interpreter.getId());
pluginManager.setActive(true, retriever.getId());
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
QueryResult result;
result = queryProcessor.process(question);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example2/HelloWorldMain.java
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
package org.aksw.openqa.examples.example2;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
HelloWorldInterpreter interpreter = new HelloWorldInterpreter();
HelloWorldRetriever retriever = new HelloWorldRetriever();
PluginManager pluginManager = new PluginManager();
pluginManager.register(interpreter);
pluginManager.register(retriever);
pluginManager.setActive(true, interpreter.getId());
pluginManager.setActive(true, retriever.getId());
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
QueryResult result;
result = queryProcessor.process(question);
|
List<? extends IResult> output = result.getOutput();
|
AKSW/openQA
|
openqa.render.infograph/src/main/java/org/aksw/openqa/component/ui/render/impl/DBpediaResultRenderFactory.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/AbstractRenderFactory.java
// public abstract class AbstractRenderFactory extends AbstractPluginFactory<InfoGraphRender> implements IRenderFactory {
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
|
import java.util.Map;
import org.aksw.openqa.component.ui.render.AbstractRenderFactory;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
|
package org.aksw.openqa.component.ui.render.impl;
public class DBpediaResultRenderFactory extends AbstractRenderFactory {
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/AbstractRenderFactory.java
// public abstract class AbstractRenderFactory extends AbstractPluginFactory<InfoGraphRender> implements IRenderFactory {
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
// Path: openqa.render.infograph/src/main/java/org/aksw/openqa/component/ui/render/impl/DBpediaResultRenderFactory.java
import java.util.Map;
import org.aksw.openqa.component.ui.render.AbstractRenderFactory;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
package org.aksw.openqa.component.ui.render.impl;
public class DBpediaResultRenderFactory extends AbstractRenderFactory {
@Override
|
public InfoGraphRender create(Map<String, Object> params) {
|
AKSW/openQA
|
openqa.render.infograph/src/main/java/org/aksw/openqa/component/ui/render/impl/ResultRender.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/AbstractInfoGraphRender.java
// public abstract class AbstractInfoGraphRender extends AbstractPlugin implements InfoGraphRender {
//
// public AbstractInfoGraphRender() {
// }
//
// public AbstractInfoGraphRender(Class<? extends IPlugin> c, Map<String, Object> params) {
// super(c, params);
// }
//
// @Override
// public void render(RenderProvider renderProvider, InfoNode result, IContext context, ServletOutputStream out) throws Exception {
// printStart(renderProvider, result, context, out);
// printContent(renderProvider, result, context, out);
// printEnd(renderProvider, result, context, out);
// }
//
// @Override
// public boolean canRender(IContext context, InfoNode node)
// throws Exception {
// IResult result = node.getResult();
//
// if(result == null)
// return false;
//
// // default check
// return result.contains(Properties.URI) ||
// result.contains(Properties.Literal.NUMBER) ||
// result.contains(Properties.Literal.DATE) ||
// result.contains(Properties.Literal.BOOLEAN) ||
// result.contains(Properties.RESOURCE);
// }
//
// protected abstract void printStart(RenderProvider render, InfoNode result, IContext context, ServletOutputStream out) throws Exception;
//
// protected abstract void printEnd(RenderProvider render, InfoNode result, IContext context, ServletOutputStream out) throws Exception;
//
// protected abstract void printContent(RenderProvider render, InfoNode result, IContext context, ServletOutputStream out) throws Exception;
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.ui.render.AbstractInfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.commons.lang.StringEscapeUtils;
|
+ "</div>"
+ "<hr class=\"ui-separator ui-state-default ui-corner-all\">"
+ "</div>";
private final static String endHTML = "</body>" +
"</html>";
private String linkHumanQuery = "<a id=\"h\" style=\"margin-left: 10px;\" class=\"button_go\" href=\"search?q=\">Graph Search</a>";
private String linkRobotQuery = "<a id=\"r\" style=\"margin-left: 10px;\" class=\"button_robot\" href=\"search?q=&content=sparql\">" + StringEscapeUtils.escapeHtml("I´m a robot") + "</a>";
public ResultRender(Map<String, Object> params) {
super(ResultRender.class, params);
}
@Override
public void printStart(RenderProvider render, InfoNode result, IContext context, ServletOutputStream out) throws Exception {
String query = (String) context.getInputQuery();
String linkHumanQuery = this.linkHumanQuery.replace("search?q=", "search?q=" + query);
String linkRobotQuery = this.linkRobotQuery.replace("search?q=", "search?q=" + query);
out.print(startHTML + " value=\"" + query +"\""+ searchInputQuery + linkHumanQuery + linkRobotQuery + afterQuery);
}
@Override
protected void printContent(RenderProvider render, InfoNode node, IContext context, ServletOutputStream out)
throws Exception {
List<InfoNode> infoNodeList = node.getInfoList();
if(infoNodeList != null) {
List<InfoNode> infoCopyNodeList = new ArrayList<InfoNode>(infoNodeList);
// filtering categories
for(InfoNode infoNode : infoNodeList) {
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/AbstractInfoGraphRender.java
// public abstract class AbstractInfoGraphRender extends AbstractPlugin implements InfoGraphRender {
//
// public AbstractInfoGraphRender() {
// }
//
// public AbstractInfoGraphRender(Class<? extends IPlugin> c, Map<String, Object> params) {
// super(c, params);
// }
//
// @Override
// public void render(RenderProvider renderProvider, InfoNode result, IContext context, ServletOutputStream out) throws Exception {
// printStart(renderProvider, result, context, out);
// printContent(renderProvider, result, context, out);
// printEnd(renderProvider, result, context, out);
// }
//
// @Override
// public boolean canRender(IContext context, InfoNode node)
// throws Exception {
// IResult result = node.getResult();
//
// if(result == null)
// return false;
//
// // default check
// return result.contains(Properties.URI) ||
// result.contains(Properties.Literal.NUMBER) ||
// result.contains(Properties.Literal.DATE) ||
// result.contains(Properties.Literal.BOOLEAN) ||
// result.contains(Properties.RESOURCE);
// }
//
// protected abstract void printStart(RenderProvider render, InfoNode result, IContext context, ServletOutputStream out) throws Exception;
//
// protected abstract void printEnd(RenderProvider render, InfoNode result, IContext context, ServletOutputStream out) throws Exception;
//
// protected abstract void printContent(RenderProvider render, InfoNode result, IContext context, ServletOutputStream out) throws Exception;
//
// public void visit(IPluginVisitor visitor) {
// visitor.visit(this);
// }
// }
// Path: openqa.render.infograph/src/main/java/org/aksw/openqa/component/ui/render/impl/ResultRender.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.Properties;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.ui.render.AbstractInfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.commons.lang.StringEscapeUtils;
+ "</div>"
+ "<hr class=\"ui-separator ui-state-default ui-corner-all\">"
+ "</div>";
private final static String endHTML = "</body>" +
"</html>";
private String linkHumanQuery = "<a id=\"h\" style=\"margin-left: 10px;\" class=\"button_go\" href=\"search?q=\">Graph Search</a>";
private String linkRobotQuery = "<a id=\"r\" style=\"margin-left: 10px;\" class=\"button_robot\" href=\"search?q=&content=sparql\">" + StringEscapeUtils.escapeHtml("I´m a robot") + "</a>";
public ResultRender(Map<String, Object> params) {
super(ResultRender.class, params);
}
@Override
public void printStart(RenderProvider render, InfoNode result, IContext context, ServletOutputStream out) throws Exception {
String query = (String) context.getInputQuery();
String linkHumanQuery = this.linkHumanQuery.replace("search?q=", "search?q=" + query);
String linkRobotQuery = this.linkRobotQuery.replace("search?q=", "search?q=" + query);
out.print(startHTML + " value=\"" + query +"\""+ searchInputQuery + linkHumanQuery + linkRobotQuery + afterQuery);
}
@Override
protected void printContent(RenderProvider render, InfoNode node, IContext context, ServletOutputStream out)
throws Exception {
List<InfoNode> infoNodeList = node.getInfoList();
if(infoNodeList != null) {
List<InfoNode> infoCopyNodeList = new ArrayList<InfoNode>(infoNodeList);
// filtering categories
for(InfoNode infoNode : infoNodeList) {
|
IResult result = infoNode.getResult();
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
|
package org.aksw.openqa;
public class OpenQA {
private static Logger logger = Logger.getLogger(OpenQA.class);
public void process(Map<String, Object> processParams,
Map<Class<? extends IProvider<? extends IPlugin>>,
IProvider<? extends IPlugin>> providers,
IContext context,
ServletOutputStream out) throws Exception {
// render
InfoNode node = new InfoNode();
try {
// increasing number of queries
int numberOfQueries = Status.getNumberOfQueries() + 1;
Status.setNumberOfQueries(numberOfQueries);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
package org.aksw.openqa;
public class OpenQA {
private static Logger logger = Logger.getLogger(OpenQA.class);
public void process(Map<String, Object> processParams,
Map<Class<? extends IProvider<? extends IPlugin>>,
IProvider<? extends IPlugin>> providers,
IContext context,
ServletOutputStream out) throws Exception {
// render
InfoNode node = new InfoNode();
try {
// increasing number of queries
int numberOfQueries = Status.getNumberOfQueries() + 1;
Status.setNumberOfQueries(numberOfQueries);
|
ServiceProvider serviceProvider = (ServiceProvider) providers.get(ServiceProvider.class);
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
|
package org.aksw.openqa;
public class OpenQA {
private static Logger logger = Logger.getLogger(OpenQA.class);
public void process(Map<String, Object> processParams,
Map<Class<? extends IProvider<? extends IPlugin>>,
IProvider<? extends IPlugin>> providers,
IContext context,
ServletOutputStream out) throws Exception {
// render
InfoNode node = new InfoNode();
try {
// increasing number of queries
int numberOfQueries = Status.getNumberOfQueries() + 1;
Status.setNumberOfQueries(numberOfQueries);
ServiceProvider serviceProvider = (ServiceProvider) providers.get(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : processParams.entrySet())
token.setParam(entry.getKey(), entry.getValue());
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
package org.aksw.openqa;
public class OpenQA {
private static Logger logger = Logger.getLogger(OpenQA.class);
public void process(Map<String, Object> processParams,
Map<Class<? extends IProvider<? extends IPlugin>>,
IProvider<? extends IPlugin>> providers,
IContext context,
ServletOutputStream out) throws Exception {
// render
InfoNode node = new InfoNode();
try {
// increasing number of queries
int numberOfQueries = Status.getNumberOfQueries() + 1;
Status.setNumberOfQueries(numberOfQueries);
ServiceProvider serviceProvider = (ServiceProvider) providers.get(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : processParams.entrySet())
token.setParam(entry.getKey(), entry.getValue());
|
List<IParams> params = new ArrayList<IParams>();
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
|
package org.aksw.openqa;
public class OpenQA {
private static Logger logger = Logger.getLogger(OpenQA.class);
public void process(Map<String, Object> processParams,
Map<Class<? extends IProvider<? extends IPlugin>>,
IProvider<? extends IPlugin>> providers,
IContext context,
ServletOutputStream out) throws Exception {
// render
InfoNode node = new InfoNode();
try {
// increasing number of queries
int numberOfQueries = Status.getNumberOfQueries() + 1;
Status.setNumberOfQueries(numberOfQueries);
ServiceProvider serviceProvider = (ServiceProvider) providers.get(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : processParams.entrySet())
token.setParam(entry.getKey(), entry.getValue());
List<IParams> params = new ArrayList<IParams>();
params.add(token);
logger.debug("Interpreting");
// Input Interpreter
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
package org.aksw.openqa;
public class OpenQA {
private static Logger logger = Logger.getLogger(OpenQA.class);
public void process(Map<String, Object> processParams,
Map<Class<? extends IProvider<? extends IPlugin>>,
IProvider<? extends IPlugin>> providers,
IContext context,
ServletOutputStream out) throws Exception {
// render
InfoNode node = new InfoNode();
try {
// increasing number of queries
int numberOfQueries = Status.getNumberOfQueries() + 1;
Status.setNumberOfQueries(numberOfQueries);
ServiceProvider serviceProvider = (ServiceProvider) providers.get(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : processParams.entrySet())
token.setParam(entry.getKey(), entry.getValue());
List<IParams> params = new ArrayList<IParams>();
params.add(token);
logger.debug("Interpreting");
// Input Interpreter
|
InterpreterProvider interpreterProvider = (InterpreterProvider) providers.get(InterpreterProvider.class);
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
|
package org.aksw.openqa;
public class OpenQA {
private static Logger logger = Logger.getLogger(OpenQA.class);
public void process(Map<String, Object> processParams,
Map<Class<? extends IProvider<? extends IPlugin>>,
IProvider<? extends IPlugin>> providers,
IContext context,
ServletOutputStream out) throws Exception {
// render
InfoNode node = new InfoNode();
try {
// increasing number of queries
int numberOfQueries = Status.getNumberOfQueries() + 1;
Status.setNumberOfQueries(numberOfQueries);
ServiceProvider serviceProvider = (ServiceProvider) providers.get(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : processParams.entrySet())
token.setParam(entry.getKey(), entry.getValue());
List<IParams> params = new ArrayList<IParams>();
params.add(token);
logger.debug("Interpreting");
// Input Interpreter
InterpreterProvider interpreterProvider = (InterpreterProvider) providers.get(InterpreterProvider.class);
List<? extends IParams> interpretations = interpreterProvider.process(params, serviceProvider, context);
logger.debug("Number of interpretations: " + interpretations.size());
logger.debug("Retrieving ");
// Processing
RetrieverProvider retrieverProvider = (RetrieverProvider) providers.get(RetrieverProvider.class);
List<? extends IParams> consultResults = retrieverProvider.process(interpretations, serviceProvider, context);
logger.debug("Number of consult results: " + consultResults.size());
logger.debug("Synthesizing");
// Synthesizing
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
package org.aksw.openqa;
public class OpenQA {
private static Logger logger = Logger.getLogger(OpenQA.class);
public void process(Map<String, Object> processParams,
Map<Class<? extends IProvider<? extends IPlugin>>,
IProvider<? extends IPlugin>> providers,
IContext context,
ServletOutputStream out) throws Exception {
// render
InfoNode node = new InfoNode();
try {
// increasing number of queries
int numberOfQueries = Status.getNumberOfQueries() + 1;
Status.setNumberOfQueries(numberOfQueries);
ServiceProvider serviceProvider = (ServiceProvider) providers.get(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : processParams.entrySet())
token.setParam(entry.getKey(), entry.getValue());
List<IParams> params = new ArrayList<IParams>();
params.add(token);
logger.debug("Interpreting");
// Input Interpreter
InterpreterProvider interpreterProvider = (InterpreterProvider) providers.get(InterpreterProvider.class);
List<? extends IParams> interpretations = interpreterProvider.process(params, serviceProvider, context);
logger.debug("Number of interpretations: " + interpretations.size());
logger.debug("Retrieving ");
// Processing
RetrieverProvider retrieverProvider = (RetrieverProvider) providers.get(RetrieverProvider.class);
List<? extends IParams> consultResults = retrieverProvider.process(interpretations, serviceProvider, context);
logger.debug("Number of consult results: " + consultResults.size());
logger.debug("Synthesizing");
// Synthesizing
|
SynthesizerProvider synthesizerProvider = (SynthesizerProvider) providers.get(SynthesizerProvider.class);
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
|
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : processParams.entrySet())
token.setParam(entry.getKey(), entry.getValue());
List<IParams> params = new ArrayList<IParams>();
params.add(token);
logger.debug("Interpreting");
// Input Interpreter
InterpreterProvider interpreterProvider = (InterpreterProvider) providers.get(InterpreterProvider.class);
List<? extends IParams> interpretations = interpreterProvider.process(params, serviceProvider, context);
logger.debug("Number of interpretations: " + interpretations.size());
logger.debug("Retrieving ");
// Processing
RetrieverProvider retrieverProvider = (RetrieverProvider) providers.get(RetrieverProvider.class);
List<? extends IParams> consultResults = retrieverProvider.process(interpretations, serviceProvider, context);
logger.debug("Number of consult results: " + consultResults.size());
logger.debug("Synthesizing");
// Synthesizing
SynthesizerProvider synthesizerProvider = (SynthesizerProvider) providers.get(SynthesizerProvider.class);
List<? extends IParams> syntheses = synthesizerProvider.process(consultResults, serviceProvider, context);
logger.debug("Number of syntheses: " + syntheses.size());
logger.debug("Resolving");
// Resolving
ResolverProvider resolverProvider = (ResolverProvider) providers.get(ResolverProvider.class);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : processParams.entrySet())
token.setParam(entry.getKey(), entry.getValue());
List<IParams> params = new ArrayList<IParams>();
params.add(token);
logger.debug("Interpreting");
// Input Interpreter
InterpreterProvider interpreterProvider = (InterpreterProvider) providers.get(InterpreterProvider.class);
List<? extends IParams> interpretations = interpreterProvider.process(params, serviceProvider, context);
logger.debug("Number of interpretations: " + interpretations.size());
logger.debug("Retrieving ");
// Processing
RetrieverProvider retrieverProvider = (RetrieverProvider) providers.get(RetrieverProvider.class);
List<? extends IParams> consultResults = retrieverProvider.process(interpretations, serviceProvider, context);
logger.debug("Number of consult results: " + consultResults.size());
logger.debug("Synthesizing");
// Synthesizing
SynthesizerProvider synthesizerProvider = (SynthesizerProvider) providers.get(SynthesizerProvider.class);
List<? extends IParams> syntheses = synthesizerProvider.process(consultResults, serviceProvider, context);
logger.debug("Number of syntheses: " + syntheses.size());
logger.debug("Resolving");
// Resolving
ResolverProvider resolverProvider = (ResolverProvider) providers.get(ResolverProvider.class);
|
List<? extends IResult> resolved = resolverProvider.process(syntheses, serviceProvider, context);
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
|
// Synthesizing
SynthesizerProvider synthesizerProvider = (SynthesizerProvider) providers.get(SynthesizerProvider.class);
List<? extends IParams> syntheses = synthesizerProvider.process(consultResults, serviceProvider, context);
logger.debug("Number of syntheses: " + syntheses.size());
logger.debug("Resolving");
// Resolving
ResolverProvider resolverProvider = (ResolverProvider) providers.get(ResolverProvider.class);
List<? extends IResult> resolved = resolverProvider.process(syntheses, serviceProvider, context);
logger.debug("Number of resolved results: " + resolved.size());
if(resolved.size() == 0) {
// increasing number of queries without result
int numberOfQueriesWithoutResult = Status.getQueriesWithourResult() + 1;
Status.setQueriesWithourResult(numberOfQueriesWithoutResult);
}
logger.debug("Rendering result");
for(IResult result : resolved) {
InfoNode childNode = new InfoNode();
childNode.setResult(result);
node.addInfo(childNode);
}
} catch (Exception e) {
int numberOfErrors = Status.getNumberOfErrors() + 1;
Status.setNumberOfErrors(numberOfErrors);
logger.error("An error occurred during the input process.", e);
}
// getting the main render
RenderProvider renderProvider = (RenderProvider) providers.get(RenderProvider.class);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/OpenQA.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import javax.servlet.ServletOutputStream;
import org.aksw.openqa.component.IPlugin;
import org.aksw.openqa.component.IProvider;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.RenderProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
import org.aksw.openqa.component.ui.render.InfoNode;
import org.apache.log4j.Logger;
// Synthesizing
SynthesizerProvider synthesizerProvider = (SynthesizerProvider) providers.get(SynthesizerProvider.class);
List<? extends IParams> syntheses = synthesizerProvider.process(consultResults, serviceProvider, context);
logger.debug("Number of syntheses: " + syntheses.size());
logger.debug("Resolving");
// Resolving
ResolverProvider resolverProvider = (ResolverProvider) providers.get(ResolverProvider.class);
List<? extends IResult> resolved = resolverProvider.process(syntheses, serviceProvider, context);
logger.debug("Number of resolved results: " + resolved.size());
if(resolved.size() == 0) {
// increasing number of queries without result
int numberOfQueriesWithoutResult = Status.getQueriesWithourResult() + 1;
Status.setQueriesWithourResult(numberOfQueriesWithoutResult);
}
logger.debug("Rendering result");
for(IResult result : resolved) {
InfoNode childNode = new InfoNode();
childNode.setResult(result);
node.addInfo(childNode);
}
} catch (Exception e) {
int numberOfErrors = Status.getNumberOfErrors() + 1;
Status.setNumberOfErrors(numberOfErrors);
logger.error("An error occurred during the input process.", e);
}
// getting the main render
RenderProvider renderProvider = (RenderProvider) providers.get(RenderProvider.class);
|
InfoGraphRender mainRender = renderProvider.getRootRender();
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
|
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
PluginManager pluginManager,
IContext context) throws Exception {
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
PluginManager pluginManager,
IContext context) throws Exception {
|
ServiceProvider serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
PluginManager pluginManager,
IContext context) throws Exception {
ServiceProvider serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : params.entrySet())
token.setParam(entry.getKey(), entry.getValue());
logger.debug("Interpreting");
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
PluginManager pluginManager,
IContext context) throws Exception {
ServiceProvider serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : params.entrySet())
token.setParam(entry.getKey(), entry.getValue());
logger.debug("Interpreting");
|
InterpreterProvider interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
PluginManager pluginManager,
IContext context) throws Exception {
ServiceProvider serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : params.entrySet())
token.setParam(entry.getKey(), entry.getValue());
logger.debug("Interpreting");
InterpreterProvider interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
PluginManager pluginManager,
IContext context) throws Exception {
ServiceProvider serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : params.entrySet())
token.setParam(entry.getKey(), entry.getValue());
logger.debug("Interpreting");
InterpreterProvider interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
|
List<IParams> arguments = new ArrayList<IParams>();
|
AKSW/openQA
|
openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
|
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
PluginManager pluginManager,
IContext context) throws Exception {
ServiceProvider serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : params.entrySet())
token.setParam(entry.getKey(), entry.getValue());
logger.debug("Interpreting");
InterpreterProvider interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
List<IParams> arguments = new ArrayList<IParams>();
arguments.add(token);
List<? extends IResult> interpretations = interpreterProvider.process(arguments, serviceProvider, context);
logger.debug("Number of interpretations: " + interpretations.size());
if(skipRetriever)
return interpretations;
logger.debug("Retrieving ");
RetrieverProvider retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
List<? extends IResult> retrieverResults = retrieverProvider.process(interpretations, serviceProvider, context);
logger.debug("Number of retrieved results: " + retrieverResults.size());
logger.debug("Synthesizing");
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IParams.java
// public interface IParams extends IObject {
// public IComponent getSource();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/InterpreterProvider.java
// public class InterpreterProvider extends PluginProcessProvider<Interpreter, IInterpreterFactory> {
// public InterpreterProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(IInterpreterFactory.class, classLoaders, serviceProvider);
// }
//
// public InterpreterProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/ServiceProvider.java
// public class ServiceProvider extends AbstractPluginProvider<IService, IServiceFactory> {
// public ServiceProvider(List<? extends ClassLoader> classLoaders) {
// super(IServiceFactory.class, classLoaders, null);
// }
//
// public ServiceProvider() {
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/providers/impl/SynthesizerProvider.java
// public class SynthesizerProvider extends PluginProcessProvider<ISynthesizer, ISynthesizerFactory> {
// public SynthesizerProvider(List<? extends ClassLoader> classLoaders, ServiceProvider serviceProvider) {
// super(ISynthesizerFactory.class, classLoaders, serviceProvider);
// }
//
// public SynthesizerProvider() {
// }
// }
// Path: openqa.webserver/src/main/java/org/aksw/openqa/component/answerformulation/AnswerFormulation.java
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.aksw.openqa.component.context.IContext;
import org.aksw.openqa.component.object.IParams;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.component.object.Params;
import org.aksw.openqa.component.providers.impl.InterpreterProvider;
import org.aksw.openqa.component.providers.impl.ResolverProvider;
import org.aksw.openqa.component.providers.impl.RetrieverProvider;
import org.aksw.openqa.component.providers.impl.ServiceProvider;
import org.aksw.openqa.component.providers.impl.SynthesizerProvider;
import org.aksw.openqa.manager.plugin.PluginManager;
import org.apache.log4j.Logger;
package org.aksw.openqa.component.answerformulation;
public class AnswerFormulation {
private static Logger logger = Logger.getLogger(AnswerFormulation.class);
public List<? extends IResult> process(boolean skipRetriever, Map<String, Object> params,
PluginManager pluginManager,
IContext context) throws Exception {
ServiceProvider serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
Params token = new Params();
logger.info("Parameterizing");
// param set
for(Entry<String, Object> entry : params.entrySet())
token.setParam(entry.getKey(), entry.getValue());
logger.debug("Interpreting");
InterpreterProvider interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
List<IParams> arguments = new ArrayList<IParams>();
arguments.add(token);
List<? extends IResult> interpretations = interpreterProvider.process(arguments, serviceProvider, context);
logger.debug("Number of interpretations: " + interpretations.size());
if(skipRetriever)
return interpretations;
logger.debug("Retrieving ");
RetrieverProvider retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
List<? extends IResult> retrieverResults = retrieverProvider.process(interpretations, serviceProvider, context);
logger.debug("Number of retrieved results: " + retrieverResults.size());
logger.debug("Synthesizing");
|
SynthesizerProvider synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
|
AKSW/openQA
|
openqa.render.infograph/src/main/java/org/aksw/openqa/component/ui/render/impl/DBpediaSPARQLQueryRenderFactory.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/AbstractRenderFactory.java
// public abstract class AbstractRenderFactory extends AbstractPluginFactory<InfoGraphRender> implements IRenderFactory {
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
|
import java.util.Map;
import org.aksw.openqa.component.ui.render.AbstractRenderFactory;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
|
package org.aksw.openqa.component.ui.render.impl;
public class DBpediaSPARQLQueryRenderFactory extends AbstractRenderFactory {
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/AbstractRenderFactory.java
// public abstract class AbstractRenderFactory extends AbstractPluginFactory<InfoGraphRender> implements IRenderFactory {
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/ui/render/InfoGraphRender.java
// public interface InfoGraphRender extends IRender, IPlugin {
// public boolean canRender(IContext context, InfoNode node) throws Exception;
// }
// Path: openqa.render.infograph/src/main/java/org/aksw/openqa/component/ui/render/impl/DBpediaSPARQLQueryRenderFactory.java
import java.util.Map;
import org.aksw.openqa.component.ui.render.AbstractRenderFactory;
import org.aksw.openqa.component.ui.render.InfoGraphRender;
package org.aksw.openqa.component.ui.render.impl;
public class DBpediaSPARQLQueryRenderFactory extends AbstractRenderFactory {
@Override
|
public InfoGraphRender create(Map<String, Object> params) {
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreterFactory.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/Interpreter.java
// public interface Interpreter extends IPluginProcess {
// }
|
import java.util.Map;
import org.aksw.openqa.component.answerformulation.AbstractInterpreterFactory;
import org.aksw.openqa.component.answerformulation.Interpreter;
|
package org.aksw.openqa.examples.example3;
public class HelloWorldInterpreterFactory extends AbstractInterpreterFactory {
@Override
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/answerformulation/Interpreter.java
// public interface Interpreter extends IPluginProcess {
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example3/HelloWorldInterpreterFactory.java
import java.util.Map;
import org.aksw.openqa.component.answerformulation.AbstractInterpreterFactory;
import org.aksw.openqa.component.answerformulation.Interpreter;
package org.aksw.openqa.examples.example3;
public class HelloWorldInterpreterFactory extends AbstractInterpreterFactory {
@Override
|
public Interpreter create(Map<String, Object> params) {
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example1/HelloWorldMain.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
|
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
|
package org.aksw.openqa.examples.example1;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
HelloWorldInterpreter interpreter = new HelloWorldInterpreter();
PluginManager pluginManager = new PluginManager();
pluginManager.register(interpreter);
pluginManager.setActive(true, interpreter.getId());
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example1/HelloWorldMain.java
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
package org.aksw.openqa.examples.example1;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
HelloWorldInterpreter interpreter = new HelloWorldInterpreter();
PluginManager pluginManager = new PluginManager();
pluginManager.register(interpreter);
pluginManager.setActive(true, interpreter.getId());
|
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
|
AKSW/openQA
|
openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example1/HelloWorldMain.java
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
|
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
|
package org.aksw.openqa.examples.example1;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
HelloWorldInterpreter interpreter = new HelloWorldInterpreter();
PluginManager pluginManager = new PluginManager();
pluginManager.register(interpreter);
pluginManager.setActive(true, interpreter.getId());
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
QueryResult result;
result = queryProcessor.process(question);
|
// Path: openqa.engine/src/main/java/org/aksw/openqa/QAEngineProcessor.java
// public class QAEngineProcessor implements IComponent {
//
// private static Logger logger = Logger.getLogger(QAEngineProcessor.class);
//
// private ContextProvider contextProvider;
// private ServiceProvider serviceProvider;
// private InterpreterProvider interpreterProvider;
// private RetrieverProvider retrieverProvider;
// private SynthesizerProvider synthesizerProvider;
//
// public QAEngineProcessor(PluginManager pluginManager) {
// this.contextProvider = (ContextProvider) pluginManager.getProvider(ContextProvider.class);
// this.serviceProvider = (ServiceProvider) pluginManager.getProvider(ServiceProvider.class);
// this.interpreterProvider = (InterpreterProvider) pluginManager.getProvider(InterpreterProvider.class);
// this.retrieverProvider = (RetrieverProvider) pluginManager.getProvider(RetrieverProvider.class);
// this.synthesizerProvider = (SynthesizerProvider) pluginManager.getProvider(SynthesizerProvider.class);
// }
//
// public QAEngineProcessor(ContextProvider contextProvider, ServiceProvider serviceProvider,
// InterpreterProvider interpreterProvider, RetrieverProvider retrieverProvider,
// SynthesizerProvider synthesizerProvider) {
// this.contextProvider = contextProvider;
// this.serviceProvider = serviceProvider;
// this.interpreterProvider = interpreterProvider;
// this.retrieverProvider = retrieverProvider;
// this.synthesizerProvider = synthesizerProvider;
// }
//
// public QueryResult process(String query) throws Exception {
// List<IParams> params = new ArrayList<IParams>();
// Params param = new Params();
// param.setParam(Properties.Literal.TEXT, query);
// params.add(param);
// return process(params);
// }
//
// protected QueryResult process(List<IParams> params) throws Exception {
// IContext context = contextProvider.get(IContext.class);
// Date start = new Date();
// QueryResult queryResult = process(params, serviceProvider, context);
// Date end = new Date();
// queryResult.setRuntime(end.getTime() - start.getTime());
// logger.debug("Answer formulation Runtime(ms) " + queryResult.getRuntime());
// return queryResult;
// }
//
// protected ProcessResult executeProcess(List<? extends IParams> params, IProcess process, ServiceProvider services, IContext context) throws Exception {
// Date start = new Date();
// Throwable throwable = null;
// List<? extends IResult> results = null;
// try {
// results = process.process(params, services, context);
// } catch (Throwable t) {
// throwable = t;
// }
// Date end = new Date();
// ProcessResult processResult = new ProcessResult();
// processResult.setOutput(results);
// processResult.setRuntime(end.getTime() - start.getTime()); // setting the runtime of the process
// processResult.setInput(params);
// processResult.setException(throwable);
//
// return processResult;
// }
//
// private QueryResult process(List<? extends IParams> params,
// ServiceProvider services, IContext context) throws Exception {
//
// QueryResult result = new QueryResult();
// result.setComponentSource(this);
// result.setInput(params);
//
// logger.debug("Interpreting");
// // Interpreting
// ProcessResult processResult = executeProcess(params, interpreterProvider, services, context);
// List<? extends IResult> interpretations = processResult.getOutput();
// logger.debug("Number of interpretations: " + interpretations.size());
// logger.debug("Interpreting runtime: " + processResult.getRuntime());
// // set Interpreting result
// result.setParam(QueryResult.Attr.INTERPRETING_RESULT, processResult);
//
// logger.debug("Retrieving");
// // Retrieving
// processResult = executeProcess(interpretations, retrieverProvider, services, context);
// List<? extends IResult> retrievingResults = processResult.getOutput();
// logger.debug("Number of retrieved results: " + retrievingResults.size());
// logger.debug("Retrieval runtime: " + processResult.getRuntime());
// // set Retrieving result
// result.setParam(QueryResult.Attr.RETRIEVAL_RESULT, processResult);
//
// logger.debug("Synthesizing");
// // Synthesizing
// processResult = executeProcess(retrievingResults, synthesizerProvider, services, context);
// List<? extends IResult> synthesisResults = processResult.getOutput();
// logger.debug("Number of synthesis: " + synthesisResults.size());
// logger.debug("Synthesis runtime: " + processResult.getRuntime());
// // set Synthesizer result
// result.setParam(QueryResult.Attr.SYNTHESIS_RESULT, processResult);
//
// result.setOutput(synthesisResults);
//
// return result;
// }
// }
//
// Path: openqa.engine/src/main/java/org/aksw/openqa/component/object/IResult.java
// public interface IResult extends IParams {
// public IParams getInputParam();
// }
// Path: openqa.engine.examples/src/main/java/org/aksw/openqa/examples/example1/HelloWorldMain.java
import java.util.List;
import org.aksw.openqa.Properties;
import org.aksw.openqa.QAEngineProcessor;
import org.aksw.openqa.component.object.IResult;
import org.aksw.openqa.main.QueryResult;
import org.aksw.openqa.manager.plugin.PluginManager;
package org.aksw.openqa.examples.example1;
public class HelloWorldMain {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
String question = "";
String answer = "";
if(args.length > 0)
question = args[0];
System.out.println("You:\t" + question);
HelloWorldInterpreter interpreter = new HelloWorldInterpreter();
PluginManager pluginManager = new PluginManager();
pluginManager.register(interpreter);
pluginManager.setActive(true, interpreter.getId());
QAEngineProcessor queryProcessor = new QAEngineProcessor(pluginManager);
QueryResult result;
result = queryProcessor.process(question);
|
List<? extends IResult> output = result.getOutput();
|
cjstehno/ersatz
|
ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/PutExpectations.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
|
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available PUT request expectations.
*/
public interface PutExpectations {
/**
* Allows configuration of a PUT request expectation.
*
* @param path the expected request path
* @return a <code>RequestWithContent</code> configuration object
*/
default RequestWithContent PUT(String path) {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/PutExpectations.java
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available PUT request expectations.
*/
public interface PutExpectations {
/**
* Allows configuration of a PUT request expectation.
*
* @param path the expected request path
* @return a <code>RequestWithContent</code> configuration object
*/
default RequestWithContent PUT(String path) {
|
return PUT(pathMatcher(path));
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/server/undertow/ResponseChunkerTest.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/server/undertow/ResponseChunker.java
// class ResponseChunker implements IoCallback {
//
// private final List<byte[]> chunks;
// public final int delay;
//
// ResponseChunker(final List<byte[]> chunks, final int delay) {
// this.chunks = chunks;
// this.delay = delay;
// }
//
// @Override
// public void onComplete(final HttpServerExchange exchange, final Sender sender) {
// if (chunks != null && !chunks.isEmpty()) {
// rest();
// sender.send(ByteBuffer.wrap(chunks.remove(0)), this);
// }
// }
//
// private void rest() {
// if (delay > 0) {
// try {
// Thread.sleep(delay);
// } catch (InterruptedException e) {
// // ignore
// }
// }
// }
//
// @Override
// public void onException(HttpServerExchange exchange, Sender sender, IOException exception) {
// exception.printStackTrace();
// }
//
// /**
// * Splits the provided string of content into the specified number of chunks. Any remaining characters will be spread out over the chunks to
// * keep the sizes as even as possible.
// *
// * @param content the content array to be chunked
// * @param chunks the number of chunks
// * @return a List<String> containing the chunk data
// */
// public static List<byte[]> prepareChunks(final byte[] content, final int chunks) {
// int chunklen = content.length / chunks;
// int remainder = content.length % chunks;
//
// final List<byte[]> chunked = new LinkedList<>();
//
// int index = 0;
//
// for (int n = 0; n < chunks; n++) {
// int extra = 0;
// if (remainder > 0) {
// extra = 1;
// --remainder;
// }
//
// int len = chunklen + extra;
//
// final byte[] chunk = new byte[len];
// System.arraycopy(content, index, chunk, 0, len);
// chunked.add(chunk);
//
// index += len;
// }
//
// return chunked;
// }
// }
|
import io.github.cjstehno.ersatz.server.undertow.ResponseChunker;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.server.undertow;
class ResponseChunkerTest {
private static final byte[] BYTES = "abcdefghijklmnop".getBytes();
@Test @DisplayName("parsing 3 chunks")
void parsing_3_chunks(){
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/server/undertow/ResponseChunker.java
// class ResponseChunker implements IoCallback {
//
// private final List<byte[]> chunks;
// public final int delay;
//
// ResponseChunker(final List<byte[]> chunks, final int delay) {
// this.chunks = chunks;
// this.delay = delay;
// }
//
// @Override
// public void onComplete(final HttpServerExchange exchange, final Sender sender) {
// if (chunks != null && !chunks.isEmpty()) {
// rest();
// sender.send(ByteBuffer.wrap(chunks.remove(0)), this);
// }
// }
//
// private void rest() {
// if (delay > 0) {
// try {
// Thread.sleep(delay);
// } catch (InterruptedException e) {
// // ignore
// }
// }
// }
//
// @Override
// public void onException(HttpServerExchange exchange, Sender sender, IOException exception) {
// exception.printStackTrace();
// }
//
// /**
// * Splits the provided string of content into the specified number of chunks. Any remaining characters will be spread out over the chunks to
// * keep the sizes as even as possible.
// *
// * @param content the content array to be chunked
// * @param chunks the number of chunks
// * @return a List<String> containing the chunk data
// */
// public static List<byte[]> prepareChunks(final byte[] content, final int chunks) {
// int chunklen = content.length / chunks;
// int remainder = content.length % chunks;
//
// final List<byte[]> chunked = new LinkedList<>();
//
// int index = 0;
//
// for (int n = 0; n < chunks; n++) {
// int extra = 0;
// if (remainder > 0) {
// extra = 1;
// --remainder;
// }
//
// int len = chunklen + extra;
//
// final byte[] chunk = new byte[len];
// System.arraycopy(content, index, chunk, 0, len);
// chunked.add(chunk);
//
// index += len;
// }
//
// return chunked;
// }
// }
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/server/undertow/ResponseChunkerTest.java
import io.github.cjstehno.ersatz.server.undertow.ResponseChunker;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.server.undertow;
class ResponseChunkerTest {
private static final byte[] BYTES = "abcdefghijklmnop".getBytes();
@Test @DisplayName("parsing 3 chunks")
void parsing_3_chunks(){
|
final var chunks = ResponseChunker.prepareChunks(BYTES, 3);
|
cjstehno/ersatz
|
ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/DeleteExpectations.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
|
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available DELETE request expectations.
*/
public interface DeleteExpectations {
/**
* Allows configuration of a DELETE request expectation.
*
* @param path the expected request path
* @return a <code>Request</code> configuration object
*/
default Request DELETE(String path) {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/DeleteExpectations.java
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available DELETE request expectations.
*/
public interface DeleteExpectations {
/**
* Allows configuration of a DELETE request expectation.
*
* @param path the expected request path
* @return a <code>Request</code> configuration object
*/
default Request DELETE(String path) {
|
return DELETE(pathMatcher(path));
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/CookieTest.java
|
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/TestAssertions.java
// static void verifyEqualityAndHashCode(final Object instanceA, final Object instanceB) {
// assertThat(instanceA, equalTo(instanceA));
// assertThat(instanceB, equalTo(instanceB));
// assertThat(instanceA, equalTo(instanceB));
// assertThat(instanceB, equalTo(instanceA));
// assertThat(instanceA, not(equalTo(null)));
// assertThat(instanceB, not(equalTo(null)));
// assertThat(instanceA.hashCode(), equalTo(instanceA.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceA.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceA.hashCode()));
// }
|
import lombok.val;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static io.github.cjstehno.ersatz.TestAssertions.verifyEqualityAndHashCode;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class CookieTest {
private static Cookie cookie() {
return Cookie.cookie(c -> {
c.value("alpha");
c.comment("Something");
c.domain("localhost");
c.path("/foo");
c.version(1);
c.httpOnly(true);
c.maxAge(100);
c.secure(true);
});
}
@Test @DisplayName("cookie (closure)") void cookieClosure() {
val cookie = cookie();
assertEquals("alpha", cookie.getValue());
assertEquals("Something", cookie.getComment());
assertEquals("localhost", cookie.getDomain());
assertEquals("/foo", cookie.getPath());
assertEquals(1, cookie.getVersion());
assertTrue(cookie.isHttpOnly());
assertEquals(100, cookie.getMaxAge());
assertTrue(cookie.isSecure());
}
@Test void equalsAndHash() {
|
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/TestAssertions.java
// static void verifyEqualityAndHashCode(final Object instanceA, final Object instanceB) {
// assertThat(instanceA, equalTo(instanceA));
// assertThat(instanceB, equalTo(instanceB));
// assertThat(instanceA, equalTo(instanceB));
// assertThat(instanceB, equalTo(instanceA));
// assertThat(instanceA, not(equalTo(null)));
// assertThat(instanceB, not(equalTo(null)));
// assertThat(instanceA.hashCode(), equalTo(instanceA.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceA.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceA.hashCode()));
// }
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/CookieTest.java
import lombok.val;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static io.github.cjstehno.ersatz.TestAssertions.verifyEqualityAndHashCode;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class CookieTest {
private static Cookie cookie() {
return Cookie.cookie(c -> {
c.value("alpha");
c.comment("Something");
c.domain("localhost");
c.path("/foo");
c.version(1);
c.httpOnly(true);
c.maxAge(100);
c.secure(true);
});
}
@Test @DisplayName("cookie (closure)") void cookieClosure() {
val cookie = cookie();
assertEquals("alpha", cookie.getValue());
assertEquals("Something", cookie.getComment());
assertEquals("localhost", cookie.getDomain());
assertEquals("/foo", cookie.getPath());
assertEquals(1, cookie.getVersion());
assertTrue(cookie.isHttpOnly());
assertEquals(100, cookie.getMaxAge());
assertTrue(cookie.isSecure());
}
@Test void equalsAndHash() {
|
verifyEqualityAndHashCode(cookie(), cookie());
|
cjstehno/ersatz
|
ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/PostExpectations.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
|
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available POST request expectations.
*/
public interface PostExpectations {
/**
* Allows configuration of a POST request expectation.
*
* @param path the request path.
* @return a <code>RequestWithContent</code> configuration object
*/
default RequestWithContent POST(String path) {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/PostExpectations.java
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available POST request expectations.
*/
public interface PostExpectations {
/**
* Allows configuration of a POST request expectation.
*
* @param path the request path.
* @return a <code>RequestWithContent</code> configuration object
*/
default RequestWithContent POST(String path) {
|
return POST(pathMatcher(path));
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/impl/GetExpectationsTest.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/HttpMethod.java
// public enum HttpMethod {
//
// /**
// * Wildcard matching any HTTP method.
// */
// ANY("*"),
//
// /**
// * HTTP GET method matcher.
// */
// GET("GET"),
//
// /**
// * HTTP HEAD method matcher.
// */
// HEAD("HEAD"),
//
// /**
// * HTTP POST method matcher.
// */
// POST("POST"),
//
// /**
// * HTTP PUT method matcher.
// */
// PUT("PUT"),
//
// /**
// * HTTP DELETE method matcher.
// */
// DELETE("DELETE"),
//
// /**
// * HTTP PATCH method matcher.
// */
// PATCH("PATCH"),
//
// /**
// * HTTP OPTIONS method matcher.
// */
// OPTIONS("OPTIONS"),
//
// /**
// * HTTP TRACE method matcher.
// */
// TRACE("TRACE");
//
// private final String value;
//
// HttpMethod(final String value) {
// this.value = value;
// }
//
// /**
// * Retrieve the text value for the method.
// *
// * @return the method label.
// */
// public String getValue() {
// return value;
// }
//
// @Override public String toString() {
// return value;
// }
// }
|
import io.github.cjstehno.ersatz.cfg.HttpMethod;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import static org.hamcrest.CoreMatchers.startsWith;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.impl;
class GetExpectationsTest extends ExpectationHarness {
GetExpectationsTest() {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/HttpMethod.java
// public enum HttpMethod {
//
// /**
// * Wildcard matching any HTTP method.
// */
// ANY("*"),
//
// /**
// * HTTP GET method matcher.
// */
// GET("GET"),
//
// /**
// * HTTP HEAD method matcher.
// */
// HEAD("HEAD"),
//
// /**
// * HTTP POST method matcher.
// */
// POST("POST"),
//
// /**
// * HTTP PUT method matcher.
// */
// PUT("PUT"),
//
// /**
// * HTTP DELETE method matcher.
// */
// DELETE("DELETE"),
//
// /**
// * HTTP PATCH method matcher.
// */
// PATCH("PATCH"),
//
// /**
// * HTTP OPTIONS method matcher.
// */
// OPTIONS("OPTIONS"),
//
// /**
// * HTTP TRACE method matcher.
// */
// TRACE("TRACE");
//
// private final String value;
//
// HttpMethod(final String value) {
// this.value = value;
// }
//
// /**
// * Retrieve the text value for the method.
// *
// * @return the method label.
// */
// public String getValue() {
// return value;
// }
//
// @Override public String toString() {
// return value;
// }
// }
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/impl/GetExpectationsTest.java
import io.github.cjstehno.ersatz.cfg.HttpMethod;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import static org.hamcrest.CoreMatchers.startsWith;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.impl;
class GetExpectationsTest extends ExpectationHarness {
GetExpectationsTest() {
|
super(HttpMethod.GET);
|
cjstehno/ersatz
|
ersatz/src/main/java/io/github/cjstehno/ersatz/impl/UnmatchedRequestReport.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/server/ClientRequest.java
// public interface ClientRequest {
//
// /**
// * Retrieves the HTTP method for the request.
// *
// * @return the HTTP method for the request
// */
// HttpMethod getMethod();
//
// /**
// * Used to retrieve the request protocol, generally HTTP or HTTPS.
// *
// * @return the request protocol
// */
// String getProtocol();
//
// /**
// * Retrieves the request path.
// *
// * @return the request path
// */
// String getPath();
//
// /**
// * Retrieves the URL query string parameters for the request.
// *
// * @return the query string parameters
// */
// Map<String, Deque<String>> getQueryParams();
//
// /**
// * Retrieves the request headers.
// *
// * @return the request headers
// */
// Map<String, Deque<String>> getHeaders();
//
// /**
// * Retrieves the cookies associated with the request.
// *
// * @return the request cookies
// */
// Map<String, Cookie> getCookies();
//
// /**
// * Retrieves the body content (if any) as a byte array (null for an empty request).
// *
// * @return the optional body content as a byte array.
// */
// byte[] getBody();
//
// /**
// * Retrieves request parameters specified in the body content, if any.
// *
// * @return a Map containing the body parameters
// */
// Map<String, Deque<String> > getBodyParameters();
//
// /**
// * Retrieves the content length of the request.
// *
// * @return the request content length
// */
// long getContentLength();
//
// /**
// * Retrieves the request character encoding.
// *
// * @return the request character encoding
// */
// String getCharacterEncoding();
//
// /**
// * Retrieves the request content type. Generally this will only be present for requests with body content.
// *
// * @return the request content type
// */
// String getContentType();
// }
|
import io.github.cjstehno.ersatz.server.ClientRequest;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static java.util.stream.Collectors.joining;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.impl;
/**
* Helper object used to build and render a report of the unmatched request and the configured expectations.
*/
public class UnmatchedRequestReport implements Report {
private static final List<String> TEXT_CONTENT_HINTS = List.of("text/", "/json", "application/x-www-form-urlencoded");
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/server/ClientRequest.java
// public interface ClientRequest {
//
// /**
// * Retrieves the HTTP method for the request.
// *
// * @return the HTTP method for the request
// */
// HttpMethod getMethod();
//
// /**
// * Used to retrieve the request protocol, generally HTTP or HTTPS.
// *
// * @return the request protocol
// */
// String getProtocol();
//
// /**
// * Retrieves the request path.
// *
// * @return the request path
// */
// String getPath();
//
// /**
// * Retrieves the URL query string parameters for the request.
// *
// * @return the query string parameters
// */
// Map<String, Deque<String>> getQueryParams();
//
// /**
// * Retrieves the request headers.
// *
// * @return the request headers
// */
// Map<String, Deque<String>> getHeaders();
//
// /**
// * Retrieves the cookies associated with the request.
// *
// * @return the request cookies
// */
// Map<String, Cookie> getCookies();
//
// /**
// * Retrieves the body content (if any) as a byte array (null for an empty request).
// *
// * @return the optional body content as a byte array.
// */
// byte[] getBody();
//
// /**
// * Retrieves request parameters specified in the body content, if any.
// *
// * @return a Map containing the body parameters
// */
// Map<String, Deque<String> > getBodyParameters();
//
// /**
// * Retrieves the content length of the request.
// *
// * @return the request content length
// */
// long getContentLength();
//
// /**
// * Retrieves the request character encoding.
// *
// * @return the request character encoding
// */
// String getCharacterEncoding();
//
// /**
// * Retrieves the request content type. Generally this will only be present for requests with body content.
// *
// * @return the request content type
// */
// String getContentType();
// }
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/impl/UnmatchedRequestReport.java
import io.github.cjstehno.ersatz.server.ClientRequest;
import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import static java.util.stream.Collectors.joining;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.impl;
/**
* Helper object used to build and render a report of the unmatched request and the configured expectations.
*/
public class UnmatchedRequestReport implements Report {
private static final List<String> TEXT_CONTENT_HINTS = List.of("text/", "/json", "application/x-www-form-urlencoded");
|
private final ClientRequest request;
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/util/ByteArraysTest.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/util/ByteArrays.java
// public class ByteArrays {
//
// /**
// * Joins all of the byte arrays in the list, in order.
// *
// * @param arrays the list of byte arrays
// * @return a joined list of byte arrays
// */
// public static byte[] join(final List<byte[]> arrays) {
// byte[] current = new byte[0];
//
// for (final byte[] array : arrays) {
// current = join(current, array);
// }
//
// return current;
// }
//
// /**
// * Joins the two byte arrays into a single byte array, as first, then second.
// *
// * @param first the first byte array
// * @param second the second byte array
// * @return a merged byte array of the two in order
// */
// public static byte[] join(final byte[] first, final byte[] second) {
// byte[] combined = new byte[first.length + second.length];
// arraycopy(first, 0, combined, 0, first.length);
// arraycopy(second, 0, combined, first.length, second.length);
// return combined;
// }
//
// /**
// * Used to join the array of <code>ByteBuffer</code>s into a single array of bytes.
// *
// * @param buffers the ByteBuffers to be joined
// * @return a byte array container the merged bytes from the buffers
// */
// public static byte[] join(final ByteBuffer[] buffers) {
// byte[] incoming = new byte[0];
//
// for (final ByteBuffer b : buffers) {
// final byte[] data = new byte[b.remaining()];
// b.get(data);
// incoming = join(incoming, data);
// }
//
// return incoming;
// }
// }
|
import io.github.cjstehno.ersatz.util.ByteArrays;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.util;
class ByteArraysTest {
private static final byte[] A_0 = "first byte array".getBytes();
private static final byte[] A_1 = "second byte array".getBytes();
private static final byte[] A_2 = "third byte array".getBytes();
@Test @DisplayName("joining two byte arrays")
void joining_two() {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/util/ByteArrays.java
// public class ByteArrays {
//
// /**
// * Joins all of the byte arrays in the list, in order.
// *
// * @param arrays the list of byte arrays
// * @return a joined list of byte arrays
// */
// public static byte[] join(final List<byte[]> arrays) {
// byte[] current = new byte[0];
//
// for (final byte[] array : arrays) {
// current = join(current, array);
// }
//
// return current;
// }
//
// /**
// * Joins the two byte arrays into a single byte array, as first, then second.
// *
// * @param first the first byte array
// * @param second the second byte array
// * @return a merged byte array of the two in order
// */
// public static byte[] join(final byte[] first, final byte[] second) {
// byte[] combined = new byte[first.length + second.length];
// arraycopy(first, 0, combined, 0, first.length);
// arraycopy(second, 0, combined, first.length, second.length);
// return combined;
// }
//
// /**
// * Used to join the array of <code>ByteBuffer</code>s into a single array of bytes.
// *
// * @param buffers the ByteBuffers to be joined
// * @return a byte array container the merged bytes from the buffers
// */
// public static byte[] join(final ByteBuffer[] buffers) {
// byte[] incoming = new byte[0];
//
// for (final ByteBuffer b : buffers) {
// final byte[] data = new byte[b.remaining()];
// b.get(data);
// incoming = join(incoming, data);
// }
//
// return incoming;
// }
// }
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/util/ByteArraysTest.java
import io.github.cjstehno.ersatz.util.ByteArrays;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.nio.ByteBuffer;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.util;
class ByteArraysTest {
private static final byte[] A_0 = "first byte array".getBytes();
private static final byte[] A_1 = "second byte array".getBytes();
private static final byte[] A_2 = "third byte array".getBytes();
@Test @DisplayName("joining two byte arrays")
void joining_two() {
|
final var result = ByteArrays.join(A_0, A_1);
|
cjstehno/ersatz
|
ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ServerConfig.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/encdec/DecodingContext.java
// @RequiredArgsConstructor @Getter
// public class DecodingContext {
//
// private final long contentLength;
// private final String contentType;
// private final String characterEncoding;
// private final DecoderChain decoderChain;
// }
|
import io.github.cjstehno.ersatz.encdec.DecodingContext;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Configuration interface for an Ersatz server instance.
*/
public interface ServerConfig {
/**
* Used to control the enabled/disabled state of HTTPS on the server. By default HTTPS is disabled.
*
* @param enabled whether or not HTTPS support is enabled
* @return a reference to the server being configured
*/
ServerConfig https(boolean enabled);
/**
* Used to enabled HTTPS on the server. By default HTTPS is disabled.
*
* @return a reference to the server being configured
*/
ServerConfig https();
/**
* Used to enable/disable the auto-start feature, which will start the server after any call to either of the <code>expectations</code>
* configuration methods. With this setting enabled, any other calls to the <code>start()</code> method are ignored. Further configuration is
* allowed.
* <p>
* Auto-start is enabled by default.
*
* @param enabled whether or not auto-start is enabled
* @return a reference to the server being configured
*/
ServerConfig autoStart(boolean enabled);
/**
* Used to specify the server request timeout property value on the server.
*
* @param value the timeout value
* @param units the units the timeout is specified with
* @return a reference to the server being configured
*/
ServerConfig timeout(int value, TimeUnit units);
/**
* Used to specify the server request timeout property value on the server, in seconds.
*
* @param value the timeout value
* @return a reference to the server being configured
*/
ServerConfig timeout(int value);
/**
* Causes the mismatched request reports to be generated as console output, rather than only in the logging.
*
* @return a reference to the server being configured
*/
ServerConfig reportToConsole();
/**
* Used to toggle the console output of mismatched request reports. By default they are only rendered in the logging. A value of <code>true</code>
* will cause the report to be output on the console as well.
*
* @param toConsole whether or not the report should also be written to the console
* @return a reference to the server being configured
*/
ServerConfig reportToConsole(boolean toConsole);
/**
* Allows configuration of an external HTTPS keystore with the given location and password. By default, if this is not specified an internally
* provided keystore will be used for HTTPS certification. See the User Guide for details about configuring your own keystore.
*
* @param location the URL of the keystore file
* @param password the keystore file password
* @return a reference to the server being configured
*/
ServerConfig keystore(URL location, String password);
/**
* Allows configuration of an external HTTPS keystore with the given location (using the default password "ersatz"). By default, if this is not
* specified an internally provided keystore will be used for HTTPS certification. See the User Guide for details about configuring your own
* keystore.
*
* @param location the URL of the keystore file
* @return a reference to the server being configured
*/
ServerConfig keystore(URL location);
/**
* Used to configure HTTP expectations on the server; the provided <code>Consumer<Expectations></code> implementation will have an active
* <code>Expectations</code> object passed into it for configuring server interaction expectations.
*
* If auto-start is enabled (default) the server will be started after the expectations are applied.
*
* @param expects the <code>Consumer<Expectations></code> instance to perform the configuration
* @return a reference to this server
*/
ServerConfig expectations(final Consumer<Expectations> expects);
/**
* An alternate means of starting the expectation chain.
*
* @return the reference to the Expectation configuration object
*/
Expectations expects();
/**
* Configures the given request content decoder for the specified request content-type. The decoder will be configured globally and used if no
* overriding decoder is provided during expectation configuration.
*
* @param contentType the request content-type
* @param decoder the request content decoder
* @return the reference to the server configuration
*/
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/encdec/DecodingContext.java
// @RequiredArgsConstructor @Getter
// public class DecodingContext {
//
// private final long contentLength;
// private final String contentType;
// private final String characterEncoding;
// private final DecoderChain decoderChain;
// }
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ServerConfig.java
import io.github.cjstehno.ersatz.encdec.DecodingContext;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Configuration interface for an Ersatz server instance.
*/
public interface ServerConfig {
/**
* Used to control the enabled/disabled state of HTTPS on the server. By default HTTPS is disabled.
*
* @param enabled whether or not HTTPS support is enabled
* @return a reference to the server being configured
*/
ServerConfig https(boolean enabled);
/**
* Used to enabled HTTPS on the server. By default HTTPS is disabled.
*
* @return a reference to the server being configured
*/
ServerConfig https();
/**
* Used to enable/disable the auto-start feature, which will start the server after any call to either of the <code>expectations</code>
* configuration methods. With this setting enabled, any other calls to the <code>start()</code> method are ignored. Further configuration is
* allowed.
* <p>
* Auto-start is enabled by default.
*
* @param enabled whether or not auto-start is enabled
* @return a reference to the server being configured
*/
ServerConfig autoStart(boolean enabled);
/**
* Used to specify the server request timeout property value on the server.
*
* @param value the timeout value
* @param units the units the timeout is specified with
* @return a reference to the server being configured
*/
ServerConfig timeout(int value, TimeUnit units);
/**
* Used to specify the server request timeout property value on the server, in seconds.
*
* @param value the timeout value
* @return a reference to the server being configured
*/
ServerConfig timeout(int value);
/**
* Causes the mismatched request reports to be generated as console output, rather than only in the logging.
*
* @return a reference to the server being configured
*/
ServerConfig reportToConsole();
/**
* Used to toggle the console output of mismatched request reports. By default they are only rendered in the logging. A value of <code>true</code>
* will cause the report to be output on the console as well.
*
* @param toConsole whether or not the report should also be written to the console
* @return a reference to the server being configured
*/
ServerConfig reportToConsole(boolean toConsole);
/**
* Allows configuration of an external HTTPS keystore with the given location and password. By default, if this is not specified an internally
* provided keystore will be used for HTTPS certification. See the User Guide for details about configuring your own keystore.
*
* @param location the URL of the keystore file
* @param password the keystore file password
* @return a reference to the server being configured
*/
ServerConfig keystore(URL location, String password);
/**
* Allows configuration of an external HTTPS keystore with the given location (using the default password "ersatz"). By default, if this is not
* specified an internally provided keystore will be used for HTTPS certification. See the User Guide for details about configuring your own
* keystore.
*
* @param location the URL of the keystore file
* @return a reference to the server being configured
*/
ServerConfig keystore(URL location);
/**
* Used to configure HTTP expectations on the server; the provided <code>Consumer<Expectations></code> implementation will have an active
* <code>Expectations</code> object passed into it for configuring server interaction expectations.
*
* If auto-start is enabled (default) the server will be started after the expectations are applied.
*
* @param expects the <code>Consumer<Expectations></code> instance to perform the configuration
* @return a reference to this server
*/
ServerConfig expectations(final Consumer<Expectations> expects);
/**
* An alternate means of starting the expectation chain.
*
* @return the reference to the Expectation configuration object
*/
Expectations expects();
/**
* Configures the given request content decoder for the specified request content-type. The decoder will be configured globally and used if no
* overriding decoder is provided during expectation configuration.
*
* @param contentType the request content-type
* @param decoder the request content decoder
* @return the reference to the server configuration
*/
|
ServerConfig decoder(final String contentType, final BiFunction<byte[], DecodingContext, Object> decoder);
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/MultipartPartTest.java
|
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/TestAssertions.java
// static void verifyEqualityAndHashCode(final Object instanceA, final Object instanceB) {
// assertThat(instanceA, equalTo(instanceA));
// assertThat(instanceB, equalTo(instanceB));
// assertThat(instanceA, equalTo(instanceB));
// assertThat(instanceB, equalTo(instanceA));
// assertThat(instanceA, not(equalTo(null)));
// assertThat(instanceB, not(equalTo(null)));
// assertThat(instanceA.hashCode(), equalTo(instanceA.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceA.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceA.hashCode()));
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ContentType.java
// public static final ContentType IMAGE_PNG = new ContentType("image/png");
|
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static io.github.cjstehno.ersatz.TestAssertions.verifyEqualityAndHashCode;
import static io.github.cjstehno.ersatz.cfg.ContentType.IMAGE_PNG;
import static org.junit.jupiter.api.Assertions.assertEquals;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class MultipartPartTest {
private MultipartPart multipartPart() {
return new MultipartPart("file", "file.txt", "text/plain", "binary", "some file");
}
@Test @DisplayName("properties") void properties() {
final var part = multipartPart();
assertEquals("file", part.getFieldName());
assertEquals("file.txt", part.getFileName());
assertEquals("text/plain", part.getContentType());
assertEquals("binary", part.getTransferEncoding());
assertEquals("some file", part.getValue());
}
@Test @DisplayName("equals and hashCode")
void equalsAndHash() {
|
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/TestAssertions.java
// static void verifyEqualityAndHashCode(final Object instanceA, final Object instanceB) {
// assertThat(instanceA, equalTo(instanceA));
// assertThat(instanceB, equalTo(instanceB));
// assertThat(instanceA, equalTo(instanceB));
// assertThat(instanceB, equalTo(instanceA));
// assertThat(instanceA, not(equalTo(null)));
// assertThat(instanceB, not(equalTo(null)));
// assertThat(instanceA.hashCode(), equalTo(instanceA.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceA.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceA.hashCode()));
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ContentType.java
// public static final ContentType IMAGE_PNG = new ContentType("image/png");
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/MultipartPartTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static io.github.cjstehno.ersatz.TestAssertions.verifyEqualityAndHashCode;
import static io.github.cjstehno.ersatz.cfg.ContentType.IMAGE_PNG;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class MultipartPartTest {
private MultipartPart multipartPart() {
return new MultipartPart("file", "file.txt", "text/plain", "binary", "some file");
}
@Test @DisplayName("properties") void properties() {
final var part = multipartPart();
assertEquals("file", part.getFieldName());
assertEquals("file.txt", part.getFileName());
assertEquals("text/plain", part.getContentType());
assertEquals("binary", part.getTransferEncoding());
assertEquals("some file", part.getValue());
}
@Test @DisplayName("equals and hashCode")
void equalsAndHash() {
|
verifyEqualityAndHashCode(multipartPart(), multipartPart());
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/MultipartPartTest.java
|
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/TestAssertions.java
// static void verifyEqualityAndHashCode(final Object instanceA, final Object instanceB) {
// assertThat(instanceA, equalTo(instanceA));
// assertThat(instanceB, equalTo(instanceB));
// assertThat(instanceA, equalTo(instanceB));
// assertThat(instanceB, equalTo(instanceA));
// assertThat(instanceA, not(equalTo(null)));
// assertThat(instanceB, not(equalTo(null)));
// assertThat(instanceA.hashCode(), equalTo(instanceA.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceA.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceA.hashCode()));
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ContentType.java
// public static final ContentType IMAGE_PNG = new ContentType("image/png");
|
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static io.github.cjstehno.ersatz.TestAssertions.verifyEqualityAndHashCode;
import static io.github.cjstehno.ersatz.cfg.ContentType.IMAGE_PNG;
import static org.junit.jupiter.api.Assertions.assertEquals;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class MultipartPartTest {
private MultipartPart multipartPart() {
return new MultipartPart("file", "file.txt", "text/plain", "binary", "some file");
}
@Test @DisplayName("properties") void properties() {
final var part = multipartPart();
assertEquals("file", part.getFieldName());
assertEquals("file.txt", part.getFileName());
assertEquals("text/plain", part.getContentType());
assertEquals("binary", part.getTransferEncoding());
assertEquals("some file", part.getValue());
}
@Test @DisplayName("equals and hashCode")
void equalsAndHash() {
verifyEqualityAndHashCode(multipartPart(), multipartPart());
}
@Test @DisplayName("string")
void string() {
assertEquals(
"MultipartPart(fieldName=file, fileName=file.txt, contentType=text/plain, transferEncoding=binary, value=some file)",
multipartPart().toString()
);
}
@Test @DisplayName("equalsAndHash with bytes")
void equalsAndHashWithBytes(){
verifyEqualityAndHashCode(
|
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/TestAssertions.java
// static void verifyEqualityAndHashCode(final Object instanceA, final Object instanceB) {
// assertThat(instanceA, equalTo(instanceA));
// assertThat(instanceB, equalTo(instanceB));
// assertThat(instanceA, equalTo(instanceB));
// assertThat(instanceB, equalTo(instanceA));
// assertThat(instanceA, not(equalTo(null)));
// assertThat(instanceB, not(equalTo(null)));
// assertThat(instanceA.hashCode(), equalTo(instanceA.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceA.hashCode(), equalTo(instanceB.hashCode()));
// assertThat(instanceB.hashCode(), equalTo(instanceA.hashCode()));
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ContentType.java
// public static final ContentType IMAGE_PNG = new ContentType("image/png");
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/MultipartPartTest.java
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static io.github.cjstehno.ersatz.TestAssertions.verifyEqualityAndHashCode;
import static io.github.cjstehno.ersatz.cfg.ContentType.IMAGE_PNG;
import static org.junit.jupiter.api.Assertions.assertEquals;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class MultipartPartTest {
private MultipartPart multipartPart() {
return new MultipartPart("file", "file.txt", "text/plain", "binary", "some file");
}
@Test @DisplayName("properties") void properties() {
final var part = multipartPart();
assertEquals("file", part.getFieldName());
assertEquals("file.txt", part.getFileName());
assertEquals("text/plain", part.getContentType());
assertEquals("binary", part.getTransferEncoding());
assertEquals("some file", part.getValue());
}
@Test @DisplayName("equals and hashCode")
void equalsAndHash() {
verifyEqualityAndHashCode(multipartPart(), multipartPart());
}
@Test @DisplayName("string")
void string() {
assertEquals(
"MultipartPart(fieldName=file, fileName=file.txt, contentType=text/plain, transferEncoding=binary, value=some file)",
multipartPart().toString()
);
}
@Test @DisplayName("equalsAndHash with bytes")
void equalsAndHashWithBytes(){
verifyEqualityAndHashCode(
|
new MultipartPart("charlie", null, IMAGE_PNG.getValue(), null, new byte[]{8, 6, 7, 5, 3, 0, 9}),
|
cjstehno/ersatz
|
ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/PatchExpectations.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
|
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available PATCH request expectations.
*/
public interface PatchExpectations {
/**
* Allows configuration of a PATCH request expectation.
*
* @param path the expected request path
* @return a <code>RequestWithContent</code> configuration object
*/
default RequestWithContent PATCH(String path) {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/PatchExpectations.java
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available PATCH request expectations.
*/
public interface PatchExpectations {
/**
* Allows configuration of a PATCH request expectation.
*
* @param path the expected request path
* @return a <code>RequestWithContent</code> configuration object
*/
default RequestWithContent PATCH(String path) {
|
return PATCH(pathMatcher(path));
|
cjstehno/ersatz
|
ersatz/src/main/java/io/github/cjstehno/ersatz/encdec/Encoders.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/util/ByteArrays.java
// public static byte[] join(final List<byte[]> arrays) {
// byte[] current = new byte[0];
//
// for (final byte[] array : arrays) {
// current = join(current, array);
// }
//
// return current;
// }
|
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.LinkedList;
import java.util.function.Function;
import static io.github.cjstehno.ersatz.util.ByteArrays.join;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllBytes;
|
throw new IllegalArgumentException(obj.getClass().getName() + " found, MultipartRequestContent is required.");
}
final ErsatzMultipartResponseContent mrc = (ErsatzMultipartResponseContent) obj;
final var arrays = new LinkedList<byte[]>();
mrc.parts().forEach(p -> {
arrays.add(("--" + mrc.getBoundary() + "\r\n").getBytes(UTF_8));
if (p.getFileName() != null) {
arrays.add(("Content-Disposition: form-data; name=\"" + p.getFieldName() + "\"; filename=\"" + p.getFileName() + "\"\r\n").getBytes(UTF_8));
} else {
arrays.add(("Content-Disposition: form-data; name=\"" + p.getFieldName() + "\"\r\n").getBytes(UTF_8));
}
if (p.getTransferEncoding() != null) {
arrays.add(("Content-Transfer-Encoding: " + p.getTransferEncoding() + "\r\n").getBytes(UTF_8));
}
arrays.add(("Content-Type: " + p.getContentType() + "\r\n\r\n").getBytes(UTF_8));
final Function<Object, byte[]> encoderFn = mrc.encoder(p.getContentType(), p.getValue().getClass());
final var encoded = encoderFn.apply(p.getValue());
arrays.add(encoded);
arrays.add("\r\n".getBytes(UTF_8));
});
arrays.add(("--" + mrc.getBoundary() + "--\r\n").getBytes(UTF_8));
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/util/ByteArrays.java
// public static byte[] join(final List<byte[]> arrays) {
// byte[] current = new byte[0];
//
// for (final byte[] array : arrays) {
// current = join(current, array);
// }
//
// return current;
// }
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/encdec/Encoders.java
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.nio.charset.Charset;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Base64;
import java.util.LinkedList;
import java.util.function.Function;
import static io.github.cjstehno.ersatz.util.ByteArrays.join;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.nio.file.Files.readAllBytes;
throw new IllegalArgumentException(obj.getClass().getName() + " found, MultipartRequestContent is required.");
}
final ErsatzMultipartResponseContent mrc = (ErsatzMultipartResponseContent) obj;
final var arrays = new LinkedList<byte[]>();
mrc.parts().forEach(p -> {
arrays.add(("--" + mrc.getBoundary() + "\r\n").getBytes(UTF_8));
if (p.getFileName() != null) {
arrays.add(("Content-Disposition: form-data; name=\"" + p.getFieldName() + "\"; filename=\"" + p.getFileName() + "\"\r\n").getBytes(UTF_8));
} else {
arrays.add(("Content-Disposition: form-data; name=\"" + p.getFieldName() + "\"\r\n").getBytes(UTF_8));
}
if (p.getTransferEncoding() != null) {
arrays.add(("Content-Transfer-Encoding: " + p.getTransferEncoding() + "\r\n").getBytes(UTF_8));
}
arrays.add(("Content-Type: " + p.getContentType() + "\r\n\r\n").getBytes(UTF_8));
final Function<Object, byte[]> encoderFn = mrc.encoder(p.getContentType(), p.getValue().getClass());
final var encoded = encoderFn.apply(p.getValue());
arrays.add(encoded);
arrays.add("\r\n".getBytes(UTF_8));
});
arrays.add(("--" + mrc.getBoundary() + "--\r\n").getBytes(UTF_8));
|
return join(arrays);
|
cjstehno/ersatz
|
ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/OptionsExpectations.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
|
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available OPTIONS request expectations.
*/
public interface OptionsExpectations {
/**
* Allows configuration of a OPTIONS request expectation.
*
* @param path the expected request path.
* @return a <code>Request</code> configuration object
*/
default Request OPTIONS(String path) {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/OptionsExpectations.java
import org.hamcrest.Matcher;
import java.util.function.Consumer;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.cfg;
/**
* Defines the available OPTIONS request expectations.
*/
public interface OptionsExpectations {
/**
* Allows configuration of a OPTIONS request expectation.
*
* @param path the expected request path.
* @return a <code>Request</code> configuration object
*/
default Request OPTIONS(String path) {
|
return OPTIONS(pathMatcher(path));
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/match/ErsatzMatchersTest.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// public interface ErsatzMatchers {
//
// /**
// * Matcher that matches a request path. A wildcard (*) may be used to match any request path.
// *
// * @param path the path to be matched or * for wildcard
// * @return the matcher
// */
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
//
// /**
// * Matcher that matches if the object is an Iterable of Strings whose elements match (in any order) the provided
// * matchers.
// *
// * @param matchers the element matchers
// * @return the wrapping matcher
// */
// static Matcher<Iterable<? super String>> stringIterableMatcher(final Collection<Matcher<? super String>> matchers) {
// return new StringIterableMatcher(matchers);
// }
//
// /**
// * The provided value must be a byte array with the same length and same first and last element values.
// *
// * @param array the array
// * @return the resulting matcher
// */
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// /**
// * The provided function is used to verify the match, wrapped in a Matcher.
// *
// * @param fun the function being wrapped (a true response implies a match)
// * @param <T> the type of object(s) being matched
// * @return the function wrapped in a matcher
// */
// static <T> Matcher<T> functionMatcher(final Function<T, Boolean> fun) {
// return new FunctionMatcher<>(fun);
// }
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
|
import io.github.cjstehno.ersatz.match.ErsatzMatchers;
import lombok.val;
import org.hamcrest.StringDescription;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.List;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.byteArrayLike;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.jupiter.api.Assertions.*;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.match;
class ErsatzMatchersTest {
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"*,/alpha/bravo,true",
"*,/other,true",
"/foo,/foo,true",
"/foo,/bar,false",
"/foo,/foo/bar,false"
})
void matchingPaths(final String pattern, final String value, final boolean matches) {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// public interface ErsatzMatchers {
//
// /**
// * Matcher that matches a request path. A wildcard (*) may be used to match any request path.
// *
// * @param path the path to be matched or * for wildcard
// * @return the matcher
// */
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
//
// /**
// * Matcher that matches if the object is an Iterable of Strings whose elements match (in any order) the provided
// * matchers.
// *
// * @param matchers the element matchers
// * @return the wrapping matcher
// */
// static Matcher<Iterable<? super String>> stringIterableMatcher(final Collection<Matcher<? super String>> matchers) {
// return new StringIterableMatcher(matchers);
// }
//
// /**
// * The provided value must be a byte array with the same length and same first and last element values.
// *
// * @param array the array
// * @return the resulting matcher
// */
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// /**
// * The provided function is used to verify the match, wrapped in a Matcher.
// *
// * @param fun the function being wrapped (a true response implies a match)
// * @param <T> the type of object(s) being matched
// * @return the function wrapped in a matcher
// */
// static <T> Matcher<T> functionMatcher(final Function<T, Boolean> fun) {
// return new FunctionMatcher<>(fun);
// }
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/match/ErsatzMatchersTest.java
import io.github.cjstehno.ersatz.match.ErsatzMatchers;
import lombok.val;
import org.hamcrest.StringDescription;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.List;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.byteArrayLike;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.match;
class ErsatzMatchersTest {
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"*,/alpha/bravo,true",
"*,/other,true",
"/foo,/foo,true",
"/foo,/bar,false",
"/foo,/foo/bar,false"
})
void matchingPaths(final String pattern, final String value, final boolean matches) {
|
assertEquals(matches, pathMatcher(pattern).matches(value));
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/match/ErsatzMatchersTest.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// public interface ErsatzMatchers {
//
// /**
// * Matcher that matches a request path. A wildcard (*) may be used to match any request path.
// *
// * @param path the path to be matched or * for wildcard
// * @return the matcher
// */
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
//
// /**
// * Matcher that matches if the object is an Iterable of Strings whose elements match (in any order) the provided
// * matchers.
// *
// * @param matchers the element matchers
// * @return the wrapping matcher
// */
// static Matcher<Iterable<? super String>> stringIterableMatcher(final Collection<Matcher<? super String>> matchers) {
// return new StringIterableMatcher(matchers);
// }
//
// /**
// * The provided value must be a byte array with the same length and same first and last element values.
// *
// * @param array the array
// * @return the resulting matcher
// */
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// /**
// * The provided function is used to verify the match, wrapped in a Matcher.
// *
// * @param fun the function being wrapped (a true response implies a match)
// * @param <T> the type of object(s) being matched
// * @return the function wrapped in a matcher
// */
// static <T> Matcher<T> functionMatcher(final Function<T, Boolean> fun) {
// return new FunctionMatcher<>(fun);
// }
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
|
import io.github.cjstehno.ersatz.match.ErsatzMatchers;
import lombok.val;
import org.hamcrest.StringDescription;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.List;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.byteArrayLike;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.jupiter.api.Assertions.*;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.match;
class ErsatzMatchersTest {
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"*,/alpha/bravo,true",
"*,/other,true",
"/foo,/foo,true",
"/foo,/bar,false",
"/foo,/foo/bar,false"
})
void matchingPaths(final String pattern, final String value, final boolean matches) {
assertEquals(matches, pathMatcher(pattern).matches(value));
}
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"some bytes,some bytes,true",
"some bytes,other bytes,false"
})
void alikeByteArray(final String pattern, final String value, final boolean matches){
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// public interface ErsatzMatchers {
//
// /**
// * Matcher that matches a request path. A wildcard (*) may be used to match any request path.
// *
// * @param path the path to be matched or * for wildcard
// * @return the matcher
// */
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
//
// /**
// * Matcher that matches if the object is an Iterable of Strings whose elements match (in any order) the provided
// * matchers.
// *
// * @param matchers the element matchers
// * @return the wrapping matcher
// */
// static Matcher<Iterable<? super String>> stringIterableMatcher(final Collection<Matcher<? super String>> matchers) {
// return new StringIterableMatcher(matchers);
// }
//
// /**
// * The provided value must be a byte array with the same length and same first and last element values.
// *
// * @param array the array
// * @return the resulting matcher
// */
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// /**
// * The provided function is used to verify the match, wrapped in a Matcher.
// *
// * @param fun the function being wrapped (a true response implies a match)
// * @param <T> the type of object(s) being matched
// * @return the function wrapped in a matcher
// */
// static <T> Matcher<T> functionMatcher(final Function<T, Boolean> fun) {
// return new FunctionMatcher<>(fun);
// }
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/match/ErsatzMatchersTest.java
import io.github.cjstehno.ersatz.match.ErsatzMatchers;
import lombok.val;
import org.hamcrest.StringDescription;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.List;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.byteArrayLike;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.match;
class ErsatzMatchersTest {
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"*,/alpha/bravo,true",
"*,/other,true",
"/foo,/foo,true",
"/foo,/bar,false",
"/foo,/foo/bar,false"
})
void matchingPaths(final String pattern, final String value, final boolean matches) {
assertEquals(matches, pathMatcher(pattern).matches(value));
}
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"some bytes,some bytes,true",
"some bytes,other bytes,false"
})
void alikeByteArray(final String pattern, final String value, final boolean matches){
|
assertEquals(matches, byteArrayLike(pattern.getBytes(UTF_8)).matches(value.getBytes(UTF_8)));
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/match/ErsatzMatchersTest.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// public interface ErsatzMatchers {
//
// /**
// * Matcher that matches a request path. A wildcard (*) may be used to match any request path.
// *
// * @param path the path to be matched or * for wildcard
// * @return the matcher
// */
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
//
// /**
// * Matcher that matches if the object is an Iterable of Strings whose elements match (in any order) the provided
// * matchers.
// *
// * @param matchers the element matchers
// * @return the wrapping matcher
// */
// static Matcher<Iterable<? super String>> stringIterableMatcher(final Collection<Matcher<? super String>> matchers) {
// return new StringIterableMatcher(matchers);
// }
//
// /**
// * The provided value must be a byte array with the same length and same first and last element values.
// *
// * @param array the array
// * @return the resulting matcher
// */
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// /**
// * The provided function is used to verify the match, wrapped in a Matcher.
// *
// * @param fun the function being wrapped (a true response implies a match)
// * @param <T> the type of object(s) being matched
// * @return the function wrapped in a matcher
// */
// static <T> Matcher<T> functionMatcher(final Function<T, Boolean> fun) {
// return new FunctionMatcher<>(fun);
// }
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
|
import io.github.cjstehno.ersatz.match.ErsatzMatchers;
import lombok.val;
import org.hamcrest.StringDescription;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.List;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.byteArrayLike;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.jupiter.api.Assertions.*;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.match;
class ErsatzMatchersTest {
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"*,/alpha/bravo,true",
"*,/other,true",
"/foo,/foo,true",
"/foo,/bar,false",
"/foo,/foo/bar,false"
})
void matchingPaths(final String pattern, final String value, final boolean matches) {
assertEquals(matches, pathMatcher(pattern).matches(value));
}
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"some bytes,some bytes,true",
"some bytes,other bytes,false"
})
void alikeByteArray(final String pattern, final String value, final boolean matches){
assertEquals(matches, byteArrayLike(pattern.getBytes(UTF_8)).matches(value.getBytes(UTF_8)));
}
@Test @DisplayName("byte array matcher description")
void byteArrayMatcherDescription(){
val matcher = byteArrayLike("stuff".getBytes(UTF_8));
val desc = new StringDescription();
matcher.describeTo(desc);
assertEquals("A byte array of length 5 having 115 as the first element and 102 as the last.", desc.toString());
}
@Test @DisplayName("function matcher")
void functionMatcher(){
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// public interface ErsatzMatchers {
//
// /**
// * Matcher that matches a request path. A wildcard (*) may be used to match any request path.
// *
// * @param path the path to be matched or * for wildcard
// * @return the matcher
// */
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
//
// /**
// * Matcher that matches if the object is an Iterable of Strings whose elements match (in any order) the provided
// * matchers.
// *
// * @param matchers the element matchers
// * @return the wrapping matcher
// */
// static Matcher<Iterable<? super String>> stringIterableMatcher(final Collection<Matcher<? super String>> matchers) {
// return new StringIterableMatcher(matchers);
// }
//
// /**
// * The provided value must be a byte array with the same length and same first and last element values.
// *
// * @param array the array
// * @return the resulting matcher
// */
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// /**
// * The provided function is used to verify the match, wrapped in a Matcher.
// *
// * @param fun the function being wrapped (a true response implies a match)
// * @param <T> the type of object(s) being matched
// * @return the function wrapped in a matcher
// */
// static <T> Matcher<T> functionMatcher(final Function<T, Boolean> fun) {
// return new FunctionMatcher<>(fun);
// }
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<byte[]> byteArrayLike(final byte[] array) {
// return new ByteArrayMatcher(array);
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/match/ErsatzMatchers.java
// static Matcher<String> pathMatcher(final String path) {
// return path.equals("*") ? Matchers.any(String.class) : equalTo(path);
// }
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/match/ErsatzMatchersTest.java
import io.github.cjstehno.ersatz.match.ErsatzMatchers;
import lombok.val;
import org.hamcrest.StringDescription;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import java.util.List;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.byteArrayLike;
import static io.github.cjstehno.ersatz.match.ErsatzMatchers.pathMatcher;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.*;
import static org.junit.jupiter.api.Assertions.*;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.match;
class ErsatzMatchersTest {
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"*,/alpha/bravo,true",
"*,/other,true",
"/foo,/foo,true",
"/foo,/bar,false",
"/foo,/foo/bar,false"
})
void matchingPaths(final String pattern, final String value, final boolean matches) {
assertEquals(matches, pathMatcher(pattern).matches(value));
}
@ParameterizedTest(name = "[{index}] {0} matches {1} -> {2}")
@CsvSource({
"some bytes,some bytes,true",
"some bytes,other bytes,false"
})
void alikeByteArray(final String pattern, final String value, final boolean matches){
assertEquals(matches, byteArrayLike(pattern.getBytes(UTF_8)).matches(value.getBytes(UTF_8)));
}
@Test @DisplayName("byte array matcher description")
void byteArrayMatcherDescription(){
val matcher = byteArrayLike("stuff".getBytes(UTF_8));
val desc = new StringDescription();
matcher.describeTo(desc);
assertEquals("A byte array of length 5 having 115 as the first element and 102 as the last.", desc.toString());
}
@Test @DisplayName("function matcher")
void functionMatcher(){
|
val matcher = ErsatzMatchers.functionMatcher(x -> x instanceof String);
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/DecodersTest.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/encdec/Decoders.java
// public interface Decoders {
//
// /**
// * Decoder that simply passes the content bytes through as an array of bytes.
// */
// BiFunction<byte[], DecodingContext, Object> passthrough = (content, ctx) -> content;
//
// /**
// * Decoder that converts request content bytes into a UTF-8 string.
// */
// BiFunction<byte[], DecodingContext, Object> utf8String = string(UTF_8);
//
// /**
// * Decoder that converts request content bytes into a UTF-8 string.
// *
// * @return the decoded bytes as a string
// */
// static BiFunction<byte[], DecodingContext, Object> string() {
// return string(UTF_8);
// }
//
// /**
// * Decoder that converts request content bytes into a string of the specified charset.
// *
// * @param charset the name of the charset
// * @return the decoded bytes as a string
// */
// static BiFunction<byte[], DecodingContext, Object> string(final String charset) {
// return string(Charset.forName(charset));
// }
//
// /**
// * Decoder that converts request content bytes into a string of the specified charset.
// *
// * @param charset the charset to be used
// * @return the decoded bytes as a string
// */
// static BiFunction<byte[], DecodingContext, Object> string(final Charset charset) {
// return (content, ctx) -> content != null ? new String(content, charset) : "";
// }
//
// /**
// * Decoder that converts request content bytes in a url-encoded format into a map of name/value pairs.
// */
// BiFunction<byte[], DecodingContext, Object> urlEncoded = (content, ctx) -> {
// val map = new HashMap<String, String>();
//
// if (content != null) {
// for (val nvp : new String(content, UTF_8).split("&")) {
// val parts = nvp.split("=");
// try {
// if (parts.length == 2) {
// map.put(decode(parts[0], UTF_8.name()), decode(parts[1], UTF_8.name()));
// }
// } catch (Exception e) {
// throw new IllegalArgumentException(e.getMessage());
// }
// }
// }
//
// return map;
// };
//
// /**
// * Decoder that converts request content bytes into a <code>MultipartRequestContent</code> object populated with the multipart request content.
// */
// BiFunction<byte[], DecodingContext, Object> multipart = (content, ctx) -> {
// List<FileItem> parts;
// try {
// val tempDir = Files.createTempDirectory("ersatz-multipart-").toFile();
// parts = new FileUpload(new DiskFileItemFactory(10_000, tempDir)).parseRequest(new UploadContext() {
// @Override
// public long contentLength() {
// return ctx.getContentLength();
// }
//
// @Override
// public String getCharacterEncoding() {
// return ctx.getCharacterEncoding();
// }
//
// @Override
// public String getContentType() {
// return ctx.getContentType();
// }
//
// @Override
// public int getContentLength() {
// return (int) ctx.getContentLength();
// }
//
// @Override
// public InputStream getInputStream() throws IOException {
// return new ByteArrayInputStream(content);
// }
// });
// } catch (final Exception e) {
// throw new IllegalArgumentException(e.getMessage());
// }
//
// val multipartRequest = new MultipartRequestContent();
//
// parts.forEach(part -> {
// val partCtx = new DecodingContext(part.getSize(), part.getContentType(), null, ctx.getDecoderChain());
//
// if (part.isFormField()) {
// multipartRequest.part(part.getFieldName(), TEXT_PLAIN, ctx.getDecoderChain().resolve(TEXT_PLAIN).apply(part.get(), partCtx));
// } else {
// multipartRequest.part(
// part.getFieldName(),
// part.getName(),
// part.getContentType(),
// ctx.getDecoderChain().resolve(part.getContentType()).apply(part.get(), partCtx)
// );
// }
// });
//
// return multipartRequest;
// };
// }
|
import io.github.cjstehno.ersatz.encdec.Decoders;
import lombok.val;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.*;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class DecodersTest {
private static final String STRING = "this is a string!";
private static final byte[] STRING_BYTES_UTF = STRING.getBytes(UTF_8);
@Test void passthrough() {
final var bytes = new byte[10];
ThreadLocalRandom.current().nextBytes(bytes);
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/encdec/Decoders.java
// public interface Decoders {
//
// /**
// * Decoder that simply passes the content bytes through as an array of bytes.
// */
// BiFunction<byte[], DecodingContext, Object> passthrough = (content, ctx) -> content;
//
// /**
// * Decoder that converts request content bytes into a UTF-8 string.
// */
// BiFunction<byte[], DecodingContext, Object> utf8String = string(UTF_8);
//
// /**
// * Decoder that converts request content bytes into a UTF-8 string.
// *
// * @return the decoded bytes as a string
// */
// static BiFunction<byte[], DecodingContext, Object> string() {
// return string(UTF_8);
// }
//
// /**
// * Decoder that converts request content bytes into a string of the specified charset.
// *
// * @param charset the name of the charset
// * @return the decoded bytes as a string
// */
// static BiFunction<byte[], DecodingContext, Object> string(final String charset) {
// return string(Charset.forName(charset));
// }
//
// /**
// * Decoder that converts request content bytes into a string of the specified charset.
// *
// * @param charset the charset to be used
// * @return the decoded bytes as a string
// */
// static BiFunction<byte[], DecodingContext, Object> string(final Charset charset) {
// return (content, ctx) -> content != null ? new String(content, charset) : "";
// }
//
// /**
// * Decoder that converts request content bytes in a url-encoded format into a map of name/value pairs.
// */
// BiFunction<byte[], DecodingContext, Object> urlEncoded = (content, ctx) -> {
// val map = new HashMap<String, String>();
//
// if (content != null) {
// for (val nvp : new String(content, UTF_8).split("&")) {
// val parts = nvp.split("=");
// try {
// if (parts.length == 2) {
// map.put(decode(parts[0], UTF_8.name()), decode(parts[1], UTF_8.name()));
// }
// } catch (Exception e) {
// throw new IllegalArgumentException(e.getMessage());
// }
// }
// }
//
// return map;
// };
//
// /**
// * Decoder that converts request content bytes into a <code>MultipartRequestContent</code> object populated with the multipart request content.
// */
// BiFunction<byte[], DecodingContext, Object> multipart = (content, ctx) -> {
// List<FileItem> parts;
// try {
// val tempDir = Files.createTempDirectory("ersatz-multipart-").toFile();
// parts = new FileUpload(new DiskFileItemFactory(10_000, tempDir)).parseRequest(new UploadContext() {
// @Override
// public long contentLength() {
// return ctx.getContentLength();
// }
//
// @Override
// public String getCharacterEncoding() {
// return ctx.getCharacterEncoding();
// }
//
// @Override
// public String getContentType() {
// return ctx.getContentType();
// }
//
// @Override
// public int getContentLength() {
// return (int) ctx.getContentLength();
// }
//
// @Override
// public InputStream getInputStream() throws IOException {
// return new ByteArrayInputStream(content);
// }
// });
// } catch (final Exception e) {
// throw new IllegalArgumentException(e.getMessage());
// }
//
// val multipartRequest = new MultipartRequestContent();
//
// parts.forEach(part -> {
// val partCtx = new DecodingContext(part.getSize(), part.getContentType(), null, ctx.getDecoderChain());
//
// if (part.isFormField()) {
// multipartRequest.part(part.getFieldName(), TEXT_PLAIN, ctx.getDecoderChain().resolve(TEXT_PLAIN).apply(part.get(), partCtx));
// } else {
// multipartRequest.part(
// part.getFieldName(),
// part.getName(),
// part.getContentType(),
// ctx.getDecoderChain().resolve(part.getContentType()).apply(part.get(), partCtx)
// );
// }
// });
//
// return multipartRequest;
// };
// }
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/DecodersTest.java
import io.github.cjstehno.ersatz.encdec.Decoders;
import lombok.val;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.jupiter.api.Assertions.*;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class DecodersTest {
private static final String STRING = "this is a string!";
private static final byte[] STRING_BYTES_UTF = STRING.getBytes(UTF_8);
@Test void passthrough() {
final var bytes = new byte[10];
ThreadLocalRandom.current().nextBytes(bytes);
|
assertArrayEquals(bytes, (byte[]) Decoders.passthrough.apply(bytes, null));
|
cjstehno/ersatz
|
ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/ResponseEncodersTest.java
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/encdec/ResponseEncoders.java
// public class ResponseEncoders {
//
// private final List<EncoderMapping> encoders = new LinkedList<>();
//
// /**
// * Creates a response encoder container configured by the provided consumer.
// *
// * @param consumer the configuration consumer
// * @return the configured response encoders
// */
// public static ResponseEncoders encoders(final Consumer<ResponseEncoders> consumer) {
// final var encoders = new ResponseEncoders();
// consumer.accept(encoders);
// return encoders;
// }
//
// /**
// * Used to register an encoder for a content-type, part object type.
// *
// * @param contentType the part content-type
// * @param objectType the part object type
// * @param encoder the encoder function
// */
// public void register(final String contentType, final Class objectType, final Function<Object, byte[]> encoder) {
// encoders.add(new EncoderMapping(createMimeType(contentType), objectType, encoder));
// }
//
// /**
// * Used to register an encoder for a content-type, part object type.
// *
// * @param contentType the part content-type
// * @param objectType the part object type
// * @param encoder the encoder function
// */
// public void register(final ContentType contentType, final Class objectType, final Function<Object, byte[]> encoder) {
// register(contentType.getValue(), objectType, encoder);
// }
//
// /**
// * Used to find an encoder for the given content-type and object type.
// *
// * @param contentType the part content-type
// * @param objectType the part object type
// * @return the encoder function if one exists or null
// */
// public Function<Object, byte[]> findEncoder(final String contentType, final Class objectType) {
// final var mime = createMimeType(contentType);
//
// return encoders.stream()
// .filter(m -> m.contentType.match(mime) && m.objectType.isAssignableFrom(objectType))
// .findFirst()
// .map(m -> m.encoder)
// .orElse(null);
// }
//
// /**
// * Used to find an encoder for the given content-type and object type.
// * <p>
// * param contentType the part content-type
// *
// * @param contentType the response content type to be encoded
// * @param objectType the part object type
// * @return the encoder function if one exists or null
// */
// public Function<Object, byte[]> findEncoder(final ContentType contentType, final Class objectType) {
// return findEncoder(contentType.getValue(), objectType);
// }
//
// /**
// * Immutable mapping of a content-type and object type to an encoder.
// */
// private static class EncoderMapping {
//
// final MimeType contentType;
// final Class objectType;
// final Function<Object, byte[]> encoder;
//
// public EncoderMapping(MimeType contentType, Class objectType, Function<Object, byte[]> encoder) {
// this.contentType = contentType;
// this.objectType = objectType;
// this.encoder = encoder;
// }
// }
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ContentType.java
// public static final ContentType IMAGE_GIF = new ContentType("image/gif");
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ContentType.java
// public static final ContentType TEXT_PLAIN = new ContentType("text/plain");
|
import io.github.cjstehno.ersatz.encdec.ResponseEncoders;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.InputStream;
import java.util.function.Function;
import static io.github.cjstehno.ersatz.cfg.ContentType.IMAGE_GIF;
import static io.github.cjstehno.ersatz.cfg.ContentType.TEXT_PLAIN;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
|
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class ResponseEncodersTest {
private static final Function<Object, byte[]> ENCODER_A = o -> new byte[0];
private static final Function<Object, byte[]> ENCODER_B = o -> new byte[0];
@Test @DisplayName("encoders") void encoders() {
|
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/encdec/ResponseEncoders.java
// public class ResponseEncoders {
//
// private final List<EncoderMapping> encoders = new LinkedList<>();
//
// /**
// * Creates a response encoder container configured by the provided consumer.
// *
// * @param consumer the configuration consumer
// * @return the configured response encoders
// */
// public static ResponseEncoders encoders(final Consumer<ResponseEncoders> consumer) {
// final var encoders = new ResponseEncoders();
// consumer.accept(encoders);
// return encoders;
// }
//
// /**
// * Used to register an encoder for a content-type, part object type.
// *
// * @param contentType the part content-type
// * @param objectType the part object type
// * @param encoder the encoder function
// */
// public void register(final String contentType, final Class objectType, final Function<Object, byte[]> encoder) {
// encoders.add(new EncoderMapping(createMimeType(contentType), objectType, encoder));
// }
//
// /**
// * Used to register an encoder for a content-type, part object type.
// *
// * @param contentType the part content-type
// * @param objectType the part object type
// * @param encoder the encoder function
// */
// public void register(final ContentType contentType, final Class objectType, final Function<Object, byte[]> encoder) {
// register(contentType.getValue(), objectType, encoder);
// }
//
// /**
// * Used to find an encoder for the given content-type and object type.
// *
// * @param contentType the part content-type
// * @param objectType the part object type
// * @return the encoder function if one exists or null
// */
// public Function<Object, byte[]> findEncoder(final String contentType, final Class objectType) {
// final var mime = createMimeType(contentType);
//
// return encoders.stream()
// .filter(m -> m.contentType.match(mime) && m.objectType.isAssignableFrom(objectType))
// .findFirst()
// .map(m -> m.encoder)
// .orElse(null);
// }
//
// /**
// * Used to find an encoder for the given content-type and object type.
// * <p>
// * param contentType the part content-type
// *
// * @param contentType the response content type to be encoded
// * @param objectType the part object type
// * @return the encoder function if one exists or null
// */
// public Function<Object, byte[]> findEncoder(final ContentType contentType, final Class objectType) {
// return findEncoder(contentType.getValue(), objectType);
// }
//
// /**
// * Immutable mapping of a content-type and object type to an encoder.
// */
// private static class EncoderMapping {
//
// final MimeType contentType;
// final Class objectType;
// final Function<Object, byte[]> encoder;
//
// public EncoderMapping(MimeType contentType, Class objectType, Function<Object, byte[]> encoder) {
// this.contentType = contentType;
// this.objectType = objectType;
// this.encoder = encoder;
// }
// }
// }
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ContentType.java
// public static final ContentType IMAGE_GIF = new ContentType("image/gif");
//
// Path: ersatz/src/main/java/io/github/cjstehno/ersatz/cfg/ContentType.java
// public static final ContentType TEXT_PLAIN = new ContentType("text/plain");
// Path: ersatz/src/test/java/io/github/cjstehno/ersatz/encdec/ResponseEncodersTest.java
import io.github.cjstehno.ersatz.encdec.ResponseEncoders;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import java.io.File;
import java.io.InputStream;
import java.util.function.Function;
import static io.github.cjstehno.ersatz.cfg.ContentType.IMAGE_GIF;
import static io.github.cjstehno.ersatz.cfg.ContentType.TEXT_PLAIN;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
/**
* Copyright (C) 2022 Christopher J. Stehno
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.cjstehno.ersatz.encdec;
class ResponseEncodersTest {
private static final Function<Object, byte[]> ENCODER_A = o -> new byte[0];
private static final Function<Object, byte[]> ENCODER_B = o -> new byte[0];
@Test @DisplayName("encoders") void encoders() {
|
final var encoders = ResponseEncoders.encoders(e -> {
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.