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
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/services/security/CustomSecurityService.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/ROLES.java // public class ROLES { // private ROLES() { // } // // public static final String ROLE_ADMIN = "ROLE_ADMIN"; // // public static final String ADMIN = "ADMIN"; // // public static final String ROLE_PREFIX = "ROLE_"; // // public static final String LOCAL_ADMIN = "LOCAL_ADMIN"; // public static final String LOCAL_USER = "LOCAL_USER"; // } // // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Role.java // @Entity // public class Role extends BasicEntity implements GrantedAuthority { // // private static final long serialVersionUID = 1L; // // @NotEmpty // @Column(unique = true, nullable = false) // private String name; // // @JsonIgnore // @ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles") // private Set<User> users = new HashSet<User>(); // // @Override // public String getAuthority() { // return name; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Set<User> getUsers() { // return users; // } // // public void setUsers(Set<User> users) { // this.users = users; // } // // }
import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import io.github.pivopil.rest.constants.ROLES; import io.github.pivopil.share.entities.impl.Role; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.acls.domain.BasePermission; import org.springframework.security.acls.domain.ObjectIdentityRetrievalStrategyImpl; import org.springframework.security.acls.domain.PrincipalSid; import org.springframework.security.acls.model.*; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors;
private Authentication getAuthentication() { final SecurityContext context = SecurityContextHolder.getContext(); if (context == null) { return null; } return context.getAuthentication(); } private <T> Collection<T> getAuthorities(Class<T> clazz) { final Authentication authentication = getAuthentication(); if (authentication == null) { return new ArrayList<>(); } @SuppressWarnings("uncheked") Collection<T> authorities = (Collection<T>) getAuthentication().getAuthorities(); return authorities; } @Transactional(propagation= Propagation.REQUIRED) public <T> void addAclPermissions(T objectWithId) { ObjectIdentity objectIdentity = identityRetrievalStrategy.getObjectIdentity(objectWithId); mutableAclService.createAcl(objectIdentity); Boolean isRoleAdmin = isUserHasRole(ROLES.ROLE_ADMIN); // all posts are visible for ROLE_ADMIN customACLService.persistAllACLPermissionsForDomainObject(objectWithId, ROLES.ROLE_ADMIN, false); if (!isRoleAdmin) { // if user does not have ROLE_ADMIN check if he is LOCAL_ADMIN
// Path: rest/src/main/java/io/github/pivopil/rest/constants/ROLES.java // public class ROLES { // private ROLES() { // } // // public static final String ROLE_ADMIN = "ROLE_ADMIN"; // // public static final String ADMIN = "ADMIN"; // // public static final String ROLE_PREFIX = "ROLE_"; // // public static final String LOCAL_ADMIN = "LOCAL_ADMIN"; // public static final String LOCAL_USER = "LOCAL_USER"; // } // // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Role.java // @Entity // public class Role extends BasicEntity implements GrantedAuthority { // // private static final long serialVersionUID = 1L; // // @NotEmpty // @Column(unique = true, nullable = false) // private String name; // // @JsonIgnore // @ManyToMany(fetch = FetchType.LAZY, mappedBy = "roles") // private Set<User> users = new HashSet<User>(); // // @Override // public String getAuthority() { // return name; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public Set<User> getUsers() { // return users; // } // // public void setUsers(Set<User> users) { // this.users = users; // } // // } // Path: rest/src/main/java/io/github/pivopil/rest/services/security/CustomSecurityService.java import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import io.github.pivopil.rest.constants.ROLES; import io.github.pivopil.share.entities.impl.Role; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.acls.domain.BasePermission; import org.springframework.security.acls.domain.ObjectIdentityRetrievalStrategyImpl; import org.springframework.security.acls.domain.PrincipalSid; import org.springframework.security.acls.model.*; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContext; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import java.util.*; import java.util.stream.Collectors; private Authentication getAuthentication() { final SecurityContext context = SecurityContextHolder.getContext(); if (context == null) { return null; } return context.getAuthentication(); } private <T> Collection<T> getAuthorities(Class<T> clazz) { final Authentication authentication = getAuthentication(); if (authentication == null) { return new ArrayList<>(); } @SuppressWarnings("uncheked") Collection<T> authorities = (Collection<T>) getAuthentication().getAuthorities(); return authorities; } @Transactional(propagation= Propagation.REQUIRED) public <T> void addAclPermissions(T objectWithId) { ObjectIdentity objectIdentity = identityRetrievalStrategy.getObjectIdentity(objectWithId); mutableAclService.createAcl(objectIdentity); Boolean isRoleAdmin = isUserHasRole(ROLES.ROLE_ADMIN); // all posts are visible for ROLE_ADMIN customACLService.persistAllACLPermissionsForDomainObject(objectWithId, ROLES.ROLE_ADMIN, false); if (!isRoleAdmin) { // if user does not have ROLE_ADMIN check if he is LOCAL_ADMIN
List<Role> localAdminSet = getRolesNameContains(ROLES.LOCAL_ADMIN);
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/controllers/ErrorController.java
// Path: share/src/main/java/io/github/pivopil/share/exceptions/CustomOvalException.java // public class CustomOvalException extends RuntimeException { // // private final Map<String, List<String>> errorMap; // // public CustomOvalException(Map<String, List<String>> errorMap) { // super("Map with Oval validation exceptions"); // this.errorMap = errorMap; // } // // public Map<String, List<String>> getErrorMap() { // return errorMap; // } // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/ExceptionAdapter.java // public class ExceptionAdapter extends RuntimeException { // // private final String stackTrace; // private final Exception originalException; // // private final HttpStatus httpStatus; // private final ErrorCategory errorCategory; // private final int errorCode; // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus) { // this(message, error.code, error.category, httpStatus, null); // } // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus, Exception cause) { // this(message, error.code, error.category, httpStatus, cause); // } // // public ExceptionAdapter(String message, int errorCode, ErrorCategory errorCategory, HttpStatus httpStatus, // Exception cause) { // super(message, cause); // this.httpStatus = httpStatus; // this.errorCategory = errorCategory; // this.errorCode = errorCode; // this.stackTrace = cause.toString(); // this.originalException = cause; // } // // public ExceptionAdapter(Exception e) { // super(e.toString()); // originalException = e; // StringWriter sw = new StringWriter(); // e.printStackTrace(new PrintWriter(sw)); // stackTrace = sw.toString(); // // this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; // this.errorCategory = ErrorCategory.UNKNOWN; // this.errorCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); // } // // public void printStackTrace() { // printStackTrace(System.err); // } // public void printStackTrace(java.io.PrintStream s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public void printStackTrace(PrintWriter s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public Throwable rethrow() { return originalException; } // // public HttpStatus getHttpStatus() { // return httpStatus; // } // // public ErrorCategory getErrorCategory() { // return errorCategory; // } // // public int getErrorCode() { // return errorCode; // } // }
import com.google.common.collect.ImmutableMap; import io.github.pivopil.share.exceptions.CustomOvalException; import io.github.pivopil.share.exceptions.ExceptionAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map;
package io.github.pivopil.rest.controllers; /** * Created on 21.06.16. */ @ControllerAdvice(basePackageClasses = { ClientController.class, CompanyController.class, ContentController.class, MessageController.class, UserController.class, HomeController.class }) public class ErrorController extends ResponseEntityExceptionHandler { private static final Logger log = LoggerFactory.getLogger(ErrorController.class);
// Path: share/src/main/java/io/github/pivopil/share/exceptions/CustomOvalException.java // public class CustomOvalException extends RuntimeException { // // private final Map<String, List<String>> errorMap; // // public CustomOvalException(Map<String, List<String>> errorMap) { // super("Map with Oval validation exceptions"); // this.errorMap = errorMap; // } // // public Map<String, List<String>> getErrorMap() { // return errorMap; // } // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/ExceptionAdapter.java // public class ExceptionAdapter extends RuntimeException { // // private final String stackTrace; // private final Exception originalException; // // private final HttpStatus httpStatus; // private final ErrorCategory errorCategory; // private final int errorCode; // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus) { // this(message, error.code, error.category, httpStatus, null); // } // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus, Exception cause) { // this(message, error.code, error.category, httpStatus, cause); // } // // public ExceptionAdapter(String message, int errorCode, ErrorCategory errorCategory, HttpStatus httpStatus, // Exception cause) { // super(message, cause); // this.httpStatus = httpStatus; // this.errorCategory = errorCategory; // this.errorCode = errorCode; // this.stackTrace = cause.toString(); // this.originalException = cause; // } // // public ExceptionAdapter(Exception e) { // super(e.toString()); // originalException = e; // StringWriter sw = new StringWriter(); // e.printStackTrace(new PrintWriter(sw)); // stackTrace = sw.toString(); // // this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; // this.errorCategory = ErrorCategory.UNKNOWN; // this.errorCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); // } // // public void printStackTrace() { // printStackTrace(System.err); // } // public void printStackTrace(java.io.PrintStream s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public void printStackTrace(PrintWriter s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public Throwable rethrow() { return originalException; } // // public HttpStatus getHttpStatus() { // return httpStatus; // } // // public ErrorCategory getErrorCategory() { // return errorCategory; // } // // public int getErrorCode() { // return errorCode; // } // } // Path: rest/src/main/java/io/github/pivopil/rest/controllers/ErrorController.java import com.google.common.collect.ImmutableMap; import io.github.pivopil.share.exceptions.CustomOvalException; import io.github.pivopil.share.exceptions.ExceptionAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; package io.github.pivopil.rest.controllers; /** * Created on 21.06.16. */ @ControllerAdvice(basePackageClasses = { ClientController.class, CompanyController.class, ContentController.class, MessageController.class, UserController.class, HomeController.class }) public class ErrorController extends ResponseEntityExceptionHandler { private static final Logger log = LoggerFactory.getLogger(ErrorController.class);
@ExceptionHandler(ExceptionAdapter.class)
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/controllers/ErrorController.java
// Path: share/src/main/java/io/github/pivopil/share/exceptions/CustomOvalException.java // public class CustomOvalException extends RuntimeException { // // private final Map<String, List<String>> errorMap; // // public CustomOvalException(Map<String, List<String>> errorMap) { // super("Map with Oval validation exceptions"); // this.errorMap = errorMap; // } // // public Map<String, List<String>> getErrorMap() { // return errorMap; // } // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/ExceptionAdapter.java // public class ExceptionAdapter extends RuntimeException { // // private final String stackTrace; // private final Exception originalException; // // private final HttpStatus httpStatus; // private final ErrorCategory errorCategory; // private final int errorCode; // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus) { // this(message, error.code, error.category, httpStatus, null); // } // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus, Exception cause) { // this(message, error.code, error.category, httpStatus, cause); // } // // public ExceptionAdapter(String message, int errorCode, ErrorCategory errorCategory, HttpStatus httpStatus, // Exception cause) { // super(message, cause); // this.httpStatus = httpStatus; // this.errorCategory = errorCategory; // this.errorCode = errorCode; // this.stackTrace = cause.toString(); // this.originalException = cause; // } // // public ExceptionAdapter(Exception e) { // super(e.toString()); // originalException = e; // StringWriter sw = new StringWriter(); // e.printStackTrace(new PrintWriter(sw)); // stackTrace = sw.toString(); // // this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; // this.errorCategory = ErrorCategory.UNKNOWN; // this.errorCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); // } // // public void printStackTrace() { // printStackTrace(System.err); // } // public void printStackTrace(java.io.PrintStream s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public void printStackTrace(PrintWriter s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public Throwable rethrow() { return originalException; } // // public HttpStatus getHttpStatus() { // return httpStatus; // } // // public ErrorCategory getErrorCategory() { // return errorCategory; // } // // public int getErrorCode() { // return errorCode; // } // }
import com.google.common.collect.ImmutableMap; import io.github.pivopil.share.exceptions.CustomOvalException; import io.github.pivopil.share.exceptions.ExceptionAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map;
package io.github.pivopil.rest.controllers; /** * Created on 21.06.16. */ @ControllerAdvice(basePackageClasses = { ClientController.class, CompanyController.class, ContentController.class, MessageController.class, UserController.class, HomeController.class }) public class ErrorController extends ResponseEntityExceptionHandler { private static final Logger log = LoggerFactory.getLogger(ErrorController.class); @ExceptionHandler(ExceptionAdapter.class) @ResponseBody ResponseEntity<?> handleControllerException(HttpServletRequest request, ExceptionAdapter ex) { HttpStatus status = getStatus(request); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON_UTF8); try { throw ex.rethrow();
// Path: share/src/main/java/io/github/pivopil/share/exceptions/CustomOvalException.java // public class CustomOvalException extends RuntimeException { // // private final Map<String, List<String>> errorMap; // // public CustomOvalException(Map<String, List<String>> errorMap) { // super("Map with Oval validation exceptions"); // this.errorMap = errorMap; // } // // public Map<String, List<String>> getErrorMap() { // return errorMap; // } // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/ExceptionAdapter.java // public class ExceptionAdapter extends RuntimeException { // // private final String stackTrace; // private final Exception originalException; // // private final HttpStatus httpStatus; // private final ErrorCategory errorCategory; // private final int errorCode; // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus) { // this(message, error.code, error.category, httpStatus, null); // } // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus, Exception cause) { // this(message, error.code, error.category, httpStatus, cause); // } // // public ExceptionAdapter(String message, int errorCode, ErrorCategory errorCategory, HttpStatus httpStatus, // Exception cause) { // super(message, cause); // this.httpStatus = httpStatus; // this.errorCategory = errorCategory; // this.errorCode = errorCode; // this.stackTrace = cause.toString(); // this.originalException = cause; // } // // public ExceptionAdapter(Exception e) { // super(e.toString()); // originalException = e; // StringWriter sw = new StringWriter(); // e.printStackTrace(new PrintWriter(sw)); // stackTrace = sw.toString(); // // this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; // this.errorCategory = ErrorCategory.UNKNOWN; // this.errorCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); // } // // public void printStackTrace() { // printStackTrace(System.err); // } // public void printStackTrace(java.io.PrintStream s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public void printStackTrace(PrintWriter s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public Throwable rethrow() { return originalException; } // // public HttpStatus getHttpStatus() { // return httpStatus; // } // // public ErrorCategory getErrorCategory() { // return errorCategory; // } // // public int getErrorCode() { // return errorCode; // } // } // Path: rest/src/main/java/io/github/pivopil/rest/controllers/ErrorController.java import com.google.common.collect.ImmutableMap; import io.github.pivopil.share.exceptions.CustomOvalException; import io.github.pivopil.share.exceptions.ExceptionAdapter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; import javax.servlet.http.HttpServletRequest; import java.util.HashMap; import java.util.List; import java.util.Map; package io.github.pivopil.rest.controllers; /** * Created on 21.06.16. */ @ControllerAdvice(basePackageClasses = { ClientController.class, CompanyController.class, ContentController.class, MessageController.class, UserController.class, HomeController.class }) public class ErrorController extends ResponseEntityExceptionHandler { private static final Logger log = LoggerFactory.getLogger(ErrorController.class); @ExceptionHandler(ExceptionAdapter.class) @ResponseBody ResponseEntity<?> handleControllerException(HttpServletRequest request, ExceptionAdapter ex) { HttpStatus status = getStatus(request); HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_JSON_UTF8); try { throw ex.rethrow();
} catch (CustomOvalException e) {
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/test/java/io/github/pivopil/ContentControllerTest.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/REST_API.java // public class REST_API { // // private REST_API() { // } // // public static final String ME = "/me"; // public static final String USERS = "/api/users"; // public static final String CLIENTS = "/api/clients"; // public static final String COMPANIES = "/api/companies"; // public static final String CONTENT = "/api/content"; // public static final String ID_PATH_VARIABLE = "/{id}"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/controllers/UserController.java // @RestController // @RequestMapping(REST_API.USERS) // public class UserController { // // private final CustomUserDetailsService customUserDetailsService; // // @Autowired // public UserController(CustomUserDetailsService customUserDetailsService) { // this.customUserDetailsService = customUserDetailsService; // } // // @GetMapping(REST_API.ME) // public UserDetails me() { // return customUserDetailsService.me(); // } // // @GetMapping // public Iterable<User> getUsers() { // return customUserDetailsService.findAll(); // } // // @GetMapping(REST_API.ID_PATH_VARIABLE) // public UserViewModel getSingle(@PathVariable("id") Long id) { // return customUserDetailsService.getSingle(id); // } // // @PostMapping // public UserViewModel createUser(@RequestBody User user) { // return customUserDetailsService.createNewUser(user); // } // // @PutMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void updateUser(@RequestBody User user, @PathVariable("id") Long id) { // user.setId(id); // customUserDetailsService.edit(user); // } // // @DeleteMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void removeUser(@PathVariable("id") Long id) { // customUserDetailsService.deleteById(id); // } // // @PostMapping(REST_API.ID_PATH_VARIABLE + "/disable") // @ResponseStatus(HttpStatus.NO_CONTENT) // public void disableUser(@PathVariable("id") Long id) { // customUserDetailsService.disableById(id); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Content.java // @Entity // public class Content extends BasicEntity { // String title; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // }
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.github.pivopil.rest.constants.REST_API; import io.github.pivopil.rest.controllers.UserController; import io.github.pivopil.share.entities.impl.Content; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.security.web.FilterChainProxy; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import java.util.List; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
package io.github.pivopil; /** * Created on 07.07.16. */ @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @SpringBootTest(classes = Application.class) @TestPropertySource(locations = "classpath:test.properties") public class ContentControllerTest extends AbstractRestTest { @Autowired private WebApplicationContext context; @Autowired private FilterChainProxy springSecurityFilterChain; @Autowired private ObjectMapper mapper; @InjectMocks
// Path: rest/src/main/java/io/github/pivopil/rest/constants/REST_API.java // public class REST_API { // // private REST_API() { // } // // public static final String ME = "/me"; // public static final String USERS = "/api/users"; // public static final String CLIENTS = "/api/clients"; // public static final String COMPANIES = "/api/companies"; // public static final String CONTENT = "/api/content"; // public static final String ID_PATH_VARIABLE = "/{id}"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/controllers/UserController.java // @RestController // @RequestMapping(REST_API.USERS) // public class UserController { // // private final CustomUserDetailsService customUserDetailsService; // // @Autowired // public UserController(CustomUserDetailsService customUserDetailsService) { // this.customUserDetailsService = customUserDetailsService; // } // // @GetMapping(REST_API.ME) // public UserDetails me() { // return customUserDetailsService.me(); // } // // @GetMapping // public Iterable<User> getUsers() { // return customUserDetailsService.findAll(); // } // // @GetMapping(REST_API.ID_PATH_VARIABLE) // public UserViewModel getSingle(@PathVariable("id") Long id) { // return customUserDetailsService.getSingle(id); // } // // @PostMapping // public UserViewModel createUser(@RequestBody User user) { // return customUserDetailsService.createNewUser(user); // } // // @PutMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void updateUser(@RequestBody User user, @PathVariable("id") Long id) { // user.setId(id); // customUserDetailsService.edit(user); // } // // @DeleteMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void removeUser(@PathVariable("id") Long id) { // customUserDetailsService.deleteById(id); // } // // @PostMapping(REST_API.ID_PATH_VARIABLE + "/disable") // @ResponseStatus(HttpStatus.NO_CONTENT) // public void disableUser(@PathVariable("id") Long id) { // customUserDetailsService.disableById(id); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Content.java // @Entity // public class Content extends BasicEntity { // String title; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // } // Path: rest/src/test/java/io/github/pivopil/ContentControllerTest.java import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.github.pivopil.rest.constants.REST_API; import io.github.pivopil.rest.controllers.UserController; import io.github.pivopil.share.entities.impl.Content; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.security.web.FilterChainProxy; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import java.util.List; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; package io.github.pivopil; /** * Created on 07.07.16. */ @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @SpringBootTest(classes = Application.class) @TestPropertySource(locations = "classpath:test.properties") public class ContentControllerTest extends AbstractRestTest { @Autowired private WebApplicationContext context; @Autowired private FilterChainProxy springSecurityFilterChain; @Autowired private ObjectMapper mapper; @InjectMocks
private UserController controller;
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/test/java/io/github/pivopil/ContentControllerTest.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/REST_API.java // public class REST_API { // // private REST_API() { // } // // public static final String ME = "/me"; // public static final String USERS = "/api/users"; // public static final String CLIENTS = "/api/clients"; // public static final String COMPANIES = "/api/companies"; // public static final String CONTENT = "/api/content"; // public static final String ID_PATH_VARIABLE = "/{id}"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/controllers/UserController.java // @RestController // @RequestMapping(REST_API.USERS) // public class UserController { // // private final CustomUserDetailsService customUserDetailsService; // // @Autowired // public UserController(CustomUserDetailsService customUserDetailsService) { // this.customUserDetailsService = customUserDetailsService; // } // // @GetMapping(REST_API.ME) // public UserDetails me() { // return customUserDetailsService.me(); // } // // @GetMapping // public Iterable<User> getUsers() { // return customUserDetailsService.findAll(); // } // // @GetMapping(REST_API.ID_PATH_VARIABLE) // public UserViewModel getSingle(@PathVariable("id") Long id) { // return customUserDetailsService.getSingle(id); // } // // @PostMapping // public UserViewModel createUser(@RequestBody User user) { // return customUserDetailsService.createNewUser(user); // } // // @PutMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void updateUser(@RequestBody User user, @PathVariable("id") Long id) { // user.setId(id); // customUserDetailsService.edit(user); // } // // @DeleteMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void removeUser(@PathVariable("id") Long id) { // customUserDetailsService.deleteById(id); // } // // @PostMapping(REST_API.ID_PATH_VARIABLE + "/disable") // @ResponseStatus(HttpStatus.NO_CONTENT) // public void disableUser(@PathVariable("id") Long id) { // customUserDetailsService.disableById(id); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Content.java // @Entity // public class Content extends BasicEntity { // String title; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // }
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.github.pivopil.rest.constants.REST_API; import io.github.pivopil.rest.controllers.UserController; import io.github.pivopil.share.entities.impl.Content; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.security.web.FilterChainProxy; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import java.util.List; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
package io.github.pivopil; /** * Created on 07.07.16. */ @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @SpringBootTest(classes = Application.class) @TestPropertySource(locations = "classpath:test.properties") public class ContentControllerTest extends AbstractRestTest { @Autowired private WebApplicationContext context; @Autowired private FilterChainProxy springSecurityFilterChain; @Autowired private ObjectMapper mapper; @InjectMocks private UserController controller; private MockMvc mvc; @Before public void setUp() { MockitoAnnotations.initMocks(this); mvc = MockMvcBuilders.webAppContextSetup(context) .addFilter(springSecurityFilterChain).build(); } @Test public void adminContentCRUDTest() throws Exception { testCreateAndRemoveActionsForUserBy("adminLogin", "admin"); } // @Test // public void neoAdminContentCRUDTest() throws Exception { // testCreateAndRemoveActionsForUserBy("neoAdminLogin", "neoAdmin"); // } // @Test // public void neoUserContentCRUDTest() throws Exception { // testCreateAndRemoveActionsForUserBy("neoUserLogin", "neoUser"); // } private void testCreateAndRemoveActionsForUserBy(String login, String pass) throws Exception { String accessToken = getAccessToken(login, pass, mvc);
// Path: rest/src/main/java/io/github/pivopil/rest/constants/REST_API.java // public class REST_API { // // private REST_API() { // } // // public static final String ME = "/me"; // public static final String USERS = "/api/users"; // public static final String CLIENTS = "/api/clients"; // public static final String COMPANIES = "/api/companies"; // public static final String CONTENT = "/api/content"; // public static final String ID_PATH_VARIABLE = "/{id}"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/controllers/UserController.java // @RestController // @RequestMapping(REST_API.USERS) // public class UserController { // // private final CustomUserDetailsService customUserDetailsService; // // @Autowired // public UserController(CustomUserDetailsService customUserDetailsService) { // this.customUserDetailsService = customUserDetailsService; // } // // @GetMapping(REST_API.ME) // public UserDetails me() { // return customUserDetailsService.me(); // } // // @GetMapping // public Iterable<User> getUsers() { // return customUserDetailsService.findAll(); // } // // @GetMapping(REST_API.ID_PATH_VARIABLE) // public UserViewModel getSingle(@PathVariable("id") Long id) { // return customUserDetailsService.getSingle(id); // } // // @PostMapping // public UserViewModel createUser(@RequestBody User user) { // return customUserDetailsService.createNewUser(user); // } // // @PutMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void updateUser(@RequestBody User user, @PathVariable("id") Long id) { // user.setId(id); // customUserDetailsService.edit(user); // } // // @DeleteMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void removeUser(@PathVariable("id") Long id) { // customUserDetailsService.deleteById(id); // } // // @PostMapping(REST_API.ID_PATH_VARIABLE + "/disable") // @ResponseStatus(HttpStatus.NO_CONTENT) // public void disableUser(@PathVariable("id") Long id) { // customUserDetailsService.disableById(id); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Content.java // @Entity // public class Content extends BasicEntity { // String title; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // } // Path: rest/src/test/java/io/github/pivopil/ContentControllerTest.java import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.github.pivopil.rest.constants.REST_API; import io.github.pivopil.rest.controllers.UserController; import io.github.pivopil.share.entities.impl.Content; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.security.web.FilterChainProxy; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import java.util.List; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; package io.github.pivopil; /** * Created on 07.07.16. */ @RunWith(SpringJUnit4ClassRunner.class) @WebAppConfiguration @SpringBootTest(classes = Application.class) @TestPropertySource(locations = "classpath:test.properties") public class ContentControllerTest extends AbstractRestTest { @Autowired private WebApplicationContext context; @Autowired private FilterChainProxy springSecurityFilterChain; @Autowired private ObjectMapper mapper; @InjectMocks private UserController controller; private MockMvc mvc; @Before public void setUp() { MockitoAnnotations.initMocks(this); mvc = MockMvcBuilders.webAppContextSetup(context) .addFilter(springSecurityFilterChain).build(); } @Test public void adminContentCRUDTest() throws Exception { testCreateAndRemoveActionsForUserBy("adminLogin", "admin"); } // @Test // public void neoAdminContentCRUDTest() throws Exception { // testCreateAndRemoveActionsForUserBy("neoAdminLogin", "neoAdmin"); // } // @Test // public void neoUserContentCRUDTest() throws Exception { // testCreateAndRemoveActionsForUserBy("neoUserLogin", "neoUser"); // } private void testCreateAndRemoveActionsForUserBy(String login, String pass) throws Exception { String accessToken = getAccessToken(login, pass, mvc);
String contentAsString = mvc.perform(get(REST_API.CONTENT + "?title=" + login)
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/test/java/io/github/pivopil/ContentControllerTest.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/REST_API.java // public class REST_API { // // private REST_API() { // } // // public static final String ME = "/me"; // public static final String USERS = "/api/users"; // public static final String CLIENTS = "/api/clients"; // public static final String COMPANIES = "/api/companies"; // public static final String CONTENT = "/api/content"; // public static final String ID_PATH_VARIABLE = "/{id}"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/controllers/UserController.java // @RestController // @RequestMapping(REST_API.USERS) // public class UserController { // // private final CustomUserDetailsService customUserDetailsService; // // @Autowired // public UserController(CustomUserDetailsService customUserDetailsService) { // this.customUserDetailsService = customUserDetailsService; // } // // @GetMapping(REST_API.ME) // public UserDetails me() { // return customUserDetailsService.me(); // } // // @GetMapping // public Iterable<User> getUsers() { // return customUserDetailsService.findAll(); // } // // @GetMapping(REST_API.ID_PATH_VARIABLE) // public UserViewModel getSingle(@PathVariable("id") Long id) { // return customUserDetailsService.getSingle(id); // } // // @PostMapping // public UserViewModel createUser(@RequestBody User user) { // return customUserDetailsService.createNewUser(user); // } // // @PutMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void updateUser(@RequestBody User user, @PathVariable("id") Long id) { // user.setId(id); // customUserDetailsService.edit(user); // } // // @DeleteMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void removeUser(@PathVariable("id") Long id) { // customUserDetailsService.deleteById(id); // } // // @PostMapping(REST_API.ID_PATH_VARIABLE + "/disable") // @ResponseStatus(HttpStatus.NO_CONTENT) // public void disableUser(@PathVariable("id") Long id) { // customUserDetailsService.disableById(id); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Content.java // @Entity // public class Content extends BasicEntity { // String title; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // }
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.github.pivopil.rest.constants.REST_API; import io.github.pivopil.rest.controllers.UserController; import io.github.pivopil.share.entities.impl.Content; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.security.web.FilterChainProxy; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import java.util.List; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
public void setUp() { MockitoAnnotations.initMocks(this); mvc = MockMvcBuilders.webAppContextSetup(context) .addFilter(springSecurityFilterChain).build(); } @Test public void adminContentCRUDTest() throws Exception { testCreateAndRemoveActionsForUserBy("adminLogin", "admin"); } // @Test // public void neoAdminContentCRUDTest() throws Exception { // testCreateAndRemoveActionsForUserBy("neoAdminLogin", "neoAdmin"); // } // @Test // public void neoUserContentCRUDTest() throws Exception { // testCreateAndRemoveActionsForUserBy("neoUserLogin", "neoUser"); // } private void testCreateAndRemoveActionsForUserBy(String login, String pass) throws Exception { String accessToken = getAccessToken(login, pass, mvc); String contentAsString = mvc.perform(get(REST_API.CONTENT + "?title=" + login) .header("Authorization", "Bearer " + accessToken)) .andReturn().getResponse().getContentAsString(); if (contentAsString.equals("[]")) { // create content
// Path: rest/src/main/java/io/github/pivopil/rest/constants/REST_API.java // public class REST_API { // // private REST_API() { // } // // public static final String ME = "/me"; // public static final String USERS = "/api/users"; // public static final String CLIENTS = "/api/clients"; // public static final String COMPANIES = "/api/companies"; // public static final String CONTENT = "/api/content"; // public static final String ID_PATH_VARIABLE = "/{id}"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/controllers/UserController.java // @RestController // @RequestMapping(REST_API.USERS) // public class UserController { // // private final CustomUserDetailsService customUserDetailsService; // // @Autowired // public UserController(CustomUserDetailsService customUserDetailsService) { // this.customUserDetailsService = customUserDetailsService; // } // // @GetMapping(REST_API.ME) // public UserDetails me() { // return customUserDetailsService.me(); // } // // @GetMapping // public Iterable<User> getUsers() { // return customUserDetailsService.findAll(); // } // // @GetMapping(REST_API.ID_PATH_VARIABLE) // public UserViewModel getSingle(@PathVariable("id") Long id) { // return customUserDetailsService.getSingle(id); // } // // @PostMapping // public UserViewModel createUser(@RequestBody User user) { // return customUserDetailsService.createNewUser(user); // } // // @PutMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void updateUser(@RequestBody User user, @PathVariable("id") Long id) { // user.setId(id); // customUserDetailsService.edit(user); // } // // @DeleteMapping(REST_API.ID_PATH_VARIABLE) // @ResponseStatus(HttpStatus.NO_CONTENT) // public void removeUser(@PathVariable("id") Long id) { // customUserDetailsService.deleteById(id); // } // // @PostMapping(REST_API.ID_PATH_VARIABLE + "/disable") // @ResponseStatus(HttpStatus.NO_CONTENT) // public void disableUser(@PathVariable("id") Long id) { // customUserDetailsService.disableById(id); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Content.java // @Entity // public class Content extends BasicEntity { // String title; // // public String getTitle() { // return title; // } // // public void setTitle(String title) { // this.title = title; // } // } // Path: rest/src/test/java/io/github/pivopil/ContentControllerTest.java import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import io.github.pivopil.rest.constants.REST_API; import io.github.pivopil.rest.controllers.UserController; import io.github.pivopil.share.entities.impl.Content; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; import org.mockito.MockitoAnnotations; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.http.MediaType; import org.springframework.security.web.FilterChainProxy; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import org.springframework.web.context.WebApplicationContext; import java.util.List; import static org.hamcrest.Matchers.*; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; public void setUp() { MockitoAnnotations.initMocks(this); mvc = MockMvcBuilders.webAppContextSetup(context) .addFilter(springSecurityFilterChain).build(); } @Test public void adminContentCRUDTest() throws Exception { testCreateAndRemoveActionsForUserBy("adminLogin", "admin"); } // @Test // public void neoAdminContentCRUDTest() throws Exception { // testCreateAndRemoveActionsForUserBy("neoAdminLogin", "neoAdmin"); // } // @Test // public void neoUserContentCRUDTest() throws Exception { // testCreateAndRemoveActionsForUserBy("neoUserLogin", "neoUser"); // } private void testCreateAndRemoveActionsForUserBy(String login, String pass) throws Exception { String accessToken = getAccessToken(login, pass, mvc); String contentAsString = mvc.perform(get(REST_API.CONTENT + "?title=" + login) .header("Authorization", "Bearer " + accessToken)) .andReturn().getResponse().getContentAsString(); if (contentAsString.equals("[]")) { // create content
Content content = new Content();
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/config/ACLConfig.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/ROLES.java // public class ROLES { // private ROLES() { // } // // public static final String ROLE_ADMIN = "ROLE_ADMIN"; // // public static final String ADMIN = "ADMIN"; // // public static final String ROLE_PREFIX = "ROLE_"; // // public static final String LOCAL_ADMIN = "LOCAL_ADMIN"; // public static final String LOCAL_USER = "LOCAL_USER"; // }
import io.github.pivopil.rest.constants.ROLES; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.ehcache.EhCacheFactoryBean; import org.springframework.cache.ehcache.EhCacheManagerFactoryBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler; import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler; import org.springframework.security.acls.AclPermissionEvaluator; import org.springframework.security.acls.domain.*; import org.springframework.security.acls.jdbc.BasicLookupStrategy; import org.springframework.security.acls.jdbc.JdbcMutableAclService; import org.springframework.security.acls.jdbc.LookupStrategy; import org.springframework.security.acls.model.SidRetrievalStrategy; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration; import org.springframework.security.core.authority.SimpleGrantedAuthority; import javax.sql.DataSource;
@Bean public DefaultPermissionGrantingStrategy permissionGrantingStrategy() { ConsoleAuditLogger consoleAuditLogger = new ConsoleAuditLogger(); return new DefaultPermissionGrantingStrategy(consoleAuditLogger); } @Bean public EhCacheBasedAclCache aclCache() { return new EhCacheBasedAclCache(aclEhCacheFactoryBean().getObject(), permissionGrantingStrategy(), aclAuthorizationStrategy()); } @Bean public EhCacheFactoryBean aclEhCacheFactoryBean() { EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean(); ehCacheFactoryBean.setCacheManager(aclCacheManager().getObject()); ehCacheFactoryBean.setCacheName("aclCache"); return ehCacheFactoryBean; } @Bean public EhCacheManagerFactoryBean aclCacheManager() { return new EhCacheManagerFactoryBean(); } LookupStrategy lookupStrategy() { return new BasicLookupStrategy(dataSource, aclCache(), aclAuthorizationStrategy(), new ConsoleAuditLogger()); } AclAuthorizationStrategy aclAuthorizationStrategy() {
// Path: rest/src/main/java/io/github/pivopil/rest/constants/ROLES.java // public class ROLES { // private ROLES() { // } // // public static final String ROLE_ADMIN = "ROLE_ADMIN"; // // public static final String ADMIN = "ADMIN"; // // public static final String ROLE_PREFIX = "ROLE_"; // // public static final String LOCAL_ADMIN = "LOCAL_ADMIN"; // public static final String LOCAL_USER = "LOCAL_USER"; // } // Path: rest/src/main/java/io/github/pivopil/rest/config/ACLConfig.java import io.github.pivopil.rest.constants.ROLES; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cache.ehcache.EhCacheFactoryBean; import org.springframework.cache.ehcache.EhCacheManagerFactoryBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler; import org.springframework.security.access.expression.method.MethodSecurityExpressionHandler; import org.springframework.security.acls.AclPermissionEvaluator; import org.springframework.security.acls.domain.*; import org.springframework.security.acls.jdbc.BasicLookupStrategy; import org.springframework.security.acls.jdbc.JdbcMutableAclService; import org.springframework.security.acls.jdbc.LookupStrategy; import org.springframework.security.acls.model.SidRetrievalStrategy; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration; import org.springframework.security.core.authority.SimpleGrantedAuthority; import javax.sql.DataSource; @Bean public DefaultPermissionGrantingStrategy permissionGrantingStrategy() { ConsoleAuditLogger consoleAuditLogger = new ConsoleAuditLogger(); return new DefaultPermissionGrantingStrategy(consoleAuditLogger); } @Bean public EhCacheBasedAclCache aclCache() { return new EhCacheBasedAclCache(aclEhCacheFactoryBean().getObject(), permissionGrantingStrategy(), aclAuthorizationStrategy()); } @Bean public EhCacheFactoryBean aclEhCacheFactoryBean() { EhCacheFactoryBean ehCacheFactoryBean = new EhCacheFactoryBean(); ehCacheFactoryBean.setCacheManager(aclCacheManager().getObject()); ehCacheFactoryBean.setCacheName("aclCache"); return ehCacheFactoryBean; } @Bean public EhCacheManagerFactoryBean aclCacheManager() { return new EhCacheManagerFactoryBean(); } LookupStrategy lookupStrategy() { return new BasicLookupStrategy(dataSource, aclCache(), aclAuthorizationStrategy(), new ConsoleAuditLogger()); } AclAuthorizationStrategy aclAuthorizationStrategy() {
return new AclAuthorizationStrategyImpl(new SimpleGrantedAuthority(ROLES.ROLE_ADMIN),
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/config/WebSocketSecurityConfig.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java // public class WS_API { // private WS_API() { // // } // // public static final String HANDSHAKE = "/messages"; // public static final String INSTANT_MESSAGE = "/im"; // public static final String ACTIVE_USERS = "/users"; // public static final String QUEUE_MESSAGES = "/queue/messages"; // // public static final String QUEUE_DESTINATION_PREFIX = "/queue/"; // public static final String TOPIC_DESTINATION_PREFIX = "/topic/"; // public static final String APP_PREFIX = "/app"; // public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin"; // public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout"; // }
import io.github.pivopil.rest.constants.WS_API; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.SimpMessageType; import org.springframework.security.config.annotation.web.messaging.MessageSecurityMetadataSourceRegistry; import org.springframework.security.config.annotation.web.socket.AbstractSecurityWebSocketMessageBrokerConfigurer;
package io.github.pivopil.rest.config; @Configuration public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer { @Override protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) { messages .simpTypeMatchers(SimpMessageType.CONNECT, SimpMessageType.HEARTBEAT, SimpMessageType.UNSUBSCRIBE, SimpMessageType.DISCONNECT).permitAll() // matches any destination that starts with /rooms/
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java // public class WS_API { // private WS_API() { // // } // // public static final String HANDSHAKE = "/messages"; // public static final String INSTANT_MESSAGE = "/im"; // public static final String ACTIVE_USERS = "/users"; // public static final String QUEUE_MESSAGES = "/queue/messages"; // // public static final String QUEUE_DESTINATION_PREFIX = "/queue/"; // public static final String TOPIC_DESTINATION_PREFIX = "/topic/"; // public static final String APP_PREFIX = "/app"; // public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin"; // public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout"; // } // Path: rest/src/main/java/io/github/pivopil/rest/config/WebSocketSecurityConfig.java import io.github.pivopil.rest.constants.WS_API; import org.springframework.context.annotation.Configuration; import org.springframework.messaging.simp.SimpMessageType; import org.springframework.security.config.annotation.web.messaging.MessageSecurityMetadataSourceRegistry; import org.springframework.security.config.annotation.web.socket.AbstractSecurityWebSocketMessageBrokerConfigurer; package io.github.pivopil.rest.config; @Configuration public class WebSocketSecurityConfig extends AbstractSecurityWebSocketMessageBrokerConfigurer { @Override protected void configureInbound(MessageSecurityMetadataSourceRegistry messages) { messages .simpTypeMatchers(SimpMessageType.CONNECT, SimpMessageType.HEARTBEAT, SimpMessageType.UNSUBSCRIBE, SimpMessageType.DISCONNECT).permitAll() // matches any destination that starts with /rooms/
.simpDestMatchers(WS_API.QUEUE_DESTINATION_PREFIX + "**").authenticated()
Pivopil/spring-boot-oauth2-rest-service-password-encoding
share/src/main/java/io/github/pivopil/share/entities/impl/Client.java
// Path: share/src/main/java/io/github/pivopil/share/entities/BasicEntity.java // @MappedSuperclass // public class BasicEntity extends EntityWithId { // // private Date created; // // private Date updated; // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // // public Date getUpdated() { // return updated; // } // // public void setUpdated(Date updated) { // this.updated = updated; // } // // @PrePersist // protected void onCreate() { // this.created = new Date(); // } // // @PreUpdate // protected void onUpdate() { // this.updated = new Date(); // } // // }
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.deser.std.StringArrayDeserializer; import io.github.pivopil.share.entities.BasicEntity; import org.hibernate.validator.constraints.NotEmpty; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.Table; import java.util.Set;
package io.github.pivopil.share.entities.impl; /** * Created on 24.10.16. */ @Entity @Table(name = "custom_oauth_client_details")
// Path: share/src/main/java/io/github/pivopil/share/entities/BasicEntity.java // @MappedSuperclass // public class BasicEntity extends EntityWithId { // // private Date created; // // private Date updated; // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // // public Date getUpdated() { // return updated; // } // // public void setUpdated(Date updated) { // this.updated = updated; // } // // @PrePersist // protected void onCreate() { // this.created = new Date(); // } // // @PreUpdate // protected void onUpdate() { // this.updated = new Date(); // } // // } // Path: share/src/main/java/io/github/pivopil/share/entities/impl/Client.java import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.deser.std.StringArrayDeserializer; import io.github.pivopil.share.entities.BasicEntity; import org.hibernate.validator.constraints.NotEmpty; import javax.persistence.Column; import javax.persistence.ElementCollection; import javax.persistence.Entity; import javax.persistence.Table; import java.util.Set; package io.github.pivopil.share.entities.impl; /** * Created on 24.10.16. */ @Entity @Table(name = "custom_oauth_client_details")
public class Client extends BasicEntity {
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/controllers/MessageController.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java // public class WS_API { // private WS_API() { // // } // // public static final String HANDSHAKE = "/messages"; // public static final String INSTANT_MESSAGE = "/im"; // public static final String ACTIVE_USERS = "/users"; // public static final String QUEUE_MESSAGES = "/queue/messages"; // // public static final String QUEUE_DESTINATION_PREFIX = "/queue/"; // public static final String TOPIC_DESTINATION_PREFIX = "/topic/"; // public static final String APP_PREFIX = "/app"; // public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin"; // public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/models/InstantMessage.java // public class InstantMessage { // private String to; // // private String from; // // private String message; // // private Calendar created = Calendar.getInstance(); // // public String getTo() { // return this.to; // } // // public void setTo(String to) { // this.to = to; // } // // public String getFrom() { // return this.from; // } // // public void setFrom(String from) { // this.from = from; // } // // public String getMessage() { // return this.message; // } // // public void setMessage(String message) { // this.message = message; // } // // public Calendar getCreated() { // return this.created; // } // // public void setCreated(Calendar created) { // this.created = created; // } // // } // // Path: rest/src/main/java/io/github/pivopil/rest/services/ws/MessageService.java // @Service // public class MessageService { // // private final CustomSecurityService customSecurityService; // // private final SimpMessageSendingOperations messagingTemplate; // // private final ActiveWebSocketUserRepository activeUserRepository; // // // @Autowired // public MessageService(CustomSecurityService customSecurityService, SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository activeUserRepository) { // this.customSecurityService = customSecurityService; // this.messagingTemplate = messagingTemplate; // this.activeUserRepository = activeUserRepository; // } // // public void im(InstantMessage instantMessage) { // instantMessage.setFrom(customSecurityService.userLoginFromAuthentication()); // this.messagingTemplate.convertAndSendToUser(instantMessage.getTo(), WS_API.QUEUE_MESSAGES, instantMessage); // this.messagingTemplate.convertAndSendToUser(instantMessage.getFrom(), WS_API.QUEUE_MESSAGES, instantMessage); // } // // public List<String> getAllActiveUsers() { // return this.activeUserRepository.findAllActiveUsers(customSecurityService.userLoginFromAuthentication()); // } // }
import io.github.pivopil.rest.constants.WS_API; import io.github.pivopil.rest.models.InstantMessage; import io.github.pivopil.rest.services.ws.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.annotation.SubscribeMapping; import org.springframework.stereotype.Controller; import java.util.List;
package io.github.pivopil.rest.controllers; @Controller public class MessageController {
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java // public class WS_API { // private WS_API() { // // } // // public static final String HANDSHAKE = "/messages"; // public static final String INSTANT_MESSAGE = "/im"; // public static final String ACTIVE_USERS = "/users"; // public static final String QUEUE_MESSAGES = "/queue/messages"; // // public static final String QUEUE_DESTINATION_PREFIX = "/queue/"; // public static final String TOPIC_DESTINATION_PREFIX = "/topic/"; // public static final String APP_PREFIX = "/app"; // public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin"; // public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/models/InstantMessage.java // public class InstantMessage { // private String to; // // private String from; // // private String message; // // private Calendar created = Calendar.getInstance(); // // public String getTo() { // return this.to; // } // // public void setTo(String to) { // this.to = to; // } // // public String getFrom() { // return this.from; // } // // public void setFrom(String from) { // this.from = from; // } // // public String getMessage() { // return this.message; // } // // public void setMessage(String message) { // this.message = message; // } // // public Calendar getCreated() { // return this.created; // } // // public void setCreated(Calendar created) { // this.created = created; // } // // } // // Path: rest/src/main/java/io/github/pivopil/rest/services/ws/MessageService.java // @Service // public class MessageService { // // private final CustomSecurityService customSecurityService; // // private final SimpMessageSendingOperations messagingTemplate; // // private final ActiveWebSocketUserRepository activeUserRepository; // // // @Autowired // public MessageService(CustomSecurityService customSecurityService, SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository activeUserRepository) { // this.customSecurityService = customSecurityService; // this.messagingTemplate = messagingTemplate; // this.activeUserRepository = activeUserRepository; // } // // public void im(InstantMessage instantMessage) { // instantMessage.setFrom(customSecurityService.userLoginFromAuthentication()); // this.messagingTemplate.convertAndSendToUser(instantMessage.getTo(), WS_API.QUEUE_MESSAGES, instantMessage); // this.messagingTemplate.convertAndSendToUser(instantMessage.getFrom(), WS_API.QUEUE_MESSAGES, instantMessage); // } // // public List<String> getAllActiveUsers() { // return this.activeUserRepository.findAllActiveUsers(customSecurityService.userLoginFromAuthentication()); // } // } // Path: rest/src/main/java/io/github/pivopil/rest/controllers/MessageController.java import io.github.pivopil.rest.constants.WS_API; import io.github.pivopil.rest.models.InstantMessage; import io.github.pivopil.rest.services.ws.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.annotation.SubscribeMapping; import org.springframework.stereotype.Controller; import java.util.List; package io.github.pivopil.rest.controllers; @Controller public class MessageController {
private final MessageService messageService;
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/controllers/MessageController.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java // public class WS_API { // private WS_API() { // // } // // public static final String HANDSHAKE = "/messages"; // public static final String INSTANT_MESSAGE = "/im"; // public static final String ACTIVE_USERS = "/users"; // public static final String QUEUE_MESSAGES = "/queue/messages"; // // public static final String QUEUE_DESTINATION_PREFIX = "/queue/"; // public static final String TOPIC_DESTINATION_PREFIX = "/topic/"; // public static final String APP_PREFIX = "/app"; // public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin"; // public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/models/InstantMessage.java // public class InstantMessage { // private String to; // // private String from; // // private String message; // // private Calendar created = Calendar.getInstance(); // // public String getTo() { // return this.to; // } // // public void setTo(String to) { // this.to = to; // } // // public String getFrom() { // return this.from; // } // // public void setFrom(String from) { // this.from = from; // } // // public String getMessage() { // return this.message; // } // // public void setMessage(String message) { // this.message = message; // } // // public Calendar getCreated() { // return this.created; // } // // public void setCreated(Calendar created) { // this.created = created; // } // // } // // Path: rest/src/main/java/io/github/pivopil/rest/services/ws/MessageService.java // @Service // public class MessageService { // // private final CustomSecurityService customSecurityService; // // private final SimpMessageSendingOperations messagingTemplate; // // private final ActiveWebSocketUserRepository activeUserRepository; // // // @Autowired // public MessageService(CustomSecurityService customSecurityService, SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository activeUserRepository) { // this.customSecurityService = customSecurityService; // this.messagingTemplate = messagingTemplate; // this.activeUserRepository = activeUserRepository; // } // // public void im(InstantMessage instantMessage) { // instantMessage.setFrom(customSecurityService.userLoginFromAuthentication()); // this.messagingTemplate.convertAndSendToUser(instantMessage.getTo(), WS_API.QUEUE_MESSAGES, instantMessage); // this.messagingTemplate.convertAndSendToUser(instantMessage.getFrom(), WS_API.QUEUE_MESSAGES, instantMessage); // } // // public List<String> getAllActiveUsers() { // return this.activeUserRepository.findAllActiveUsers(customSecurityService.userLoginFromAuthentication()); // } // }
import io.github.pivopil.rest.constants.WS_API; import io.github.pivopil.rest.models.InstantMessage; import io.github.pivopil.rest.services.ws.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.annotation.SubscribeMapping; import org.springframework.stereotype.Controller; import java.util.List;
package io.github.pivopil.rest.controllers; @Controller public class MessageController { private final MessageService messageService; @Autowired public MessageController(MessageService messageService) { this.messageService = messageService; } // @Payload Object payload, @Headers Map<String, Object> headers
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java // public class WS_API { // private WS_API() { // // } // // public static final String HANDSHAKE = "/messages"; // public static final String INSTANT_MESSAGE = "/im"; // public static final String ACTIVE_USERS = "/users"; // public static final String QUEUE_MESSAGES = "/queue/messages"; // // public static final String QUEUE_DESTINATION_PREFIX = "/queue/"; // public static final String TOPIC_DESTINATION_PREFIX = "/topic/"; // public static final String APP_PREFIX = "/app"; // public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin"; // public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/models/InstantMessage.java // public class InstantMessage { // private String to; // // private String from; // // private String message; // // private Calendar created = Calendar.getInstance(); // // public String getTo() { // return this.to; // } // // public void setTo(String to) { // this.to = to; // } // // public String getFrom() { // return this.from; // } // // public void setFrom(String from) { // this.from = from; // } // // public String getMessage() { // return this.message; // } // // public void setMessage(String message) { // this.message = message; // } // // public Calendar getCreated() { // return this.created; // } // // public void setCreated(Calendar created) { // this.created = created; // } // // } // // Path: rest/src/main/java/io/github/pivopil/rest/services/ws/MessageService.java // @Service // public class MessageService { // // private final CustomSecurityService customSecurityService; // // private final SimpMessageSendingOperations messagingTemplate; // // private final ActiveWebSocketUserRepository activeUserRepository; // // // @Autowired // public MessageService(CustomSecurityService customSecurityService, SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository activeUserRepository) { // this.customSecurityService = customSecurityService; // this.messagingTemplate = messagingTemplate; // this.activeUserRepository = activeUserRepository; // } // // public void im(InstantMessage instantMessage) { // instantMessage.setFrom(customSecurityService.userLoginFromAuthentication()); // this.messagingTemplate.convertAndSendToUser(instantMessage.getTo(), WS_API.QUEUE_MESSAGES, instantMessage); // this.messagingTemplate.convertAndSendToUser(instantMessage.getFrom(), WS_API.QUEUE_MESSAGES, instantMessage); // } // // public List<String> getAllActiveUsers() { // return this.activeUserRepository.findAllActiveUsers(customSecurityService.userLoginFromAuthentication()); // } // } // Path: rest/src/main/java/io/github/pivopil/rest/controllers/MessageController.java import io.github.pivopil.rest.constants.WS_API; import io.github.pivopil.rest.models.InstantMessage; import io.github.pivopil.rest.services.ws.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.annotation.SubscribeMapping; import org.springframework.stereotype.Controller; import java.util.List; package io.github.pivopil.rest.controllers; @Controller public class MessageController { private final MessageService messageService; @Autowired public MessageController(MessageService messageService) { this.messageService = messageService; } // @Payload Object payload, @Headers Map<String, Object> headers
@MessageMapping(WS_API.INSTANT_MESSAGE)
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/controllers/MessageController.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java // public class WS_API { // private WS_API() { // // } // // public static final String HANDSHAKE = "/messages"; // public static final String INSTANT_MESSAGE = "/im"; // public static final String ACTIVE_USERS = "/users"; // public static final String QUEUE_MESSAGES = "/queue/messages"; // // public static final String QUEUE_DESTINATION_PREFIX = "/queue/"; // public static final String TOPIC_DESTINATION_PREFIX = "/topic/"; // public static final String APP_PREFIX = "/app"; // public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin"; // public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/models/InstantMessage.java // public class InstantMessage { // private String to; // // private String from; // // private String message; // // private Calendar created = Calendar.getInstance(); // // public String getTo() { // return this.to; // } // // public void setTo(String to) { // this.to = to; // } // // public String getFrom() { // return this.from; // } // // public void setFrom(String from) { // this.from = from; // } // // public String getMessage() { // return this.message; // } // // public void setMessage(String message) { // this.message = message; // } // // public Calendar getCreated() { // return this.created; // } // // public void setCreated(Calendar created) { // this.created = created; // } // // } // // Path: rest/src/main/java/io/github/pivopil/rest/services/ws/MessageService.java // @Service // public class MessageService { // // private final CustomSecurityService customSecurityService; // // private final SimpMessageSendingOperations messagingTemplate; // // private final ActiveWebSocketUserRepository activeUserRepository; // // // @Autowired // public MessageService(CustomSecurityService customSecurityService, SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository activeUserRepository) { // this.customSecurityService = customSecurityService; // this.messagingTemplate = messagingTemplate; // this.activeUserRepository = activeUserRepository; // } // // public void im(InstantMessage instantMessage) { // instantMessage.setFrom(customSecurityService.userLoginFromAuthentication()); // this.messagingTemplate.convertAndSendToUser(instantMessage.getTo(), WS_API.QUEUE_MESSAGES, instantMessage); // this.messagingTemplate.convertAndSendToUser(instantMessage.getFrom(), WS_API.QUEUE_MESSAGES, instantMessage); // } // // public List<String> getAllActiveUsers() { // return this.activeUserRepository.findAllActiveUsers(customSecurityService.userLoginFromAuthentication()); // } // }
import io.github.pivopil.rest.constants.WS_API; import io.github.pivopil.rest.models.InstantMessage; import io.github.pivopil.rest.services.ws.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.annotation.SubscribeMapping; import org.springframework.stereotype.Controller; import java.util.List;
package io.github.pivopil.rest.controllers; @Controller public class MessageController { private final MessageService messageService; @Autowired public MessageController(MessageService messageService) { this.messageService = messageService; } // @Payload Object payload, @Headers Map<String, Object> headers @MessageMapping(WS_API.INSTANT_MESSAGE)
// Path: rest/src/main/java/io/github/pivopil/rest/constants/WS_API.java // public class WS_API { // private WS_API() { // // } // // public static final String HANDSHAKE = "/messages"; // public static final String INSTANT_MESSAGE = "/im"; // public static final String ACTIVE_USERS = "/users"; // public static final String QUEUE_MESSAGES = "/queue/messages"; // // public static final String QUEUE_DESTINATION_PREFIX = "/queue/"; // public static final String TOPIC_DESTINATION_PREFIX = "/topic/"; // public static final String APP_PREFIX = "/app"; // public static final String TOPIC_FRIENDS_SIGNIN = "/topic/friends/signin"; // public static final String TOPIC_FRIENDS_SIGNOUT = "/topic/friends/signout"; // } // // Path: rest/src/main/java/io/github/pivopil/rest/models/InstantMessage.java // public class InstantMessage { // private String to; // // private String from; // // private String message; // // private Calendar created = Calendar.getInstance(); // // public String getTo() { // return this.to; // } // // public void setTo(String to) { // this.to = to; // } // // public String getFrom() { // return this.from; // } // // public void setFrom(String from) { // this.from = from; // } // // public String getMessage() { // return this.message; // } // // public void setMessage(String message) { // this.message = message; // } // // public Calendar getCreated() { // return this.created; // } // // public void setCreated(Calendar created) { // this.created = created; // } // // } // // Path: rest/src/main/java/io/github/pivopil/rest/services/ws/MessageService.java // @Service // public class MessageService { // // private final CustomSecurityService customSecurityService; // // private final SimpMessageSendingOperations messagingTemplate; // // private final ActiveWebSocketUserRepository activeUserRepository; // // // @Autowired // public MessageService(CustomSecurityService customSecurityService, SimpMessageSendingOperations messagingTemplate, ActiveWebSocketUserRepository activeUserRepository) { // this.customSecurityService = customSecurityService; // this.messagingTemplate = messagingTemplate; // this.activeUserRepository = activeUserRepository; // } // // public void im(InstantMessage instantMessage) { // instantMessage.setFrom(customSecurityService.userLoginFromAuthentication()); // this.messagingTemplate.convertAndSendToUser(instantMessage.getTo(), WS_API.QUEUE_MESSAGES, instantMessage); // this.messagingTemplate.convertAndSendToUser(instantMessage.getFrom(), WS_API.QUEUE_MESSAGES, instantMessage); // } // // public List<String> getAllActiveUsers() { // return this.activeUserRepository.findAllActiveUsers(customSecurityService.userLoginFromAuthentication()); // } // } // Path: rest/src/main/java/io/github/pivopil/rest/controllers/MessageController.java import io.github.pivopil.rest.constants.WS_API; import io.github.pivopil.rest.models.InstantMessage; import io.github.pivopil.rest.services.ws.MessageService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.annotation.SubscribeMapping; import org.springframework.stereotype.Controller; import java.util.List; package io.github.pivopil.rest.controllers; @Controller public class MessageController { private final MessageService messageService; @Autowired public MessageController(MessageService messageService) { this.messageService = messageService; } // @Payload Object payload, @Headers Map<String, Object> headers @MessageMapping(WS_API.INSTANT_MESSAGE)
public void im(InstantMessage im) {
Pivopil/spring-boot-oauth2-rest-service-password-encoding
rest/src/main/java/io/github/pivopil/rest/services/security/CustomACLService.java
// Path: rest/src/main/java/io/github/pivopil/rest/constants/ROLES.java // public class ROLES { // private ROLES() { // } // // public static final String ROLE_ADMIN = "ROLE_ADMIN"; // // public static final String ADMIN = "ADMIN"; // // public static final String ROLE_PREFIX = "ROLE_"; // // public static final String LOCAL_ADMIN = "LOCAL_ADMIN"; // public static final String LOCAL_USER = "LOCAL_USER"; // }
import io.github.pivopil.rest.constants.ROLES; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.acls.AclPermissionEvaluator; import org.springframework.security.acls.domain.BasePermission; import org.springframework.security.acls.domain.GrantedAuthoritySid; import org.springframework.security.acls.domain.ObjectIdentityRetrievalStrategyImpl; import org.springframework.security.acls.domain.PrincipalSid; import org.springframework.security.acls.jdbc.JdbcMutableAclService; import org.springframework.security.acls.model.*; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Service; import java.util.List;
List<AccessControlEntry> entries = mutableAcl.getEntries(); log.debug("Try to obtain sid by user data '{}'", userData); Sid sid = obtainSidObject(userData, isPrincipal); log.debug("Successfully got sid by user data '{}'", userData); log.debug("Try to update mutableAcl permission '{}' for object '{}' for user '{}'", permission, objectIdentity, userData); mutableAcl.insertAce(entries.size(), permission, sid, true); mutableAcl = mutableAclService.updateAcl(mutableAcl); log.debug("Successfully updated mutableAcl"); return mutableAcl; } private Sid obtainSidObject(Object userData, boolean isPrincipal) { log.debug("Try to get principal object from data '{}'", userData); if (userData instanceof Sid) { log.debug("Successfully got Sid object from data '{}'", userData); return Sid.class.cast(userData); } if (userData instanceof Authentication) { log.debug("Successfully got Authentication object from data '{}'", userData); return new PrincipalSid(Authentication.class.cast(userData)); } if (userData instanceof String) { String stringRecipient = String.class.cast(userData);
// Path: rest/src/main/java/io/github/pivopil/rest/constants/ROLES.java // public class ROLES { // private ROLES() { // } // // public static final String ROLE_ADMIN = "ROLE_ADMIN"; // // public static final String ADMIN = "ADMIN"; // // public static final String ROLE_PREFIX = "ROLE_"; // // public static final String LOCAL_ADMIN = "LOCAL_ADMIN"; // public static final String LOCAL_USER = "LOCAL_USER"; // } // Path: rest/src/main/java/io/github/pivopil/rest/services/security/CustomACLService.java import io.github.pivopil.rest.constants.ROLES; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.acls.AclPermissionEvaluator; import org.springframework.security.acls.domain.BasePermission; import org.springframework.security.acls.domain.GrantedAuthoritySid; import org.springframework.security.acls.domain.ObjectIdentityRetrievalStrategyImpl; import org.springframework.security.acls.domain.PrincipalSid; import org.springframework.security.acls.jdbc.JdbcMutableAclService; import org.springframework.security.acls.model.*; import org.springframework.security.core.Authentication; import org.springframework.stereotype.Service; import java.util.List; List<AccessControlEntry> entries = mutableAcl.getEntries(); log.debug("Try to obtain sid by user data '{}'", userData); Sid sid = obtainSidObject(userData, isPrincipal); log.debug("Successfully got sid by user data '{}'", userData); log.debug("Try to update mutableAcl permission '{}' for object '{}' for user '{}'", permission, objectIdentity, userData); mutableAcl.insertAce(entries.size(), permission, sid, true); mutableAcl = mutableAclService.updateAcl(mutableAcl); log.debug("Successfully updated mutableAcl"); return mutableAcl; } private Sid obtainSidObject(Object userData, boolean isPrincipal) { log.debug("Try to get principal object from data '{}'", userData); if (userData instanceof Sid) { log.debug("Successfully got Sid object from data '{}'", userData); return Sid.class.cast(userData); } if (userData instanceof Authentication) { log.debug("Successfully got Authentication object from data '{}'", userData); return new PrincipalSid(Authentication.class.cast(userData)); } if (userData instanceof String) { String stringRecipient = String.class.cast(userData);
boolean startsWithRolePrefix = stringRecipient.startsWith(ROLES.ROLE_PREFIX);
Pivopil/spring-boot-oauth2-rest-service-password-encoding
share/src/main/java/io/github/pivopil/share/builders/EntityBuilder.java
// Path: share/src/main/java/io/github/pivopil/share/entities/BasicEntity.java // @MappedSuperclass // public class BasicEntity extends EntityWithId { // // private Date created; // // private Date updated; // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // // public Date getUpdated() { // return updated; // } // // public void setUpdated(Date updated) { // this.updated = updated; // } // // @PrePersist // protected void onCreate() { // this.created = new Date(); // } // // @PreUpdate // protected void onUpdate() { // this.updated = new Date(); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/CustomOvalException.java // public class CustomOvalException extends RuntimeException { // // private final Map<String, List<String>> errorMap; // // public CustomOvalException(Map<String, List<String>> errorMap) { // super("Map with Oval validation exceptions"); // this.errorMap = errorMap; // } // // public Map<String, List<String>> getErrorMap() { // return errorMap; // } // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/ExceptionAdapter.java // public class ExceptionAdapter extends RuntimeException { // // private final String stackTrace; // private final Exception originalException; // // private final HttpStatus httpStatus; // private final ErrorCategory errorCategory; // private final int errorCode; // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus) { // this(message, error.code, error.category, httpStatus, null); // } // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus, Exception cause) { // this(message, error.code, error.category, httpStatus, cause); // } // // public ExceptionAdapter(String message, int errorCode, ErrorCategory errorCategory, HttpStatus httpStatus, // Exception cause) { // super(message, cause); // this.httpStatus = httpStatus; // this.errorCategory = errorCategory; // this.errorCode = errorCode; // this.stackTrace = cause.toString(); // this.originalException = cause; // } // // public ExceptionAdapter(Exception e) { // super(e.toString()); // originalException = e; // StringWriter sw = new StringWriter(); // e.printStackTrace(new PrintWriter(sw)); // stackTrace = sw.toString(); // // this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; // this.errorCategory = ErrorCategory.UNKNOWN; // this.errorCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); // } // // public void printStackTrace() { // printStackTrace(System.err); // } // public void printStackTrace(java.io.PrintStream s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public void printStackTrace(PrintWriter s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public Throwable rethrow() { return originalException; } // // public HttpStatus getHttpStatus() { // return httpStatus; // } // // public ErrorCategory getErrorCategory() { // return errorCategory; // } // // public int getErrorCode() { // return errorCode; // } // } // // Path: share/src/main/java/io/github/pivopil/share/viewmodels/ViewModel.java // public interface ViewModel<T> { // // Long getId(); // // void setId(Long id); // // Date getCreated(); // // void setCreated(Date created); // // Date getUpdated(); // // void setUpdated(Date updated); // // }
import io.github.pivopil.share.entities.BasicEntity; import io.github.pivopil.share.exceptions.CustomOvalException; import io.github.pivopil.share.exceptions.ExceptionAdapter; import io.github.pivopil.share.viewmodels.ViewModel; import net.sf.oval.ConstraintViolation; import net.sf.oval.Validator; import java.util.*;
package io.github.pivopil.share.builders; /** * Created on 06.05.16. */ public interface EntityBuilder<T extends BasicEntity, K extends EntityBuilder, V extends ViewModel<T>> { K newInstance(); V buildViewModel(); K newInstance(T entity); K id(Long val); K created(Date val); K updated(Date val); T build(); K withOvalValidator(Validator ovalValidator); default void validate(Validator ovalValidator) { if (ovalValidator != null) { List<ConstraintViolation> constraintViolations = ovalValidator.validate(this); if (constraintViolations.size() > 0) { final Map<String, List<String>> errorMap = new HashMap<>(); final String className = this.getClass().getName() + "."; constraintViolations .forEach(constraintViolation -> errorMap.computeIfAbsent(constraintViolation.getCheckDeclaringContext().toString().replace(className, ""), k -> new ArrayList<>()) .add(constraintViolation.getMessage().replace(className, "")));
// Path: share/src/main/java/io/github/pivopil/share/entities/BasicEntity.java // @MappedSuperclass // public class BasicEntity extends EntityWithId { // // private Date created; // // private Date updated; // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // // public Date getUpdated() { // return updated; // } // // public void setUpdated(Date updated) { // this.updated = updated; // } // // @PrePersist // protected void onCreate() { // this.created = new Date(); // } // // @PreUpdate // protected void onUpdate() { // this.updated = new Date(); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/CustomOvalException.java // public class CustomOvalException extends RuntimeException { // // private final Map<String, List<String>> errorMap; // // public CustomOvalException(Map<String, List<String>> errorMap) { // super("Map with Oval validation exceptions"); // this.errorMap = errorMap; // } // // public Map<String, List<String>> getErrorMap() { // return errorMap; // } // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/ExceptionAdapter.java // public class ExceptionAdapter extends RuntimeException { // // private final String stackTrace; // private final Exception originalException; // // private final HttpStatus httpStatus; // private final ErrorCategory errorCategory; // private final int errorCode; // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus) { // this(message, error.code, error.category, httpStatus, null); // } // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus, Exception cause) { // this(message, error.code, error.category, httpStatus, cause); // } // // public ExceptionAdapter(String message, int errorCode, ErrorCategory errorCategory, HttpStatus httpStatus, // Exception cause) { // super(message, cause); // this.httpStatus = httpStatus; // this.errorCategory = errorCategory; // this.errorCode = errorCode; // this.stackTrace = cause.toString(); // this.originalException = cause; // } // // public ExceptionAdapter(Exception e) { // super(e.toString()); // originalException = e; // StringWriter sw = new StringWriter(); // e.printStackTrace(new PrintWriter(sw)); // stackTrace = sw.toString(); // // this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; // this.errorCategory = ErrorCategory.UNKNOWN; // this.errorCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); // } // // public void printStackTrace() { // printStackTrace(System.err); // } // public void printStackTrace(java.io.PrintStream s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public void printStackTrace(PrintWriter s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public Throwable rethrow() { return originalException; } // // public HttpStatus getHttpStatus() { // return httpStatus; // } // // public ErrorCategory getErrorCategory() { // return errorCategory; // } // // public int getErrorCode() { // return errorCode; // } // } // // Path: share/src/main/java/io/github/pivopil/share/viewmodels/ViewModel.java // public interface ViewModel<T> { // // Long getId(); // // void setId(Long id); // // Date getCreated(); // // void setCreated(Date created); // // Date getUpdated(); // // void setUpdated(Date updated); // // } // Path: share/src/main/java/io/github/pivopil/share/builders/EntityBuilder.java import io.github.pivopil.share.entities.BasicEntity; import io.github.pivopil.share.exceptions.CustomOvalException; import io.github.pivopil.share.exceptions.ExceptionAdapter; import io.github.pivopil.share.viewmodels.ViewModel; import net.sf.oval.ConstraintViolation; import net.sf.oval.Validator; import java.util.*; package io.github.pivopil.share.builders; /** * Created on 06.05.16. */ public interface EntityBuilder<T extends BasicEntity, K extends EntityBuilder, V extends ViewModel<T>> { K newInstance(); V buildViewModel(); K newInstance(T entity); K id(Long val); K created(Date val); K updated(Date val); T build(); K withOvalValidator(Validator ovalValidator); default void validate(Validator ovalValidator) { if (ovalValidator != null) { List<ConstraintViolation> constraintViolations = ovalValidator.validate(this); if (constraintViolations.size() > 0) { final Map<String, List<String>> errorMap = new HashMap<>(); final String className = this.getClass().getName() + "."; constraintViolations .forEach(constraintViolation -> errorMap.computeIfAbsent(constraintViolation.getCheckDeclaringContext().toString().replace(className, ""), k -> new ArrayList<>()) .add(constraintViolation.getMessage().replace(className, "")));
throw new ExceptionAdapter(new CustomOvalException(errorMap));
Pivopil/spring-boot-oauth2-rest-service-password-encoding
share/src/main/java/io/github/pivopil/share/builders/EntityBuilder.java
// Path: share/src/main/java/io/github/pivopil/share/entities/BasicEntity.java // @MappedSuperclass // public class BasicEntity extends EntityWithId { // // private Date created; // // private Date updated; // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // // public Date getUpdated() { // return updated; // } // // public void setUpdated(Date updated) { // this.updated = updated; // } // // @PrePersist // protected void onCreate() { // this.created = new Date(); // } // // @PreUpdate // protected void onUpdate() { // this.updated = new Date(); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/CustomOvalException.java // public class CustomOvalException extends RuntimeException { // // private final Map<String, List<String>> errorMap; // // public CustomOvalException(Map<String, List<String>> errorMap) { // super("Map with Oval validation exceptions"); // this.errorMap = errorMap; // } // // public Map<String, List<String>> getErrorMap() { // return errorMap; // } // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/ExceptionAdapter.java // public class ExceptionAdapter extends RuntimeException { // // private final String stackTrace; // private final Exception originalException; // // private final HttpStatus httpStatus; // private final ErrorCategory errorCategory; // private final int errorCode; // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus) { // this(message, error.code, error.category, httpStatus, null); // } // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus, Exception cause) { // this(message, error.code, error.category, httpStatus, cause); // } // // public ExceptionAdapter(String message, int errorCode, ErrorCategory errorCategory, HttpStatus httpStatus, // Exception cause) { // super(message, cause); // this.httpStatus = httpStatus; // this.errorCategory = errorCategory; // this.errorCode = errorCode; // this.stackTrace = cause.toString(); // this.originalException = cause; // } // // public ExceptionAdapter(Exception e) { // super(e.toString()); // originalException = e; // StringWriter sw = new StringWriter(); // e.printStackTrace(new PrintWriter(sw)); // stackTrace = sw.toString(); // // this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; // this.errorCategory = ErrorCategory.UNKNOWN; // this.errorCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); // } // // public void printStackTrace() { // printStackTrace(System.err); // } // public void printStackTrace(java.io.PrintStream s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public void printStackTrace(PrintWriter s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public Throwable rethrow() { return originalException; } // // public HttpStatus getHttpStatus() { // return httpStatus; // } // // public ErrorCategory getErrorCategory() { // return errorCategory; // } // // public int getErrorCode() { // return errorCode; // } // } // // Path: share/src/main/java/io/github/pivopil/share/viewmodels/ViewModel.java // public interface ViewModel<T> { // // Long getId(); // // void setId(Long id); // // Date getCreated(); // // void setCreated(Date created); // // Date getUpdated(); // // void setUpdated(Date updated); // // }
import io.github.pivopil.share.entities.BasicEntity; import io.github.pivopil.share.exceptions.CustomOvalException; import io.github.pivopil.share.exceptions.ExceptionAdapter; import io.github.pivopil.share.viewmodels.ViewModel; import net.sf.oval.ConstraintViolation; import net.sf.oval.Validator; import java.util.*;
package io.github.pivopil.share.builders; /** * Created on 06.05.16. */ public interface EntityBuilder<T extends BasicEntity, K extends EntityBuilder, V extends ViewModel<T>> { K newInstance(); V buildViewModel(); K newInstance(T entity); K id(Long val); K created(Date val); K updated(Date val); T build(); K withOvalValidator(Validator ovalValidator); default void validate(Validator ovalValidator) { if (ovalValidator != null) { List<ConstraintViolation> constraintViolations = ovalValidator.validate(this); if (constraintViolations.size() > 0) { final Map<String, List<String>> errorMap = new HashMap<>(); final String className = this.getClass().getName() + "."; constraintViolations .forEach(constraintViolation -> errorMap.computeIfAbsent(constraintViolation.getCheckDeclaringContext().toString().replace(className, ""), k -> new ArrayList<>()) .add(constraintViolation.getMessage().replace(className, "")));
// Path: share/src/main/java/io/github/pivopil/share/entities/BasicEntity.java // @MappedSuperclass // public class BasicEntity extends EntityWithId { // // private Date created; // // private Date updated; // // public Date getCreated() { // return created; // } // // public void setCreated(Date created) { // this.created = created; // } // // public Date getUpdated() { // return updated; // } // // public void setUpdated(Date updated) { // this.updated = updated; // } // // @PrePersist // protected void onCreate() { // this.created = new Date(); // } // // @PreUpdate // protected void onUpdate() { // this.updated = new Date(); // } // // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/CustomOvalException.java // public class CustomOvalException extends RuntimeException { // // private final Map<String, List<String>> errorMap; // // public CustomOvalException(Map<String, List<String>> errorMap) { // super("Map with Oval validation exceptions"); // this.errorMap = errorMap; // } // // public Map<String, List<String>> getErrorMap() { // return errorMap; // } // } // // Path: share/src/main/java/io/github/pivopil/share/exceptions/ExceptionAdapter.java // public class ExceptionAdapter extends RuntimeException { // // private final String stackTrace; // private final Exception originalException; // // private final HttpStatus httpStatus; // private final ErrorCategory errorCategory; // private final int errorCode; // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus) { // this(message, error.code, error.category, httpStatus, null); // } // // public ExceptionAdapter(String message, Error error, HttpStatus httpStatus, Exception cause) { // this(message, error.code, error.category, httpStatus, cause); // } // // public ExceptionAdapter(String message, int errorCode, ErrorCategory errorCategory, HttpStatus httpStatus, // Exception cause) { // super(message, cause); // this.httpStatus = httpStatus; // this.errorCategory = errorCategory; // this.errorCode = errorCode; // this.stackTrace = cause.toString(); // this.originalException = cause; // } // // public ExceptionAdapter(Exception e) { // super(e.toString()); // originalException = e; // StringWriter sw = new StringWriter(); // e.printStackTrace(new PrintWriter(sw)); // stackTrace = sw.toString(); // // this.httpStatus = HttpStatus.INTERNAL_SERVER_ERROR; // this.errorCategory = ErrorCategory.UNKNOWN; // this.errorCode = HttpStatus.INTERNAL_SERVER_ERROR.value(); // } // // public void printStackTrace() { // printStackTrace(System.err); // } // public void printStackTrace(java.io.PrintStream s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public void printStackTrace(PrintWriter s) { // synchronized(s) { // s.print(getClass().getName() + ": "); // s.print(stackTrace); // } // } // public Throwable rethrow() { return originalException; } // // public HttpStatus getHttpStatus() { // return httpStatus; // } // // public ErrorCategory getErrorCategory() { // return errorCategory; // } // // public int getErrorCode() { // return errorCode; // } // } // // Path: share/src/main/java/io/github/pivopil/share/viewmodels/ViewModel.java // public interface ViewModel<T> { // // Long getId(); // // void setId(Long id); // // Date getCreated(); // // void setCreated(Date created); // // Date getUpdated(); // // void setUpdated(Date updated); // // } // Path: share/src/main/java/io/github/pivopil/share/builders/EntityBuilder.java import io.github.pivopil.share.entities.BasicEntity; import io.github.pivopil.share.exceptions.CustomOvalException; import io.github.pivopil.share.exceptions.ExceptionAdapter; import io.github.pivopil.share.viewmodels.ViewModel; import net.sf.oval.ConstraintViolation; import net.sf.oval.Validator; import java.util.*; package io.github.pivopil.share.builders; /** * Created on 06.05.16. */ public interface EntityBuilder<T extends BasicEntity, K extends EntityBuilder, V extends ViewModel<T>> { K newInstance(); V buildViewModel(); K newInstance(T entity); K id(Long val); K created(Date val); K updated(Date val); T build(); K withOvalValidator(Validator ovalValidator); default void validate(Validator ovalValidator) { if (ovalValidator != null) { List<ConstraintViolation> constraintViolations = ovalValidator.validate(this); if (constraintViolations.size() > 0) { final Map<String, List<String>> errorMap = new HashMap<>(); final String className = this.getClass().getName() + "."; constraintViolations .forEach(constraintViolation -> errorMap.computeIfAbsent(constraintViolation.getCheckDeclaringContext().toString().replace(className, ""), k -> new ArrayList<>()) .add(constraintViolation.getMessage().replace(className, "")));
throw new ExceptionAdapter(new CustomOvalException(errorMap));
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/css/selectors/specifier/AttributeSpecifier.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Specifier.java // public interface Specifier { // // /** The specifier type. */ // public static enum Type { // ATTRIBUTE, PSEUDO, NEGATION // }; // // /** // * Get the specifier type. // * // * @return The specifier type. // */ // public Type getType(); // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // }
import com.connect_group.thymesheet.css.selectors.Specifier; import com.connect_group.thymesheet.css.util.Assert;
/** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.specifier; /** * An implementation of {@link Specifier} for attributes. * <p> * Note: * <br> * This implementation will also be used for ID selectors and class selectors. * * @see <a href="http://www.w3.org/TR/css3-selectors/#attribute-selectors">Attribute selectors</a> * * @author Christer Sandberg */ public class AttributeSpecifier implements Specifier { /** The type of match to perform for the attribute. */ public static enum Match { EXACT, LIST, HYPHEN, PREFIX, SUFFIX, CONTAINS }; /** The name of the attribute. */ private final String name; /** The attribute value. */ private final String value; /** The type of match to perform for the attribute. */ private final Match match; /** * Create a new attribute specifier with the specified attribute name. * <p> * This attribute specifier is used to check if the attribute with the * specified name exists whatever the value of the attribute. * * @param name The name of the attribute. */ public AttributeSpecifier(String name) {
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Specifier.java // public interface Specifier { // // /** The specifier type. */ // public static enum Type { // ATTRIBUTE, PSEUDO, NEGATION // }; // // /** // * Get the specifier type. // * // * @return The specifier type. // */ // public Type getType(); // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // } // Path: src/main/java/com/connect_group/thymesheet/css/selectors/specifier/AttributeSpecifier.java import com.connect_group.thymesheet.css.selectors.Specifier; import com.connect_group.thymesheet.css.util.Assert; /** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.specifier; /** * An implementation of {@link Specifier} for attributes. * <p> * Note: * <br> * This implementation will also be used for ID selectors and class selectors. * * @see <a href="http://www.w3.org/TR/css3-selectors/#attribute-selectors">Attribute selectors</a> * * @author Christer Sandberg */ public class AttributeSpecifier implements Specifier { /** The type of match to perform for the attribute. */ public static enum Match { EXACT, LIST, HYPHEN, PREFIX, SUFFIX, CONTAINS }; /** The name of the attribute. */ private final String name; /** The attribute value. */ private final String value; /** The type of match to perform for the attribute. */ private final Match match; /** * Create a new attribute specifier with the specified attribute name. * <p> * This attribute specifier is used to check if the attribute with the * specified name exists whatever the value of the attribute. * * @param name The name of the attribute. */ public AttributeSpecifier(String name) {
Assert.notNull(name, "name is null!");
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/ThymesheetTemplateEngine.java
// Path: src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetStandardTemplateModeHandlers.java // public class ThymesheetStandardTemplateModeHandlers { // private static final int MAX_PARSERS_POOL_SIZE = 24; // // public static final ITemplateModeHandler XML; // public static final ITemplateModeHandler VALIDXML; // public static final IThymesheetTemplateModeHandler XHTML; // public static final IThymesheetTemplateModeHandler VALIDXHTML; // public static final IThymesheetTemplateModeHandler HTML5; // public static final IThymesheetTemplateModeHandler LEGACYHTML5; // // public static final Set<ITemplateModeHandler> ALL_TEMPLATE_MODE_HANDLERS; // // private ThymesheetStandardTemplateModeHandlers() { // super(); // } // // static { // // final int availableProcessors = Runtime.getRuntime().availableProcessors(); // final int poolSize = // Math.min( // (availableProcessors <= 2? availableProcessors : availableProcessors - 1), // MAX_PARSERS_POOL_SIZE); // // Properties props = null; // InputStream is = ThymesheetStandardTemplateModeHandlers.class.getResourceAsStream("/thymesheet.properties"); // if(is!=null) { // props = new Properties(); // try { // props.load(is); // } catch (IOException e) { // e.printStackTrace(); // } // } // // LookupTableThymesheetLocator lookupLocator = new LookupTableThymesheetLocator(props); // HtmlThymesheetLocator htmlLocator = new HtmlThymesheetLocator(props); // // XML = new ThymesheetTemplateModeHandler( // "XML", // new XmlNonValidatingSAXTemplateParser(poolSize), // new XmlTemplateWriter(), // lookupLocator); // VALIDXML = new ThymesheetTemplateModeHandler( // "VALIDXML", // new XmlValidatingSAXTemplateParser(poolSize), // new XmlTemplateWriter(), // lookupLocator); // XHTML = new ThymesheetTemplateModeHandler( // "XHTML", // new XhtmlAndHtml5NonValidatingSAXTemplateParser(poolSize), // new XhtmlHtml5TemplateWriter(), // htmlLocator); // VALIDXHTML = new ThymesheetTemplateModeHandler( // "VALIDXHTML", // new XhtmlValidatingSAXTemplateParser(poolSize), // new XhtmlHtml5TemplateWriter(), // htmlLocator); // HTML5 = new ThymesheetTemplateModeHandler( // "HTML5", // new XhtmlAndHtml5NonValidatingSAXTemplateParser(poolSize), // new XhtmlHtml5TemplateWriter(), // htmlLocator); // LEGACYHTML5 = new ThymesheetTemplateModeHandler( // "LEGACYHTML5", // new LegacyHtml5TemplateParser("LEGACYHTML5", poolSize), // new XhtmlHtml5TemplateWriter(), // htmlLocator); // // ALL_TEMPLATE_MODE_HANDLERS = // new HashSet<ITemplateModeHandler>( // Arrays.asList( // new ITemplateModeHandler[] { XML, VALIDXML, XHTML, VALIDXHTML, HTML5, LEGACYHTML5 })); // // } // // }
import org.thymeleaf.TemplateEngine; import com.connect_group.thymesheet.templatemode.ThymesheetStandardTemplateModeHandlers;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet; public class ThymesheetTemplateEngine extends TemplateEngine { public ThymesheetTemplateEngine() { super();
// Path: src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetStandardTemplateModeHandlers.java // public class ThymesheetStandardTemplateModeHandlers { // private static final int MAX_PARSERS_POOL_SIZE = 24; // // public static final ITemplateModeHandler XML; // public static final ITemplateModeHandler VALIDXML; // public static final IThymesheetTemplateModeHandler XHTML; // public static final IThymesheetTemplateModeHandler VALIDXHTML; // public static final IThymesheetTemplateModeHandler HTML5; // public static final IThymesheetTemplateModeHandler LEGACYHTML5; // // public static final Set<ITemplateModeHandler> ALL_TEMPLATE_MODE_HANDLERS; // // private ThymesheetStandardTemplateModeHandlers() { // super(); // } // // static { // // final int availableProcessors = Runtime.getRuntime().availableProcessors(); // final int poolSize = // Math.min( // (availableProcessors <= 2? availableProcessors : availableProcessors - 1), // MAX_PARSERS_POOL_SIZE); // // Properties props = null; // InputStream is = ThymesheetStandardTemplateModeHandlers.class.getResourceAsStream("/thymesheet.properties"); // if(is!=null) { // props = new Properties(); // try { // props.load(is); // } catch (IOException e) { // e.printStackTrace(); // } // } // // LookupTableThymesheetLocator lookupLocator = new LookupTableThymesheetLocator(props); // HtmlThymesheetLocator htmlLocator = new HtmlThymesheetLocator(props); // // XML = new ThymesheetTemplateModeHandler( // "XML", // new XmlNonValidatingSAXTemplateParser(poolSize), // new XmlTemplateWriter(), // lookupLocator); // VALIDXML = new ThymesheetTemplateModeHandler( // "VALIDXML", // new XmlValidatingSAXTemplateParser(poolSize), // new XmlTemplateWriter(), // lookupLocator); // XHTML = new ThymesheetTemplateModeHandler( // "XHTML", // new XhtmlAndHtml5NonValidatingSAXTemplateParser(poolSize), // new XhtmlHtml5TemplateWriter(), // htmlLocator); // VALIDXHTML = new ThymesheetTemplateModeHandler( // "VALIDXHTML", // new XhtmlValidatingSAXTemplateParser(poolSize), // new XhtmlHtml5TemplateWriter(), // htmlLocator); // HTML5 = new ThymesheetTemplateModeHandler( // "HTML5", // new XhtmlAndHtml5NonValidatingSAXTemplateParser(poolSize), // new XhtmlHtml5TemplateWriter(), // htmlLocator); // LEGACYHTML5 = new ThymesheetTemplateModeHandler( // "LEGACYHTML5", // new LegacyHtml5TemplateParser("LEGACYHTML5", poolSize), // new XhtmlHtml5TemplateWriter(), // htmlLocator); // // ALL_TEMPLATE_MODE_HANDLERS = // new HashSet<ITemplateModeHandler>( // Arrays.asList( // new ITemplateModeHandler[] { XML, VALIDXML, XHTML, VALIDXHTML, HTML5, LEGACYHTML5 })); // // } // // } // Path: src/main/java/com/connect_group/thymesheet/ThymesheetTemplateEngine.java import org.thymeleaf.TemplateEngine; import com.connect_group.thymesheet.templatemode.ThymesheetStandardTemplateModeHandlers; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet; public class ThymesheetTemplateEngine extends TemplateEngine { public ThymesheetTemplateEngine() { super();
setDefaultTemplateModeHandlers(ThymesheetStandardTemplateModeHandlers.ALL_TEMPLATE_MODE_HANDLERS);
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/css/selectors/specifier/PseudoElementSpecifier.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Specifier.java // public interface Specifier { // // /** The specifier type. */ // public static enum Type { // ATTRIBUTE, PSEUDO, NEGATION // }; // // /** // * Get the specifier type. // * // * @return The specifier type. // */ // public Type getType(); // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // }
import com.connect_group.thymesheet.css.selectors.Specifier; import com.connect_group.thymesheet.css.util.Assert;
/** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.specifier; /** * An implementation of {@link Specifier} for pseudo-elements. * * @see <a href="http://www.w3.org/TR/css3-selectors/#pseudo-elements">Pseudo-elements</a> * * @author Christer Sandberg */ public class PseudoElementSpecifier implements Specifier { /** The pseudo-element value. */ private final String value; /** * Create a new pseudo-element specifier with the specified value. * * @param value The pseudo-element value. */ public PseudoElementSpecifier(String value) {
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Specifier.java // public interface Specifier { // // /** The specifier type. */ // public static enum Type { // ATTRIBUTE, PSEUDO, NEGATION // }; // // /** // * Get the specifier type. // * // * @return The specifier type. // */ // public Type getType(); // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // } // Path: src/main/java/com/connect_group/thymesheet/css/selectors/specifier/PseudoElementSpecifier.java import com.connect_group.thymesheet.css.selectors.Specifier; import com.connect_group.thymesheet.css.util.Assert; /** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.specifier; /** * An implementation of {@link Specifier} for pseudo-elements. * * @see <a href="http://www.w3.org/TR/css3-selectors/#pseudo-elements">Pseudo-elements</a> * * @author Christer Sandberg */ public class PseudoElementSpecifier implements Specifier { /** The pseudo-element value. */ private final String value; /** * Create a new pseudo-element specifier with the specified value. * * @param value The pseudo-element value. */ public PseudoElementSpecifier(String value) {
Assert.notNull(value, "value is null!");
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/css/selectors/specifier/PseudoClassSpecifier.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Specifier.java // public interface Specifier { // // /** The specifier type. */ // public static enum Type { // ATTRIBUTE, PSEUDO, NEGATION // }; // // /** // * Get the specifier type. // * // * @return The specifier type. // */ // public Type getType(); // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // }
import com.connect_group.thymesheet.css.selectors.Specifier; import com.connect_group.thymesheet.css.util.Assert;
/** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.specifier; /** * An implementation of {@link Specifier} for pseudo-classes. * <p> * Note: * <br> * The negation pseudo-class specifier is implemented by {@link NegationSpecifier}, and * the {@code nth-*} pseudo-classes are implemented by {@link PseudoNthSpecifier}. * * @see <a href="http://www.w3.org/TR/css3-selectors/#pseudo-classes">Pseudo-classes</a> * * @author Christer Sandberg */ public class PseudoClassSpecifier implements Specifier { /** The pseudo-class value. */ private final String value; /** * Create a new pseudo-class specifier with the specified value. * * @param value The pseudo-class value. */ public PseudoClassSpecifier(String value) {
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Specifier.java // public interface Specifier { // // /** The specifier type. */ // public static enum Type { // ATTRIBUTE, PSEUDO, NEGATION // }; // // /** // * Get the specifier type. // * // * @return The specifier type. // */ // public Type getType(); // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // } // Path: src/main/java/com/connect_group/thymesheet/css/selectors/specifier/PseudoClassSpecifier.java import com.connect_group.thymesheet.css.selectors.Specifier; import com.connect_group.thymesheet.css.util.Assert; /** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.specifier; /** * An implementation of {@link Specifier} for pseudo-classes. * <p> * Note: * <br> * The negation pseudo-class specifier is implemented by {@link NegationSpecifier}, and * the {@code nth-*} pseudo-classes are implemented by {@link PseudoNthSpecifier}. * * @see <a href="http://www.w3.org/TR/css3-selectors/#pseudo-classes">Pseudo-classes</a> * * @author Christer Sandberg */ public class PseudoClassSpecifier implements Specifier { /** The pseudo-class value. */ private final String value; /** * Create a new pseudo-class specifier with the specified value. * * @param value The pseudo-class value. */ public PseudoClassSpecifier(String value) {
Assert.notNull(value, "value is null!");
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/impl/ThymesheetPreprocessor.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetProcessorException.java // public class ThymesheetProcessorException extends IOException { // // private static final long serialVersionUID = 6752946320942025461L; // // public ThymesheetProcessorException() { // super(); // } // // public ThymesheetProcessorException(String message) { // super(message); // } // // public ThymesheetProcessorException(String message, Throwable t) { // super(message, t); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // }
import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.SequenceInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import com.steadystate.css.util.ThrowCssExceptionErrorHandler; import org.thymeleaf.dom.Document; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleRule; import org.w3c.dom.css.CSSStyleSheet; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.ThymesheetProcessorException; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.steadystate.css.parser.CSSOMParser; import com.steadystate.css.parser.SACParserCSS3;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetPreprocessor { private final ServletContextURLFactory urlFactory;
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetProcessorException.java // public class ThymesheetProcessorException extends IOException { // // private static final long serialVersionUID = 6752946320942025461L; // // public ThymesheetProcessorException() { // super(); // } // // public ThymesheetProcessorException(String message) { // super(message); // } // // public ThymesheetProcessorException(String message, Throwable t) { // super(message, t); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetPreprocessor.java import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.SequenceInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import com.steadystate.css.util.ThrowCssExceptionErrorHandler; import org.thymeleaf.dom.Document; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleRule; import org.w3c.dom.css.CSSStyleSheet; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.ThymesheetProcessorException; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.steadystate.css.parser.CSSOMParser; import com.steadystate.css.parser.SACParserCSS3; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetPreprocessor { private final ServletContextURLFactory urlFactory;
private final ThymesheetLocator thymesheetLocator;
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/impl/ThymesheetPreprocessor.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetProcessorException.java // public class ThymesheetProcessorException extends IOException { // // private static final long serialVersionUID = 6752946320942025461L; // // public ThymesheetProcessorException() { // super(); // } // // public ThymesheetProcessorException(String message) { // super(message); // } // // public ThymesheetProcessorException(String message, Throwable t) { // super(message, t); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // }
import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.SequenceInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import com.steadystate.css.util.ThrowCssExceptionErrorHandler; import org.thymeleaf.dom.Document; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleRule; import org.w3c.dom.css.CSSStyleSheet; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.ThymesheetProcessorException; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.steadystate.css.parser.CSSOMParser; import com.steadystate.css.parser.SACParserCSS3;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetPreprocessor { private final ServletContextURLFactory urlFactory; private final ThymesheetLocator thymesheetLocator;
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetProcessorException.java // public class ThymesheetProcessorException extends IOException { // // private static final long serialVersionUID = 6752946320942025461L; // // public ThymesheetProcessorException() { // super(); // } // // public ThymesheetProcessorException(String message) { // super(message); // } // // public ThymesheetProcessorException(String message, Throwable t) { // super(message, t); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetPreprocessor.java import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.SequenceInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import com.steadystate.css.util.ThrowCssExceptionErrorHandler; import org.thymeleaf.dom.Document; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleRule; import org.w3c.dom.css.CSSStyleSheet; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.ThymesheetProcessorException; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.steadystate.css.parser.CSSOMParser; import com.steadystate.css.parser.SACParserCSS3; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetPreprocessor { private final ServletContextURLFactory urlFactory; private final ThymesheetLocator thymesheetLocator;
private final Set<ThymesheetParserPostProcessor> postProcessors;
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/impl/ThymesheetPreprocessor.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetProcessorException.java // public class ThymesheetProcessorException extends IOException { // // private static final long serialVersionUID = 6752946320942025461L; // // public ThymesheetProcessorException() { // super(); // } // // public ThymesheetProcessorException(String message) { // super(message); // } // // public ThymesheetProcessorException(String message, Throwable t) { // super(message, t); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // }
import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.SequenceInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import com.steadystate.css.util.ThrowCssExceptionErrorHandler; import org.thymeleaf.dom.Document; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleRule; import org.w3c.dom.css.CSSStyleSheet; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.ThymesheetProcessorException; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.steadystate.css.parser.CSSOMParser; import com.steadystate.css.parser.SACParserCSS3;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetPreprocessor { private final ServletContextURLFactory urlFactory; private final ThymesheetLocator thymesheetLocator; private final Set<ThymesheetParserPostProcessor> postProcessors; public ThymesheetPreprocessor() { super(); urlFactory = null; thymesheetLocator = null; this.postProcessors = Collections.emptySet(); } public ThymesheetPreprocessor(ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { super(); this.urlFactory = urlFactory; this.thymesheetLocator = thymesheetLocator; if(postProcessors==null) { this.postProcessors = Collections.emptySet(); } else { this.postProcessors = postProcessors; } } public void preProcess(String documentName, Document document) throws IOException { List<String> filePaths = thymesheetLocator.getThymesheetPaths(document); InputStream thymesheetInputStream = getInputStream(filePaths); AttributeRuleList attributeRules = getRuleList(thymesheetInputStream); ElementRuleList elementRules=extractDOMModifications(attributeRules); try { attributeRules.applyTo(document); elementRules.applyTo(document);
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetProcessorException.java // public class ThymesheetProcessorException extends IOException { // // private static final long serialVersionUID = 6752946320942025461L; // // public ThymesheetProcessorException() { // super(); // } // // public ThymesheetProcessorException(String message) { // super(message); // } // // public ThymesheetProcessorException(String message, Throwable t) { // super(message, t); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetPreprocessor.java import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.SequenceInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import com.steadystate.css.util.ThrowCssExceptionErrorHandler; import org.thymeleaf.dom.Document; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleRule; import org.w3c.dom.css.CSSStyleSheet; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.ThymesheetProcessorException; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.steadystate.css.parser.CSSOMParser; import com.steadystate.css.parser.SACParserCSS3; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetPreprocessor { private final ServletContextURLFactory urlFactory; private final ThymesheetLocator thymesheetLocator; private final Set<ThymesheetParserPostProcessor> postProcessors; public ThymesheetPreprocessor() { super(); urlFactory = null; thymesheetLocator = null; this.postProcessors = Collections.emptySet(); } public ThymesheetPreprocessor(ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { super(); this.urlFactory = urlFactory; this.thymesheetLocator = thymesheetLocator; if(postProcessors==null) { this.postProcessors = Collections.emptySet(); } else { this.postProcessors = postProcessors; } } public void preProcess(String documentName, Document document) throws IOException { List<String> filePaths = thymesheetLocator.getThymesheetPaths(document); InputStream thymesheetInputStream = getInputStream(filePaths); AttributeRuleList attributeRules = getRuleList(thymesheetInputStream); ElementRuleList elementRules=extractDOMModifications(attributeRules); try { attributeRules.applyTo(document); elementRules.applyTo(document);
} catch (NodeSelectorException e) {
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/impl/ThymesheetPreprocessor.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetProcessorException.java // public class ThymesheetProcessorException extends IOException { // // private static final long serialVersionUID = 6752946320942025461L; // // public ThymesheetProcessorException() { // super(); // } // // public ThymesheetProcessorException(String message) { // super(message); // } // // public ThymesheetProcessorException(String message, Throwable t) { // super(message, t); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // }
import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.SequenceInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import com.steadystate.css.util.ThrowCssExceptionErrorHandler; import org.thymeleaf.dom.Document; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleRule; import org.w3c.dom.css.CSSStyleSheet; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.ThymesheetProcessorException; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.steadystate.css.parser.CSSOMParser; import com.steadystate.css.parser.SACParserCSS3;
super(); this.urlFactory = urlFactory; this.thymesheetLocator = thymesheetLocator; if(postProcessors==null) { this.postProcessors = Collections.emptySet(); } else { this.postProcessors = postProcessors; } } public void preProcess(String documentName, Document document) throws IOException { List<String> filePaths = thymesheetLocator.getThymesheetPaths(document); InputStream thymesheetInputStream = getInputStream(filePaths); AttributeRuleList attributeRules = getRuleList(thymesheetInputStream); ElementRuleList elementRules=extractDOMModifications(attributeRules); try { attributeRules.applyTo(document); elementRules.applyTo(document); } catch (NodeSelectorException e) { throw new IOException("Invalid CSS Selector", e); } thymesheetLocator.removeThymesheetLinks(document); postProcess(documentName, document); }
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetProcessorException.java // public class ThymesheetProcessorException extends IOException { // // private static final long serialVersionUID = 6752946320942025461L; // // public ThymesheetProcessorException() { // super(); // } // // public ThymesheetProcessorException(String message) { // super(message); // } // // public ThymesheetProcessorException(String message, Throwable t) { // super(message, t); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetPreprocessor.java import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.SequenceInputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.Set; import com.steadystate.css.util.ThrowCssExceptionErrorHandler; import org.thymeleaf.dom.Document; import org.w3c.css.sac.InputSource; import org.w3c.dom.css.CSSRuleList; import org.w3c.dom.css.CSSStyleRule; import org.w3c.dom.css.CSSStyleSheet; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.ThymesheetProcessorException; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.steadystate.css.parser.CSSOMParser; import com.steadystate.css.parser.SACParserCSS3; super(); this.urlFactory = urlFactory; this.thymesheetLocator = thymesheetLocator; if(postProcessors==null) { this.postProcessors = Collections.emptySet(); } else { this.postProcessors = postProcessors; } } public void preProcess(String documentName, Document document) throws IOException { List<String> filePaths = thymesheetLocator.getThymesheetPaths(document); InputStream thymesheetInputStream = getInputStream(filePaths); AttributeRuleList attributeRules = getRuleList(thymesheetInputStream); ElementRuleList elementRules=extractDOMModifications(attributeRules); try { attributeRules.applyTo(document); elementRules.applyTo(document); } catch (NodeSelectorException e) { throw new IOException("Invalid CSS Selector", e); } thymesheetLocator.removeThymesheetLinks(document); postProcess(documentName, document); }
private void postProcess(String documentName, Document document) throws ThymesheetProcessorException {
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/css/selectors/Selector.java
// Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // }
import com.connect_group.thymesheet.css.util.Assert; import java.util.List;
/** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors; /** * Represents a selector. * <p> * A selector has a tag name, a combinator and a list of {@linkplain Specifier specifiers}. * * @see <a href="http://www.w3.org/TR/css3-selectors/#selector-syntax">Selector syntax description</a> * * @author Christer Sandberg */ public class Selector { /** The universal tag name (i.e. {@code *}). */ public static final String UNIVERSAL_TAG = "*"; /** * Combinators * * @see <a href="http://www.w3.org/TR/css3-selectors/#combinators">Combinators description</a> */ public static enum Combinator { DESCENDANT, CHILD, ADJACENT_SIBLING, GENERAL_SIBLING } /** Tag name. */ private final String tagName; /** Combinator */ private final Combinator combinator; /** A list of {@linkplain Specifier specifiers}. */ private final List<Specifier> specifiers; /** * Create a new instance with the tag name set to the value of {@link #UNIVERSAL_TAG}, * and with the combinator set to {@link Combinator#DESCENDANT}. The list of * {@linkplain #specifiers specifiers} will be set to {@code null}. */ public Selector() { this.tagName = UNIVERSAL_TAG; this.combinator = Combinator.DESCENDANT; this.specifiers = null; } /** * Create a new instance with the specified tag name and combinator. * <p> * The list of {@linkplain #specifiers specifiers} will be set to {@code null}. * * @param tagName The tag name to set. * @param combinator The combinator to set. */ public Selector(String tagName, Combinator combinator) {
// Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // } // Path: src/main/java/com/connect_group/thymesheet/css/selectors/Selector.java import com.connect_group.thymesheet.css.util.Assert; import java.util.List; /** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors; /** * Represents a selector. * <p> * A selector has a tag name, a combinator and a list of {@linkplain Specifier specifiers}. * * @see <a href="http://www.w3.org/TR/css3-selectors/#selector-syntax">Selector syntax description</a> * * @author Christer Sandberg */ public class Selector { /** The universal tag name (i.e. {@code *}). */ public static final String UNIVERSAL_TAG = "*"; /** * Combinators * * @see <a href="http://www.w3.org/TR/css3-selectors/#combinators">Combinators description</a> */ public static enum Combinator { DESCENDANT, CHILD, ADJACENT_SIBLING, GENERAL_SIBLING } /** Tag name. */ private final String tagName; /** Combinator */ private final Combinator combinator; /** A list of {@linkplain Specifier specifiers}. */ private final List<Specifier> specifiers; /** * Create a new instance with the tag name set to the value of {@link #UNIVERSAL_TAG}, * and with the combinator set to {@link Combinator#DESCENDANT}. The list of * {@linkplain #specifiers specifiers} will be set to {@code null}. */ public Selector() { this.tagName = UNIVERSAL_TAG; this.combinator = Combinator.DESCENDANT; this.specifiers = null; } /** * Create a new instance with the specified tag name and combinator. * <p> * The list of {@linkplain #specifiers specifiers} will be set to {@code null}. * * @param tagName The tag name to set. * @param combinator The combinator to set. */ public Selector(String tagName, Combinator combinator) {
Assert.notNull(tagName, "tagName is null!");
connect-group/thymesheet
src/test/java/com/connect_group/thymesheet/query/HtmlElementsTests.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/query/HtmlElements.java // public class HtmlElements extends LinkedHashSet<HtmlElement> { // // private static final long serialVersionUID = 284598876009291447L; // // public HtmlElements() {} // // public HtmlElements(Element element) { // this.add(new HtmlElement(element)); // } // // public HtmlElements(Collection<Element> elements) { // for(Element e : elements) { // this.add(new HtmlElement(e)); // } // } // // public HtmlElements matching(String criteria) throws NodeSelectorException { // HtmlElements matchedElements = new HtmlElements(); // // for(HtmlElement tag : this) { // DOMNodeSelector selector = new DOMNodeSelector(tag.getElement()); // Set<Node> nodes = selector.querySelectorAll(criteria); // for(Node node : nodes) { // matchedElements.add(new HtmlElement((Element)node)); // } // } // // return matchedElements; // } // // public HtmlElement get(int index) { // if(index>=size() || index < 0) { // throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size()); // } // // Iterator<HtmlElement> it = iterator(); // while(index>0) { // it.next(); // index--; // } // // return it.next(); // } // // public String text() { // StringBuilder builder = new StringBuilder(); // for(HtmlElement tag : this) { // builder.append(tag.text()); // } // return builder.toString(); // } // // public String html() { // StringBuilder builder = new StringBuilder(); // for(HtmlElement tag : this) { // builder.append(tag.html()); // } // return builder.toString(); // } // // @Override // public String toString() { // return html(); // } // // // assertThat(elements.matching("span").size(), is(2)); // // assertThat(elements.matching("h4 span[data-alt]").text(), is("hello")); // // Hamcrest: // // hasAttr("") --> Applies to Element. // // // }
import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.thymeleaf.dom.Comment; import org.thymeleaf.dom.Element; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.connect_group.thymesheet.query.HtmlElements; import static org.hamcrest.CoreMatchers.*; import static org.junit.matchers.JUnitMatchers.*; import static org.junit.Assert.*;
package com.connect_group.thymesheet.query; public class HtmlElementsTests { @Test
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/query/HtmlElements.java // public class HtmlElements extends LinkedHashSet<HtmlElement> { // // private static final long serialVersionUID = 284598876009291447L; // // public HtmlElements() {} // // public HtmlElements(Element element) { // this.add(new HtmlElement(element)); // } // // public HtmlElements(Collection<Element> elements) { // for(Element e : elements) { // this.add(new HtmlElement(e)); // } // } // // public HtmlElements matching(String criteria) throws NodeSelectorException { // HtmlElements matchedElements = new HtmlElements(); // // for(HtmlElement tag : this) { // DOMNodeSelector selector = new DOMNodeSelector(tag.getElement()); // Set<Node> nodes = selector.querySelectorAll(criteria); // for(Node node : nodes) { // matchedElements.add(new HtmlElement((Element)node)); // } // } // // return matchedElements; // } // // public HtmlElement get(int index) { // if(index>=size() || index < 0) { // throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size()); // } // // Iterator<HtmlElement> it = iterator(); // while(index>0) { // it.next(); // index--; // } // // return it.next(); // } // // public String text() { // StringBuilder builder = new StringBuilder(); // for(HtmlElement tag : this) { // builder.append(tag.text()); // } // return builder.toString(); // } // // public String html() { // StringBuilder builder = new StringBuilder(); // for(HtmlElement tag : this) { // builder.append(tag.html()); // } // return builder.toString(); // } // // @Override // public String toString() { // return html(); // } // // // assertThat(elements.matching("span").size(), is(2)); // // assertThat(elements.matching("h4 span[data-alt]").text(), is("hello")); // // Hamcrest: // // hasAttr("") --> Applies to Element. // // // } // Path: src/test/java/com/connect_group/thymesheet/query/HtmlElementsTests.java import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.thymeleaf.dom.Comment; import org.thymeleaf.dom.Element; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.connect_group.thymesheet.query.HtmlElements; import static org.hamcrest.CoreMatchers.*; import static org.junit.matchers.JUnitMatchers.*; import static org.junit.Assert.*; package com.connect_group.thymesheet.query; public class HtmlElementsTests { @Test
public void shouldAddAllElementsOfACollection_WhenConstructedUsingACollection() throws NodeSelectorException {
connect-group/thymesheet
src/test/java/com/connect_group/thymesheet/query/HtmlElementsTests.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/query/HtmlElements.java // public class HtmlElements extends LinkedHashSet<HtmlElement> { // // private static final long serialVersionUID = 284598876009291447L; // // public HtmlElements() {} // // public HtmlElements(Element element) { // this.add(new HtmlElement(element)); // } // // public HtmlElements(Collection<Element> elements) { // for(Element e : elements) { // this.add(new HtmlElement(e)); // } // } // // public HtmlElements matching(String criteria) throws NodeSelectorException { // HtmlElements matchedElements = new HtmlElements(); // // for(HtmlElement tag : this) { // DOMNodeSelector selector = new DOMNodeSelector(tag.getElement()); // Set<Node> nodes = selector.querySelectorAll(criteria); // for(Node node : nodes) { // matchedElements.add(new HtmlElement((Element)node)); // } // } // // return matchedElements; // } // // public HtmlElement get(int index) { // if(index>=size() || index < 0) { // throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size()); // } // // Iterator<HtmlElement> it = iterator(); // while(index>0) { // it.next(); // index--; // } // // return it.next(); // } // // public String text() { // StringBuilder builder = new StringBuilder(); // for(HtmlElement tag : this) { // builder.append(tag.text()); // } // return builder.toString(); // } // // public String html() { // StringBuilder builder = new StringBuilder(); // for(HtmlElement tag : this) { // builder.append(tag.html()); // } // return builder.toString(); // } // // @Override // public String toString() { // return html(); // } // // // assertThat(elements.matching("span").size(), is(2)); // // assertThat(elements.matching("h4 span[data-alt]").text(), is("hello")); // // Hamcrest: // // hasAttr("") --> Applies to Element. // // // }
import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.thymeleaf.dom.Comment; import org.thymeleaf.dom.Element; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.connect_group.thymesheet.query.HtmlElements; import static org.hamcrest.CoreMatchers.*; import static org.junit.matchers.JUnitMatchers.*; import static org.junit.Assert.*;
package com.connect_group.thymesheet.query; public class HtmlElementsTests { @Test public void shouldAddAllElementsOfACollection_WhenConstructedUsingACollection() throws NodeSelectorException { Element[] testArray = new Element[] { new Element("banana"), new Element("apple") };
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/query/HtmlElements.java // public class HtmlElements extends LinkedHashSet<HtmlElement> { // // private static final long serialVersionUID = 284598876009291447L; // // public HtmlElements() {} // // public HtmlElements(Element element) { // this.add(new HtmlElement(element)); // } // // public HtmlElements(Collection<Element> elements) { // for(Element e : elements) { // this.add(new HtmlElement(e)); // } // } // // public HtmlElements matching(String criteria) throws NodeSelectorException { // HtmlElements matchedElements = new HtmlElements(); // // for(HtmlElement tag : this) { // DOMNodeSelector selector = new DOMNodeSelector(tag.getElement()); // Set<Node> nodes = selector.querySelectorAll(criteria); // for(Node node : nodes) { // matchedElements.add(new HtmlElement((Element)node)); // } // } // // return matchedElements; // } // // public HtmlElement get(int index) { // if(index>=size() || index < 0) { // throw new IndexOutOfBoundsException("Index: " + index + ", Size: " + size()); // } // // Iterator<HtmlElement> it = iterator(); // while(index>0) { // it.next(); // index--; // } // // return it.next(); // } // // public String text() { // StringBuilder builder = new StringBuilder(); // for(HtmlElement tag : this) { // builder.append(tag.text()); // } // return builder.toString(); // } // // public String html() { // StringBuilder builder = new StringBuilder(); // for(HtmlElement tag : this) { // builder.append(tag.html()); // } // return builder.toString(); // } // // @Override // public String toString() { // return html(); // } // // // assertThat(elements.matching("span").size(), is(2)); // // assertThat(elements.matching("h4 span[data-alt]").text(), is("hello")); // // Hamcrest: // // hasAttr("") --> Applies to Element. // // // } // Path: src/test/java/com/connect_group/thymesheet/query/HtmlElementsTests.java import java.util.Arrays; import java.util.Collection; import org.junit.Test; import org.thymeleaf.dom.Comment; import org.thymeleaf.dom.Element; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.connect_group.thymesheet.query.HtmlElements; import static org.hamcrest.CoreMatchers.*; import static org.junit.matchers.JUnitMatchers.*; import static org.junit.Assert.*; package com.connect_group.thymesheet.query; public class HtmlElementsTests { @Test public void shouldAddAllElementsOfACollection_WhenConstructedUsingACollection() throws NodeSelectorException { Element[] testArray = new Element[] { new Element("banana"), new Element("apple") };
HtmlElements tags = new HtmlElements(Arrays.asList(testArray));
connect-group/thymesheet
src/test/java/com/connect_group/thymesheet/impl/AttributeRuleListTests.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // }
import static org.junit.Assert.assertEquals; import java.util.LinkedHashMap; import java.util.List; import org.junit.Test; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Element; import com.connect_group.thymesheet.css.selectors.NodeSelectorException;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class AttributeRuleListTests { @Test
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // Path: src/test/java/com/connect_group/thymesheet/impl/AttributeRuleListTests.java import static org.junit.Assert.assertEquals; import java.util.LinkedHashMap; import java.util.List; import org.junit.Test; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Element; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class AttributeRuleListTests { @Test
public void handleRule() throws NodeSelectorException {
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // }
import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.Set; import org.thymeleaf.Configuration; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Node; import org.thymeleaf.templateparser.ITemplateParser; import com.connect_group.thymesheet.ServletContextURLFactory;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetTemplateParser implements ITemplateParser { private final ITemplateParser decoratedParser; private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor();
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.Set; import org.thymeleaf.Configuration; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Node; import org.thymeleaf.templateparser.ITemplateParser; import com.connect_group.thymesheet.ServletContextURLFactory; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetTemplateParser implements ITemplateParser { private final ITemplateParser decoratedParser; private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor();
public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) {
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // }
import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.Set; import org.thymeleaf.Configuration; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Node; import org.thymeleaf.templateparser.ITemplateParser; import com.connect_group.thymesheet.ServletContextURLFactory;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetTemplateParser implements ITemplateParser { private final ITemplateParser decoratedParser; private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor();
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.Set; import org.thymeleaf.Configuration; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Node; import org.thymeleaf.templateparser.ITemplateParser; import com.connect_group.thymesheet.ServletContextURLFactory; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetTemplateParser implements ITemplateParser { private final ITemplateParser decoratedParser; private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor();
public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) {
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // }
import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.Set; import org.thymeleaf.Configuration; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Node; import org.thymeleaf.templateparser.ITemplateParser; import com.connect_group.thymesheet.ServletContextURLFactory;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetTemplateParser implements ITemplateParser { private final ITemplateParser decoratedParser; private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor();
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import java.io.IOException; import java.io.Reader; import java.util.List; import java.util.Set; import org.thymeleaf.Configuration; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Node; import org.thymeleaf.templateparser.ITemplateParser; import com.connect_group.thymesheet.ServletContextURLFactory; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.impl; public class ThymesheetTemplateParser implements ITemplateParser { private final ITemplateParser decoratedParser; private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor();
public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) {
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetTemplateModeHandler.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java // public class ThymesheetTemplateParser implements ITemplateParser { // private final ITemplateParser decoratedParser; // private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor(); // // public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { // this.decoratedParser = parser; // this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors); // } // // public Document parseTemplate(Configuration configuration, // String documentName, Reader source) { // Document doc = decoratedParser.parseTemplate(configuration, documentName, source); // try { // preprocessor.preProcess(documentName, doc); // } catch (IOException e) { // throw new UnsupportedOperationException(e.getMessage(), e); // } // return doc; // } // // public List<Node> parseFragment(Configuration configuration, String fragment) { // return decoratedParser.parseFragment(configuration, fragment); // } // // // // }
import java.util.Set; import org.thymeleaf.templateparser.ITemplateParser; import org.thymeleaf.templatewriter.ITemplateWriter; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.impl.ThymesheetTemplateParser;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public class ThymesheetTemplateModeHandler implements IThymesheetTemplateModeHandler { private final String templateModeName;
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java // public class ThymesheetTemplateParser implements ITemplateParser { // private final ITemplateParser decoratedParser; // private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor(); // // public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { // this.decoratedParser = parser; // this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors); // } // // public Document parseTemplate(Configuration configuration, // String documentName, Reader source) { // Document doc = decoratedParser.parseTemplate(configuration, documentName, source); // try { // preprocessor.preProcess(documentName, doc); // } catch (IOException e) { // throw new UnsupportedOperationException(e.getMessage(), e); // } // return doc; // } // // public List<Node> parseFragment(Configuration configuration, String fragment) { // return decoratedParser.parseFragment(configuration, fragment); // } // // // // } // Path: src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetTemplateModeHandler.java import java.util.Set; import org.thymeleaf.templateparser.ITemplateParser; import org.thymeleaf.templatewriter.ITemplateWriter; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.impl.ThymesheetTemplateParser; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public class ThymesheetTemplateModeHandler implements IThymesheetTemplateModeHandler { private final String templateModeName;
private ThymesheetTemplateParser parser;
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetTemplateModeHandler.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java // public class ThymesheetTemplateParser implements ITemplateParser { // private final ITemplateParser decoratedParser; // private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor(); // // public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { // this.decoratedParser = parser; // this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors); // } // // public Document parseTemplate(Configuration configuration, // String documentName, Reader source) { // Document doc = decoratedParser.parseTemplate(configuration, documentName, source); // try { // preprocessor.preProcess(documentName, doc); // } catch (IOException e) { // throw new UnsupportedOperationException(e.getMessage(), e); // } // return doc; // } // // public List<Node> parseFragment(Configuration configuration, String fragment) { // return decoratedParser.parseFragment(configuration, fragment); // } // // // // }
import java.util.Set; import org.thymeleaf.templateparser.ITemplateParser; import org.thymeleaf.templatewriter.ITemplateWriter; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.impl.ThymesheetTemplateParser;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public class ThymesheetTemplateModeHandler implements IThymesheetTemplateModeHandler { private final String templateModeName; private ThymesheetTemplateParser parser; private final ITemplateParser decoratedParser; private final ITemplateWriter templateWriter;
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java // public class ThymesheetTemplateParser implements ITemplateParser { // private final ITemplateParser decoratedParser; // private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor(); // // public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { // this.decoratedParser = parser; // this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors); // } // // public Document parseTemplate(Configuration configuration, // String documentName, Reader source) { // Document doc = decoratedParser.parseTemplate(configuration, documentName, source); // try { // preprocessor.preProcess(documentName, doc); // } catch (IOException e) { // throw new UnsupportedOperationException(e.getMessage(), e); // } // return doc; // } // // public List<Node> parseFragment(Configuration configuration, String fragment) { // return decoratedParser.parseFragment(configuration, fragment); // } // // // // } // Path: src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetTemplateModeHandler.java import java.util.Set; import org.thymeleaf.templateparser.ITemplateParser; import org.thymeleaf.templatewriter.ITemplateWriter; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.impl.ThymesheetTemplateParser; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public class ThymesheetTemplateModeHandler implements IThymesheetTemplateModeHandler { private final String templateModeName; private ThymesheetTemplateParser parser; private final ITemplateParser decoratedParser; private final ITemplateWriter templateWriter;
protected final ThymesheetLocator thymesheetLocator;
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetTemplateModeHandler.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java // public class ThymesheetTemplateParser implements ITemplateParser { // private final ITemplateParser decoratedParser; // private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor(); // // public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { // this.decoratedParser = parser; // this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors); // } // // public Document parseTemplate(Configuration configuration, // String documentName, Reader source) { // Document doc = decoratedParser.parseTemplate(configuration, documentName, source); // try { // preprocessor.preProcess(documentName, doc); // } catch (IOException e) { // throw new UnsupportedOperationException(e.getMessage(), e); // } // return doc; // } // // public List<Node> parseFragment(Configuration configuration, String fragment) { // return decoratedParser.parseFragment(configuration, fragment); // } // // // // }
import java.util.Set; import org.thymeleaf.templateparser.ITemplateParser; import org.thymeleaf.templatewriter.ITemplateWriter; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.impl.ThymesheetTemplateParser;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public class ThymesheetTemplateModeHandler implements IThymesheetTemplateModeHandler { private final String templateModeName; private ThymesheetTemplateParser parser; private final ITemplateParser decoratedParser; private final ITemplateWriter templateWriter; protected final ThymesheetLocator thymesheetLocator;
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java // public class ThymesheetTemplateParser implements ITemplateParser { // private final ITemplateParser decoratedParser; // private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor(); // // public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { // this.decoratedParser = parser; // this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors); // } // // public Document parseTemplate(Configuration configuration, // String documentName, Reader source) { // Document doc = decoratedParser.parseTemplate(configuration, documentName, source); // try { // preprocessor.preProcess(documentName, doc); // } catch (IOException e) { // throw new UnsupportedOperationException(e.getMessage(), e); // } // return doc; // } // // public List<Node> parseFragment(Configuration configuration, String fragment) { // return decoratedParser.parseFragment(configuration, fragment); // } // // // // } // Path: src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetTemplateModeHandler.java import java.util.Set; import org.thymeleaf.templateparser.ITemplateParser; import org.thymeleaf.templatewriter.ITemplateWriter; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.impl.ThymesheetTemplateParser; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public class ThymesheetTemplateModeHandler implements IThymesheetTemplateModeHandler { private final String templateModeName; private ThymesheetTemplateParser parser; private final ITemplateParser decoratedParser; private final ITemplateWriter templateWriter; protected final ThymesheetLocator thymesheetLocator;
private ServletContextURLFactory urlFactory = null;
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetTemplateModeHandler.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java // public class ThymesheetTemplateParser implements ITemplateParser { // private final ITemplateParser decoratedParser; // private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor(); // // public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { // this.decoratedParser = parser; // this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors); // } // // public Document parseTemplate(Configuration configuration, // String documentName, Reader source) { // Document doc = decoratedParser.parseTemplate(configuration, documentName, source); // try { // preprocessor.preProcess(documentName, doc); // } catch (IOException e) { // throw new UnsupportedOperationException(e.getMessage(), e); // } // return doc; // } // // public List<Node> parseFragment(Configuration configuration, String fragment) { // return decoratedParser.parseFragment(configuration, fragment); // } // // // // }
import java.util.Set; import org.thymeleaf.templateparser.ITemplateParser; import org.thymeleaf.templatewriter.ITemplateWriter; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.impl.ThymesheetTemplateParser;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public class ThymesheetTemplateModeHandler implements IThymesheetTemplateModeHandler { private final String templateModeName; private ThymesheetTemplateParser parser; private final ITemplateParser decoratedParser; private final ITemplateWriter templateWriter; protected final ThymesheetLocator thymesheetLocator; private ServletContextURLFactory urlFactory = null;
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetLocator.java // public interface ThymesheetLocator { // List<String> getThymesheetPaths(Document document); // void removeThymesheetLinks(Document document); // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // // Path: src/main/java/com/connect_group/thymesheet/impl/ThymesheetTemplateParser.java // public class ThymesheetTemplateParser implements ITemplateParser { // private final ITemplateParser decoratedParser; // private final ThymesheetPreprocessor preprocessor; //= new ThymesheetPreprocessor(); // // public ThymesheetTemplateParser(ITemplateParser parser, ServletContextURLFactory urlFactory, ThymesheetLocator thymesheetLocator, Set<ThymesheetParserPostProcessor> postProcessors) { // this.decoratedParser = parser; // this.preprocessor = new ThymesheetPreprocessor(urlFactory, thymesheetLocator, postProcessors); // } // // public Document parseTemplate(Configuration configuration, // String documentName, Reader source) { // Document doc = decoratedParser.parseTemplate(configuration, documentName, source); // try { // preprocessor.preProcess(documentName, doc); // } catch (IOException e) { // throw new UnsupportedOperationException(e.getMessage(), e); // } // return doc; // } // // public List<Node> parseFragment(Configuration configuration, String fragment) { // return decoratedParser.parseFragment(configuration, fragment); // } // // // // } // Path: src/main/java/com/connect_group/thymesheet/templatemode/ThymesheetTemplateModeHandler.java import java.util.Set; import org.thymeleaf.templateparser.ITemplateParser; import org.thymeleaf.templatewriter.ITemplateWriter; import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetLocator; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import com.connect_group.thymesheet.impl.ThymesheetTemplateParser; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public class ThymesheetTemplateModeHandler implements IThymesheetTemplateModeHandler { private final String templateModeName; private ThymesheetTemplateParser parser; private final ITemplateParser decoratedParser; private final ITemplateWriter templateWriter; protected final ThymesheetLocator thymesheetLocator; private ServletContextURLFactory urlFactory = null;
private Set<ThymesheetParserPostProcessor> postProcessors;
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/css/selectors/dom/internal/AttributeSpecifierChecker.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/specifier/AttributeSpecifier.java // public class AttributeSpecifier implements Specifier { // // /** The type of match to perform for the attribute. */ // public static enum Match { // EXACT, LIST, HYPHEN, PREFIX, SUFFIX, CONTAINS // }; // // /** The name of the attribute. */ // private final String name; // // /** The attribute value. */ // private final String value; // // /** The type of match to perform for the attribute. */ // private final Match match; // // /** // * Create a new attribute specifier with the specified attribute name. // * <p> // * This attribute specifier is used to check if the attribute with the // * specified name exists whatever the value of the attribute. // * // * @param name The name of the attribute. // */ // public AttributeSpecifier(String name) { // Assert.notNull(name, "name is null!"); // this.name = name; // this.value = null; // this.match = null; // } // // /** // * Create a new attribute specifier with the specified name, value and match type. // * // * @param name The name of the attribute. // * @param value The attribute value. // * @param match The type of match to perform for the attribute. // */ // public AttributeSpecifier(String name, String value, Match match) { // Assert.notNull(name, "name is null!"); // Assert.notNull(value, "value is null!"); // Assert.notNull(match, "match is null!"); // this.name = name; // this.value = value; // this.match = match; // } // // /** // * Get the name of the attribute. // * // * @return The name of the attribute. // */ // public String getName() { // return name; // } // // /** // * Get the attribute value. // * // * @return The attribute value or {@code null}. // */ // public String getValue() { // return value; // } // // /** // * Get the type of match to perform for the attribute. // * // * @return The type of match or {@code null}. // */ // public Match getMatch() { // return match; // } // // /** // * {@inheritDoc} // */ // public Type getType() { // return Type.ATTRIBUTE; // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // }
import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.thymeleaf.dom.Attribute; import org.thymeleaf.dom.NestableAttributeHolderNode; import org.thymeleaf.dom.Node; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.connect_group.thymesheet.css.selectors.specifier.AttributeSpecifier; import com.connect_group.thymesheet.css.util.Assert;
/** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.dom.internal; /** * A {@link NodeTraversalChecker} that check if a node's attribute * matches the {@linkplain AttributeSpecifier attribute specifier} set. * * @author Christer Sandberg */ public class AttributeSpecifierChecker extends NodeTraversalChecker { /** The attribute specifier to check against. */ private final AttributeSpecifier specifier; /** * Create a new instance. * * @param specifier The attribute specifier to check against. */ public AttributeSpecifierChecker(AttributeSpecifier specifier) {
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/specifier/AttributeSpecifier.java // public class AttributeSpecifier implements Specifier { // // /** The type of match to perform for the attribute. */ // public static enum Match { // EXACT, LIST, HYPHEN, PREFIX, SUFFIX, CONTAINS // }; // // /** The name of the attribute. */ // private final String name; // // /** The attribute value. */ // private final String value; // // /** The type of match to perform for the attribute. */ // private final Match match; // // /** // * Create a new attribute specifier with the specified attribute name. // * <p> // * This attribute specifier is used to check if the attribute with the // * specified name exists whatever the value of the attribute. // * // * @param name The name of the attribute. // */ // public AttributeSpecifier(String name) { // Assert.notNull(name, "name is null!"); // this.name = name; // this.value = null; // this.match = null; // } // // /** // * Create a new attribute specifier with the specified name, value and match type. // * // * @param name The name of the attribute. // * @param value The attribute value. // * @param match The type of match to perform for the attribute. // */ // public AttributeSpecifier(String name, String value, Match match) { // Assert.notNull(name, "name is null!"); // Assert.notNull(value, "value is null!"); // Assert.notNull(match, "match is null!"); // this.name = name; // this.value = value; // this.match = match; // } // // /** // * Get the name of the attribute. // * // * @return The name of the attribute. // */ // public String getName() { // return name; // } // // /** // * Get the attribute value. // * // * @return The attribute value or {@code null}. // */ // public String getValue() { // return value; // } // // /** // * Get the type of match to perform for the attribute. // * // * @return The type of match or {@code null}. // */ // public Match getMatch() { // return match; // } // // /** // * {@inheritDoc} // */ // public Type getType() { // return Type.ATTRIBUTE; // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // } // Path: src/main/java/com/connect_group/thymesheet/css/selectors/dom/internal/AttributeSpecifierChecker.java import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.thymeleaf.dom.Attribute; import org.thymeleaf.dom.NestableAttributeHolderNode; import org.thymeleaf.dom.Node; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.connect_group.thymesheet.css.selectors.specifier.AttributeSpecifier; import com.connect_group.thymesheet.css.util.Assert; /** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.dom.internal; /** * A {@link NodeTraversalChecker} that check if a node's attribute * matches the {@linkplain AttributeSpecifier attribute specifier} set. * * @author Christer Sandberg */ public class AttributeSpecifierChecker extends NodeTraversalChecker { /** The attribute specifier to check against. */ private final AttributeSpecifier specifier; /** * Create a new instance. * * @param specifier The attribute specifier to check against. */ public AttributeSpecifierChecker(AttributeSpecifier specifier) {
Assert.notNull(specifier, "specifier is null!");
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/css/selectors/dom/internal/AttributeSpecifierChecker.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/specifier/AttributeSpecifier.java // public class AttributeSpecifier implements Specifier { // // /** The type of match to perform for the attribute. */ // public static enum Match { // EXACT, LIST, HYPHEN, PREFIX, SUFFIX, CONTAINS // }; // // /** The name of the attribute. */ // private final String name; // // /** The attribute value. */ // private final String value; // // /** The type of match to perform for the attribute. */ // private final Match match; // // /** // * Create a new attribute specifier with the specified attribute name. // * <p> // * This attribute specifier is used to check if the attribute with the // * specified name exists whatever the value of the attribute. // * // * @param name The name of the attribute. // */ // public AttributeSpecifier(String name) { // Assert.notNull(name, "name is null!"); // this.name = name; // this.value = null; // this.match = null; // } // // /** // * Create a new attribute specifier with the specified name, value and match type. // * // * @param name The name of the attribute. // * @param value The attribute value. // * @param match The type of match to perform for the attribute. // */ // public AttributeSpecifier(String name, String value, Match match) { // Assert.notNull(name, "name is null!"); // Assert.notNull(value, "value is null!"); // Assert.notNull(match, "match is null!"); // this.name = name; // this.value = value; // this.match = match; // } // // /** // * Get the name of the attribute. // * // * @return The name of the attribute. // */ // public String getName() { // return name; // } // // /** // * Get the attribute value. // * // * @return The attribute value or {@code null}. // */ // public String getValue() { // return value; // } // // /** // * Get the type of match to perform for the attribute. // * // * @return The type of match or {@code null}. // */ // public Match getMatch() { // return match; // } // // /** // * {@inheritDoc} // */ // public Type getType() { // return Type.ATTRIBUTE; // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // }
import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.thymeleaf.dom.Attribute; import org.thymeleaf.dom.NestableAttributeHolderNode; import org.thymeleaf.dom.Node; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.connect_group.thymesheet.css.selectors.specifier.AttributeSpecifier; import com.connect_group.thymesheet.css.util.Assert;
/** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.dom.internal; /** * A {@link NodeTraversalChecker} that check if a node's attribute * matches the {@linkplain AttributeSpecifier attribute specifier} set. * * @author Christer Sandberg */ public class AttributeSpecifierChecker extends NodeTraversalChecker { /** The attribute specifier to check against. */ private final AttributeSpecifier specifier; /** * Create a new instance. * * @param specifier The attribute specifier to check against. */ public AttributeSpecifierChecker(AttributeSpecifier specifier) { Assert.notNull(specifier, "specifier is null!"); this.specifier = specifier; } /** * {@inheritDoc} */ @Override
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/NodeSelectorException.java // public class NodeSelectorException extends Exception { // // /** Serial version UID. */ // private static final long serialVersionUID = -3786197030095043071L; // // /** // * Constructs a new exception with the specified detail message and cause. // * // * @param message The detail message. // * @param cause The cause. // */ // public NodeSelectorException(String message, Throwable cause) { // super(message, cause); // } // // /** // * Constructs a new exception with the specified detail message. // * // * @param message The detail message. // */ // public NodeSelectorException(String message) { // super(message); // } // // /** // * Constructs a new exception with the specified cause and a detail // * // * @param cause The cause. // */ // public NodeSelectorException(Throwable cause) { // super(cause); // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/selectors/specifier/AttributeSpecifier.java // public class AttributeSpecifier implements Specifier { // // /** The type of match to perform for the attribute. */ // public static enum Match { // EXACT, LIST, HYPHEN, PREFIX, SUFFIX, CONTAINS // }; // // /** The name of the attribute. */ // private final String name; // // /** The attribute value. */ // private final String value; // // /** The type of match to perform for the attribute. */ // private final Match match; // // /** // * Create a new attribute specifier with the specified attribute name. // * <p> // * This attribute specifier is used to check if the attribute with the // * specified name exists whatever the value of the attribute. // * // * @param name The name of the attribute. // */ // public AttributeSpecifier(String name) { // Assert.notNull(name, "name is null!"); // this.name = name; // this.value = null; // this.match = null; // } // // /** // * Create a new attribute specifier with the specified name, value and match type. // * // * @param name The name of the attribute. // * @param value The attribute value. // * @param match The type of match to perform for the attribute. // */ // public AttributeSpecifier(String name, String value, Match match) { // Assert.notNull(name, "name is null!"); // Assert.notNull(value, "value is null!"); // Assert.notNull(match, "match is null!"); // this.name = name; // this.value = value; // this.match = match; // } // // /** // * Get the name of the attribute. // * // * @return The name of the attribute. // */ // public String getName() { // return name; // } // // /** // * Get the attribute value. // * // * @return The attribute value or {@code null}. // */ // public String getValue() { // return value; // } // // /** // * Get the type of match to perform for the attribute. // * // * @return The type of match or {@code null}. // */ // public Match getMatch() { // return match; // } // // /** // * {@inheritDoc} // */ // public Type getType() { // return Type.ATTRIBUTE; // } // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // } // Path: src/main/java/com/connect_group/thymesheet/css/selectors/dom/internal/AttributeSpecifierChecker.java import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; import org.thymeleaf.dom.Attribute; import org.thymeleaf.dom.NestableAttributeHolderNode; import org.thymeleaf.dom.Node; import com.connect_group.thymesheet.css.selectors.NodeSelectorException; import com.connect_group.thymesheet.css.selectors.specifier.AttributeSpecifier; import com.connect_group.thymesheet.css.util.Assert; /** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.dom.internal; /** * A {@link NodeTraversalChecker} that check if a node's attribute * matches the {@linkplain AttributeSpecifier attribute specifier} set. * * @author Christer Sandberg */ public class AttributeSpecifierChecker extends NodeTraversalChecker { /** The attribute specifier to check against. */ private final AttributeSpecifier specifier; /** * Create a new instance. * * @param specifier The attribute specifier to check against. */ public AttributeSpecifierChecker(AttributeSpecifier specifier) { Assert.notNull(specifier, "specifier is null!"); this.specifier = specifier; } /** * {@inheritDoc} */ @Override
public Set<Node> check(Set<Node> nodes, Node root) throws NodeSelectorException {
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/css/selectors/specifier/PseudoNthSpecifier.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Specifier.java // public interface Specifier { // // /** The specifier type. */ // public static enum Type { // ATTRIBUTE, PSEUDO, NEGATION // }; // // /** // * Get the specifier type. // * // * @return The specifier type. // */ // public Type getType(); // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // }
import com.connect_group.thymesheet.css.selectors.Specifier; import com.connect_group.thymesheet.css.util.Assert;
/** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.specifier; /** * An implementation of {@link Specifier} for {@code nth-*} pseudo-classes. * * @see <a href="http://www.w3.org/TR/css3-selectors/#pseudo-classes">Pseudo-classes</a> * * @author Christer Sandberg */ public class PseudoNthSpecifier implements Specifier { /** The {@code nth-*} pseudo-class value (i.e. {@code nth-child} etc). */ private final String value; /** The {@code nth-*} pseudo-class argument (i.e. {@code 2n+1} etc). */ private final String argument; /** The parsed <em>a</em> value. */ private int a = 0; /** The parsed <em>b</em> value. */ private int b = 0; /** * Create a new {@code nth-*} pseudo-class instance with the * specified value and argument. * * @param value The {@code nth-*} pseudo-class value (i.e. {@code nth-child} etc). * @param argument The {@code nth-*} pseudo-class argument (i.e. {@code odd} etc). */ public PseudoNthSpecifier(String value, String argument) {
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Specifier.java // public interface Specifier { // // /** The specifier type. */ // public static enum Type { // ATTRIBUTE, PSEUDO, NEGATION // }; // // /** // * Get the specifier type. // * // * @return The specifier type. // */ // public Type getType(); // // } // // Path: src/main/java/com/connect_group/thymesheet/css/util/Assert.java // public final class Assert { // // /** // * Private CTOR. // */ // private Assert() { // } // // /** // * Check if the specified {@code expression} is {@code true}. If not throw an // * {@link IllegalArgumentException} with the specified {@code message}. // * // * @param expression The expression to check. // * @param message The exception message if the {@code expression} is {@code false}. // */ // public static void isTrue(boolean expression, String message) { // if (!expression) { // throw new IllegalArgumentException(message); // } // } // // /** // * Check if the specified {@code object} is {@code null}, and throw an // * {@link IllegalArgumentException} if it is. // * // * @param object The object to check. // * @param message The exception message if the {@code object} is {@code null}. // */ // public static void notNull(Object object, String message) { // if (object == null) { // throw new IllegalArgumentException(message); // } // } // // } // Path: src/main/java/com/connect_group/thymesheet/css/selectors/specifier/PseudoNthSpecifier.java import com.connect_group.thymesheet.css.selectors.Specifier; import com.connect_group.thymesheet.css.util.Assert; /** * Copyright (c) 2009-2012, Christer Sandberg * Thymesheet modifications Copyright (c) 2013 Adam Perry, Connect Group */ package com.connect_group.thymesheet.css.selectors.specifier; /** * An implementation of {@link Specifier} for {@code nth-*} pseudo-classes. * * @see <a href="http://www.w3.org/TR/css3-selectors/#pseudo-classes">Pseudo-classes</a> * * @author Christer Sandberg */ public class PseudoNthSpecifier implements Specifier { /** The {@code nth-*} pseudo-class value (i.e. {@code nth-child} etc). */ private final String value; /** The {@code nth-*} pseudo-class argument (i.e. {@code 2n+1} etc). */ private final String argument; /** The parsed <em>a</em> value. */ private int a = 0; /** The parsed <em>b</em> value. */ private int b = 0; /** * Create a new {@code nth-*} pseudo-class instance with the * specified value and argument. * * @param value The {@code nth-*} pseudo-class value (i.e. {@code nth-child} etc). * @param argument The {@code nth-*} pseudo-class argument (i.e. {@code odd} etc). */ public PseudoNthSpecifier(String value, String argument) {
Assert.notNull(value, "value is null!");
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/templatemode/IThymesheetTemplateModeHandler.java
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // }
import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import java.util.Set; import org.thymeleaf.templatemode.ITemplateModeHandler;
/* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public interface IThymesheetTemplateModeHandler extends ITemplateModeHandler { ServletContextURLFactory getUrlFactory(); void setUrlFactory(ServletContextURLFactory urlContainer);
// Path: src/main/java/com/connect_group/thymesheet/ServletContextURLFactory.java // public interface ServletContextURLFactory { // URL getURL(String filePath) throws MalformedURLException; // } // // Path: src/main/java/com/connect_group/thymesheet/ThymesheetParserPostProcessor.java // public interface ThymesheetParserPostProcessor { // void postProcess(String documentName, Document document) throws Exception; // } // Path: src/main/java/com/connect_group/thymesheet/templatemode/IThymesheetTemplateModeHandler.java import com.connect_group.thymesheet.ServletContextURLFactory; import com.connect_group.thymesheet.ThymesheetParserPostProcessor; import java.util.Set; import org.thymeleaf.templatemode.ITemplateModeHandler; /* * ============================================================================= * * Copyright (c) 2013, Connect Group (http://www.connect-group.com) * * 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 com.connect_group.thymesheet.templatemode; public interface IThymesheetTemplateModeHandler extends ITemplateModeHandler { ServletContextURLFactory getUrlFactory(); void setUrlFactory(ServletContextURLFactory urlContainer);
void setPostProcessors(Set<ThymesheetParserPostProcessor> postProcessors);
connect-group/thymesheet
src/test/java/com/connect_group/thymesheet/css/selectors/DOMHelperTest.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/dom/DOMHelper.java // public class DOMHelper { // // /** // * Private CTOR. // */ // private DOMHelper() { // } // // /** // * Get the first child node that is an element node. // * // * @param node The node whose children should be iterated. // * @return The first child element or {@code null}. // */ // public static Element getFirstChildElement(Node node) { // // if(node instanceof NestableNode) { // return ((NestableNode) node).getFirstElementChild(); // } // // return null; // } // // /** // * Get the next sibling element. // * // * @param node The start node. // * @return The next sibling element or {@code null}. // */ // public static final Element getNextSiblingElement(Node node) { // // List<Node> siblings = node.getParent().getChildren(); // Node n = null; // // int index = siblings.indexOf(node) + 1; // if(index>0 && index<siblings.size()) { // n = siblings.get(index); // while(!(n instanceof Element) && ++index < siblings.size()) { // n = siblings.get(index); // } // // if(index==siblings.size()) { // n = null; // } // } // // return (Element) n; // } // // /** // * Get the previous sibling element. // * // * @param node The start node. // * @return The previous sibling element or {@code null}. // */ // public static final Element getPreviousSiblingElement(Node node) { // // List<Node> siblings = node.getParent().getChildren(); // Node n = null; // // int index = siblings.indexOf(node) - 1; // // if(index>=0) { // n = siblings.get(index); // while(!(n instanceof Element) && --index >= 0) { // n = siblings.get(index); // } // // if(index<0) { // n = null; // } // } // // return (Element) n; // } // // public static final String getNodeName(Object node) { // if(node==null) { // return ""; // } if(node instanceof Element) { // return ((Element) node).getNormalizedName(); // } else if(node instanceof Text) { // return "#text"; // } else if(node instanceof Attribute) { // return ((Attribute) node).getNormalizedName(); // } else if (node instanceof Macro || node instanceof CDATASection) { // return "#cdata-section"; // } else if (node instanceof Comment) { // return "#comment"; // } else if(node instanceof Document) { // return "#document"; // } else if(node instanceof DocType) { // return ((DocType) node).getPublicId(); // } // // return ""; // } // // public static final Document getOwnerDocument(Node node) { // Document doc = null; // // if(node instanceof Document) { // doc = (Document) node; // } else { // // Node parent = node; // while(parent.hasParent()) { // parent = parent.getParent(); // // if(parent instanceof Document) { // doc = (Document)parent; // break; // } // } // // // } // return doc; // } // // public static final List<Node> getElementsByTagName(Node root, String tagName) { // ArrayList<Node> elements = new ArrayList<Node>(100); // getChildElementsByTagName(root, tagName, elements); // return elements; // } // // private static final void getChildElementsByTagName(Node node, String tagName, ArrayList<Node> elements) { // if(node instanceof NestableNode) { // List<Element> children = ((NestableNode) node).getElementChildren(); // // for(Element child : children) { // getElementsByTagName(child, tagName, elements); // } // } // // } // // private static final void getElementsByTagName(Node node, String tagName, ArrayList<Node> elements) { // // // if(node instanceof Element && (Selector.UNIVERSAL_TAG.equals(tagName) || ((Element)node).getNormalizedName().equalsIgnoreCase(tagName))) { // elements.add(node); // } // // getChildElementsByTagName(node, tagName, elements); // // } // // }
import static org.junit.Assert.*; import org.junit.Test; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Element; import com.connect_group.thymesheet.css.selectors.dom.DOMHelper;
package com.connect_group.thymesheet.css.selectors; public class DOMHelperTest { @Test public void testGetElementsByTagName() { Document doc = new Document(); Element html = new Element("html"); doc.addChild(html); Element body = new Element("body"); html.addChild(body); Element tag = new Element("a"); body.addChild(tag); tag = new Element("div"); body.addChild(tag); tag.addChild(new Element("span")); tag.addChild(new Element("div"));
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/dom/DOMHelper.java // public class DOMHelper { // // /** // * Private CTOR. // */ // private DOMHelper() { // } // // /** // * Get the first child node that is an element node. // * // * @param node The node whose children should be iterated. // * @return The first child element or {@code null}. // */ // public static Element getFirstChildElement(Node node) { // // if(node instanceof NestableNode) { // return ((NestableNode) node).getFirstElementChild(); // } // // return null; // } // // /** // * Get the next sibling element. // * // * @param node The start node. // * @return The next sibling element or {@code null}. // */ // public static final Element getNextSiblingElement(Node node) { // // List<Node> siblings = node.getParent().getChildren(); // Node n = null; // // int index = siblings.indexOf(node) + 1; // if(index>0 && index<siblings.size()) { // n = siblings.get(index); // while(!(n instanceof Element) && ++index < siblings.size()) { // n = siblings.get(index); // } // // if(index==siblings.size()) { // n = null; // } // } // // return (Element) n; // } // // /** // * Get the previous sibling element. // * // * @param node The start node. // * @return The previous sibling element or {@code null}. // */ // public static final Element getPreviousSiblingElement(Node node) { // // List<Node> siblings = node.getParent().getChildren(); // Node n = null; // // int index = siblings.indexOf(node) - 1; // // if(index>=0) { // n = siblings.get(index); // while(!(n instanceof Element) && --index >= 0) { // n = siblings.get(index); // } // // if(index<0) { // n = null; // } // } // // return (Element) n; // } // // public static final String getNodeName(Object node) { // if(node==null) { // return ""; // } if(node instanceof Element) { // return ((Element) node).getNormalizedName(); // } else if(node instanceof Text) { // return "#text"; // } else if(node instanceof Attribute) { // return ((Attribute) node).getNormalizedName(); // } else if (node instanceof Macro || node instanceof CDATASection) { // return "#cdata-section"; // } else if (node instanceof Comment) { // return "#comment"; // } else if(node instanceof Document) { // return "#document"; // } else if(node instanceof DocType) { // return ((DocType) node).getPublicId(); // } // // return ""; // } // // public static final Document getOwnerDocument(Node node) { // Document doc = null; // // if(node instanceof Document) { // doc = (Document) node; // } else { // // Node parent = node; // while(parent.hasParent()) { // parent = parent.getParent(); // // if(parent instanceof Document) { // doc = (Document)parent; // break; // } // } // // // } // return doc; // } // // public static final List<Node> getElementsByTagName(Node root, String tagName) { // ArrayList<Node> elements = new ArrayList<Node>(100); // getChildElementsByTagName(root, tagName, elements); // return elements; // } // // private static final void getChildElementsByTagName(Node node, String tagName, ArrayList<Node> elements) { // if(node instanceof NestableNode) { // List<Element> children = ((NestableNode) node).getElementChildren(); // // for(Element child : children) { // getElementsByTagName(child, tagName, elements); // } // } // // } // // private static final void getElementsByTagName(Node node, String tagName, ArrayList<Node> elements) { // // // if(node instanceof Element && (Selector.UNIVERSAL_TAG.equals(tagName) || ((Element)node).getNormalizedName().equalsIgnoreCase(tagName))) { // elements.add(node); // } // // getChildElementsByTagName(node, tagName, elements); // // } // // } // Path: src/test/java/com/connect_group/thymesheet/css/selectors/DOMHelperTest.java import static org.junit.Assert.*; import org.junit.Test; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Element; import com.connect_group.thymesheet.css.selectors.dom.DOMHelper; package com.connect_group.thymesheet.css.selectors; public class DOMHelperTest { @Test public void testGetElementsByTagName() { Document doc = new Document(); Element html = new Element("html"); doc.addChild(html); Element body = new Element("body"); html.addChild(body); Element tag = new Element("a"); body.addChild(tag); tag = new Element("div"); body.addChild(tag); tag.addChild(new Element("span")); tag.addChild(new Element("div"));
assertEquals(2, DOMHelper.getElementsByTagName(doc, "div").size());
connect-group/thymesheet
src/main/java/com/connect_group/thymesheet/css/selectors/dom/DOMHelper.java
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Selector.java // public class Selector { // // /** The universal tag name (i.e. {@code *}). */ // public static final String UNIVERSAL_TAG = "*"; // // /** // * Combinators // * // * @see <a href="http://www.w3.org/TR/css3-selectors/#combinators">Combinators description</a> // */ // public static enum Combinator { // DESCENDANT, CHILD, ADJACENT_SIBLING, GENERAL_SIBLING // } // // /** Tag name. */ // private final String tagName; // // /** Combinator */ // private final Combinator combinator; // // /** A list of {@linkplain Specifier specifiers}. */ // private final List<Specifier> specifiers; // // /** // * Create a new instance with the tag name set to the value of {@link #UNIVERSAL_TAG}, // * and with the combinator set to {@link Combinator#DESCENDANT}. The list of // * {@linkplain #specifiers specifiers} will be set to {@code null}. // */ // public Selector() { // this.tagName = UNIVERSAL_TAG; // this.combinator = Combinator.DESCENDANT; // this.specifiers = null; // } // // /** // * Create a new instance with the specified tag name and combinator. // * <p> // * The list of {@linkplain #specifiers specifiers} will be set to {@code null}. // * // * @param tagName The tag name to set. // * @param combinator The combinator to set. // */ // public Selector(String tagName, Combinator combinator) { // Assert.notNull(tagName, "tagName is null!"); // Assert.notNull(combinator, "combinator is null!"); // this.tagName = tagName; // this.combinator = combinator; // this.specifiers = null; // } // // /** // * Create a new instance with the specified tag name and list of specifiers. // * <p> // * The combinator will be set to {@link Combinator#DESCENDANT}. // * // * @param tagName The tag name to set. // * @param specifiers The list of specifiers to set. // */ // public Selector(String tagName, List<Specifier> specifiers) { // Assert.notNull(tagName, "tagName is null!"); // this.tagName = tagName; // this.combinator = Combinator.DESCENDANT; // this.specifiers = specifiers; // } // // /** // * Create a new instance with the specified tag name, combinator and // * list of specifiers. // * // * @param tagName The tag name to set. // * @param combinator The combinator to set. // * @param specifiers The list of specifiers to set. // */ // public Selector(String tagName, Combinator combinator, List<Specifier> specifiers) { // Assert.notNull(tagName, "tagName is null!"); // Assert.notNull(combinator, "combinator is null!"); // this.tagName = tagName; // this.combinator = combinator; // this.specifiers = specifiers; // } // // /** // * Get the tag name. // * // * @return The tag name. // */ // public String getTagName() { // return tagName; // } // // /** // * Get the combinator. // * // * @return The combinator. // */ // public Combinator getCombinator() { // return combinator; // } // // /** // * Get the list of specifiers. // * // * @return The list of specifiers or {@code null}. // */ // public List<Specifier> getSpecifiers() { // return specifiers; // } // // /** // * Returns whether this selector has any specifiers or not. // * // * @return <code>true</code> or <code>false</code>. // */ // public boolean hasSpecifiers() { // return specifiers != null && !specifiers.isEmpty(); // } // // }
import java.util.ArrayList; import java.util.List; import org.thymeleaf.dom.Attribute; import org.thymeleaf.dom.CDATASection; import org.thymeleaf.dom.Comment; import org.thymeleaf.dom.DocType; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Element; import org.thymeleaf.dom.Macro; import org.thymeleaf.dom.NestableNode; import org.thymeleaf.dom.Node; import org.thymeleaf.dom.Text; import com.connect_group.thymesheet.css.selectors.Selector;
doc = (Document)parent; break; } } } return doc; } public static final List<Node> getElementsByTagName(Node root, String tagName) { ArrayList<Node> elements = new ArrayList<Node>(100); getChildElementsByTagName(root, tagName, elements); return elements; } private static final void getChildElementsByTagName(Node node, String tagName, ArrayList<Node> elements) { if(node instanceof NestableNode) { List<Element> children = ((NestableNode) node).getElementChildren(); for(Element child : children) { getElementsByTagName(child, tagName, elements); } } } private static final void getElementsByTagName(Node node, String tagName, ArrayList<Node> elements) {
// Path: src/main/java/com/connect_group/thymesheet/css/selectors/Selector.java // public class Selector { // // /** The universal tag name (i.e. {@code *}). */ // public static final String UNIVERSAL_TAG = "*"; // // /** // * Combinators // * // * @see <a href="http://www.w3.org/TR/css3-selectors/#combinators">Combinators description</a> // */ // public static enum Combinator { // DESCENDANT, CHILD, ADJACENT_SIBLING, GENERAL_SIBLING // } // // /** Tag name. */ // private final String tagName; // // /** Combinator */ // private final Combinator combinator; // // /** A list of {@linkplain Specifier specifiers}. */ // private final List<Specifier> specifiers; // // /** // * Create a new instance with the tag name set to the value of {@link #UNIVERSAL_TAG}, // * and with the combinator set to {@link Combinator#DESCENDANT}. The list of // * {@linkplain #specifiers specifiers} will be set to {@code null}. // */ // public Selector() { // this.tagName = UNIVERSAL_TAG; // this.combinator = Combinator.DESCENDANT; // this.specifiers = null; // } // // /** // * Create a new instance with the specified tag name and combinator. // * <p> // * The list of {@linkplain #specifiers specifiers} will be set to {@code null}. // * // * @param tagName The tag name to set. // * @param combinator The combinator to set. // */ // public Selector(String tagName, Combinator combinator) { // Assert.notNull(tagName, "tagName is null!"); // Assert.notNull(combinator, "combinator is null!"); // this.tagName = tagName; // this.combinator = combinator; // this.specifiers = null; // } // // /** // * Create a new instance with the specified tag name and list of specifiers. // * <p> // * The combinator will be set to {@link Combinator#DESCENDANT}. // * // * @param tagName The tag name to set. // * @param specifiers The list of specifiers to set. // */ // public Selector(String tagName, List<Specifier> specifiers) { // Assert.notNull(tagName, "tagName is null!"); // this.tagName = tagName; // this.combinator = Combinator.DESCENDANT; // this.specifiers = specifiers; // } // // /** // * Create a new instance with the specified tag name, combinator and // * list of specifiers. // * // * @param tagName The tag name to set. // * @param combinator The combinator to set. // * @param specifiers The list of specifiers to set. // */ // public Selector(String tagName, Combinator combinator, List<Specifier> specifiers) { // Assert.notNull(tagName, "tagName is null!"); // Assert.notNull(combinator, "combinator is null!"); // this.tagName = tagName; // this.combinator = combinator; // this.specifiers = specifiers; // } // // /** // * Get the tag name. // * // * @return The tag name. // */ // public String getTagName() { // return tagName; // } // // /** // * Get the combinator. // * // * @return The combinator. // */ // public Combinator getCombinator() { // return combinator; // } // // /** // * Get the list of specifiers. // * // * @return The list of specifiers or {@code null}. // */ // public List<Specifier> getSpecifiers() { // return specifiers; // } // // /** // * Returns whether this selector has any specifiers or not. // * // * @return <code>true</code> or <code>false</code>. // */ // public boolean hasSpecifiers() { // return specifiers != null && !specifiers.isEmpty(); // } // // } // Path: src/main/java/com/connect_group/thymesheet/css/selectors/dom/DOMHelper.java import java.util.ArrayList; import java.util.List; import org.thymeleaf.dom.Attribute; import org.thymeleaf.dom.CDATASection; import org.thymeleaf.dom.Comment; import org.thymeleaf.dom.DocType; import org.thymeleaf.dom.Document; import org.thymeleaf.dom.Element; import org.thymeleaf.dom.Macro; import org.thymeleaf.dom.NestableNode; import org.thymeleaf.dom.Node; import org.thymeleaf.dom.Text; import com.connect_group.thymesheet.css.selectors.Selector; doc = (Document)parent; break; } } } return doc; } public static final List<Node> getElementsByTagName(Node root, String tagName) { ArrayList<Node> elements = new ArrayList<Node>(100); getChildElementsByTagName(root, tagName, elements); return elements; } private static final void getChildElementsByTagName(Node node, String tagName, ArrayList<Node> elements) { if(node instanceof NestableNode) { List<Element> children = ((NestableNode) node).getElementChildren(); for(Element child : children) { getElementsByTagName(child, tagName, elements); } } } private static final void getElementsByTagName(Node node, String tagName, ArrayList<Node> elements) {
if(node instanceof Element && (Selector.UNIVERSAL_TAG.equals(tagName) || ((Element)node).getNormalizedName().equalsIgnoreCase(tagName))) {
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/Response.java
// Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // }
import com.ecwid.consul.transport.HttpResponse;
package com.ecwid.consul.v1; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public final class Response<T> { private final T value; private final Long consulIndex; private final Boolean consulKnownLeader; private final Long consulLastContact; public Response(T value, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { this.value = value; this.consulIndex = consulIndex; this.consulKnownLeader = consulKnownLeader; this.consulLastContact = consulLastContact; }
// Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // Path: src/main/java/com/ecwid/consul/v1/Response.java import com.ecwid.consul.transport.HttpResponse; package com.ecwid.consul.v1; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public final class Response<T> { private final T value; private final Long consulIndex; private final Boolean consulKnownLeader; private final Long consulLastContact; public Response(T value, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { this.value = value; this.consulIndex = consulIndex; this.consulKnownLeader = consulKnownLeader; this.consulLastContact = consulLastContact; }
public Response(T value, HttpResponse httpResponse) {
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/kv/model/GetBinaryValue.java
// Path: src/main/java/com/ecwid/consul/json/Base64TypeAdapter.java // public class Base64TypeAdapter extends TypeAdapter<byte[]> { // // @Override // public void write(JsonWriter out, byte[] value) throws IOException { // if (value == null) { // out.nullValue(); // } else { // out.value(Base64.getEncoder().encodeToString(value)); // } // } // // @Override // public byte[] read(JsonReader in) throws IOException { // if (in.peek() == JsonToken.NULL) { // in.nextNull(); // return new byte[0]; // } else { // String data = in.nextString(); // return Base64.getDecoder().decode(data); // } // } // }
import com.ecwid.consul.json.Base64TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import java.util.Arrays;
package com.ecwid.consul.v1.kv.model; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public class GetBinaryValue { @SerializedName("CreateIndex") private long createIndex; @SerializedName("ModifyIndex") private long modifyIndex; @SerializedName("LockIndex") private Long lockIndex; @SerializedName("Flags") private long flags; @SerializedName("Session") private String session; @SerializedName("Key") private String key; @SerializedName("Value")
// Path: src/main/java/com/ecwid/consul/json/Base64TypeAdapter.java // public class Base64TypeAdapter extends TypeAdapter<byte[]> { // // @Override // public void write(JsonWriter out, byte[] value) throws IOException { // if (value == null) { // out.nullValue(); // } else { // out.value(Base64.getEncoder().encodeToString(value)); // } // } // // @Override // public byte[] read(JsonReader in) throws IOException { // if (in.peek() == JsonToken.NULL) { // in.nextNull(); // return new byte[0]; // } else { // String data = in.nextString(); // return Base64.getDecoder().decode(data); // } // } // } // Path: src/main/java/com/ecwid/consul/v1/kv/model/GetBinaryValue.java import com.ecwid.consul.json.Base64TypeAdapter; import com.google.gson.annotations.JsonAdapter; import com.google.gson.annotations.SerializedName; import java.util.Arrays; package com.ecwid.consul.v1.kv.model; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public class GetBinaryValue { @SerializedName("CreateIndex") private long createIndex; @SerializedName("ModifyIndex") private long modifyIndex; @SerializedName("LockIndex") private Long lockIndex; @SerializedName("Flags") private long flags; @SerializedName("Session") private String session; @SerializedName("Key") private String key; @SerializedName("Value")
@JsonAdapter(Base64TypeAdapter.class)
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // }
import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
package com.ecwid.consul.v1.catalog; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public final class CatalogConsulClient implements CatalogClient { private final ConsulRawClient rawClient; public CatalogConsulClient(ConsulRawClient rawClient) { this.rawClient = rawClient; } public CatalogConsulClient() { this(new ConsulRawClient()); }
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // } // Path: src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; package com.ecwid.consul.v1.catalog; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public final class CatalogConsulClient implements CatalogClient { private final ConsulRawClient rawClient; public CatalogConsulClient(ConsulRawClient rawClient) { this.rawClient = rawClient; } public CatalogConsulClient() { this(new ConsulRawClient()); }
public CatalogConsulClient(TLSConfig tlsConfig) {
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // }
import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
package com.ecwid.consul.v1.catalog; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public final class CatalogConsulClient implements CatalogClient { private final ConsulRawClient rawClient; public CatalogConsulClient(ConsulRawClient rawClient) { this.rawClient = rawClient; } public CatalogConsulClient() { this(new ConsulRawClient()); } public CatalogConsulClient(TLSConfig tlsConfig) { this(new ConsulRawClient(tlsConfig)); } public CatalogConsulClient(String agentHost) { this(new ConsulRawClient(agentHost)); } public CatalogConsulClient(String agentHost, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, tlsConfig)); } public CatalogConsulClient(String agentHost, int agentPort) { this(new ConsulRawClient(agentHost, agentPort)); } public CatalogConsulClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, agentPort, tlsConfig)); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration) { return catalogRegister(catalogRegistration, null); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token) {
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // } // Path: src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; package com.ecwid.consul.v1.catalog; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public final class CatalogConsulClient implements CatalogClient { private final ConsulRawClient rawClient; public CatalogConsulClient(ConsulRawClient rawClient) { this.rawClient = rawClient; } public CatalogConsulClient() { this(new ConsulRawClient()); } public CatalogConsulClient(TLSConfig tlsConfig) { this(new ConsulRawClient(tlsConfig)); } public CatalogConsulClient(String agentHost) { this(new ConsulRawClient(agentHost)); } public CatalogConsulClient(String agentHost, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, tlsConfig)); } public CatalogConsulClient(String agentHost, int agentPort) { this(new ConsulRawClient(agentHost, agentPort)); } public CatalogConsulClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, agentPort, tlsConfig)); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration) { return catalogRegister(catalogRegistration, null); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token) {
String json = GsonFactory.getGson().toJson(catalogRegistration);
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // }
import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
} public CatalogConsulClient(TLSConfig tlsConfig) { this(new ConsulRawClient(tlsConfig)); } public CatalogConsulClient(String agentHost) { this(new ConsulRawClient(agentHost)); } public CatalogConsulClient(String agentHost, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, tlsConfig)); } public CatalogConsulClient(String agentHost, int agentPort) { this(new ConsulRawClient(agentHost, agentPort)); } public CatalogConsulClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, agentPort, tlsConfig)); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration) { return catalogRegister(catalogRegistration, null); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token) { String json = GsonFactory.getGson().toJson(catalogRegistration);
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // } // Path: src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; } public CatalogConsulClient(TLSConfig tlsConfig) { this(new ConsulRawClient(tlsConfig)); } public CatalogConsulClient(String agentHost) { this(new ConsulRawClient(agentHost)); } public CatalogConsulClient(String agentHost, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, tlsConfig)); } public CatalogConsulClient(String agentHost, int agentPort) { this(new ConsulRawClient(agentHost, agentPort)); } public CatalogConsulClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, agentPort, tlsConfig)); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration) { return catalogRegister(catalogRegistration, null); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token) { String json = GsonFactory.getGson().toJson(catalogRegistration);
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // }
import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
} public CatalogConsulClient(TLSConfig tlsConfig) { this(new ConsulRawClient(tlsConfig)); } public CatalogConsulClient(String agentHost) { this(new ConsulRawClient(agentHost)); } public CatalogConsulClient(String agentHost, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, tlsConfig)); } public CatalogConsulClient(String agentHost, int agentPort) { this(new ConsulRawClient(agentHost, agentPort)); } public CatalogConsulClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, agentPort, tlsConfig)); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration) { return catalogRegister(catalogRegistration, null); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token) { String json = GsonFactory.getGson().toJson(catalogRegistration);
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // } // Path: src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; } public CatalogConsulClient(TLSConfig tlsConfig) { this(new ConsulRawClient(tlsConfig)); } public CatalogConsulClient(String agentHost) { this(new ConsulRawClient(agentHost)); } public CatalogConsulClient(String agentHost, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, tlsConfig)); } public CatalogConsulClient(String agentHost, int agentPort) { this(new ConsulRawClient(agentHost, agentPort)); } public CatalogConsulClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, agentPort, tlsConfig)); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration) { return catalogRegister(catalogRegistration, null); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token) { String json = GsonFactory.getGson().toJson(catalogRegistration);
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // }
import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map;
public CatalogConsulClient(TLSConfig tlsConfig) { this(new ConsulRawClient(tlsConfig)); } public CatalogConsulClient(String agentHost) { this(new ConsulRawClient(agentHost)); } public CatalogConsulClient(String agentHost, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, tlsConfig)); } public CatalogConsulClient(String agentHost, int agentPort) { this(new ConsulRawClient(agentHost, agentPort)); } public CatalogConsulClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, agentPort, tlsConfig)); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration) { return catalogRegister(catalogRegistration, null); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token) { String json = GsonFactory.getGson().toJson(catalogRegistration); UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
// Path: src/main/java/com/ecwid/consul/SingleUrlParameters.java // public final class SingleUrlParameters implements UrlParameters { // // private final String key; // private final String value; // // public SingleUrlParameters(String key) { // this.key = key; // this.value = null; // } // // public SingleUrlParameters(String key, String value) { // this.key = key; // this.value = value; // } // // @Override // public List<String> toUrlParameters() { // if (value != null) { // return Collections.singletonList(key + "=" + Utils.encodeValue(value)); // } else { // return Collections.singletonList(key); // } // } // // @Override // public boolean equals(Object o) { // if (this == o) { // return true; // } // if (!(o instanceof SingleUrlParameters)) { // return false; // } // SingleUrlParameters that = (SingleUrlParameters) o; // return Objects.equals(key, that.key) && // Objects.equals(value, that.value); // } // // @Override // public int hashCode() { // return Objects.hash(key, value); // } // } // // Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/json/GsonFactory.java // public class GsonFactory { // // private static final Gson GSON = new Gson(); // // public static Gson getGson() { // return GSON; // } // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // // Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public final class TLSConfig { // // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // // private final KeyStoreInstanceType keyStoreInstanceType; // private final String certificatePath; // private final String certificatePassword; // private final String keyStorePath; // private final String keyStorePassword; // // public TLSConfig(KeyStoreInstanceType keyStoreInstanceType, String certificatePath, String certificatePassword, String keyStorePath, // String keyStorePassword) { // this.keyStoreInstanceType = keyStoreInstanceType; // this.certificatePath = certificatePath; // this.certificatePassword = certificatePassword; // this.keyStorePath = keyStorePath; // this.keyStorePassword = keyStorePassword; // } // // public KeyStoreInstanceType getKeyStoreInstanceType() { // return keyStoreInstanceType; // } // // public String getCertificatePath() { // return certificatePath; // } // // public String getCertificatePassword() { // return certificatePassword; // } // // public String getKeyStorePath() { // return keyStorePath; // } // // public String getKeyStorePassword() { // return keyStorePassword; // } // } // Path: src/main/java/com/ecwid/consul/v1/catalog/CatalogConsulClient.java import com.ecwid.consul.SingleUrlParameters; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.json.GsonFactory; import com.ecwid.consul.transport.HttpResponse; import com.ecwid.consul.transport.TLSConfig; import com.ecwid.consul.v1.*; import com.ecwid.consul.v1.catalog.model.*; import com.google.gson.reflect.TypeToken; import java.util.List; import java.util.Map; public CatalogConsulClient(TLSConfig tlsConfig) { this(new ConsulRawClient(tlsConfig)); } public CatalogConsulClient(String agentHost) { this(new ConsulRawClient(agentHost)); } public CatalogConsulClient(String agentHost, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, tlsConfig)); } public CatalogConsulClient(String agentHost, int agentPort) { this(new ConsulRawClient(agentHost, agentPort)); } public CatalogConsulClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new ConsulRawClient(agentHost, agentPort, tlsConfig)); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration) { return catalogRegister(catalogRegistration, null); } @Override public Response<Void> catalogRegister(CatalogRegistration catalogRegistration, String token) { String json = GsonFactory.getGson().toJson(catalogRegistration); UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
HttpResponse httpResponse = rawClient.makePutRequest("/v1/catalog/register", json, tokenParam);
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/OperationException.java
// Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // }
import com.ecwid.consul.ConsulException; import com.ecwid.consul.transport.HttpResponse;
package com.ecwid.consul.v1; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public final class OperationException extends ConsulException { private final int statusCode; private final String statusMessage; private final String statusContent; public OperationException(int statusCode, String statusMessage, String statusContent) { super("OperationException(statusCode=" + statusCode + ", statusMessage='" + statusMessage + "', statusContent='" + statusContent + "')"); this.statusCode = statusCode; this.statusMessage = statusMessage; this.statusContent = statusContent; }
// Path: src/main/java/com/ecwid/consul/transport/HttpResponse.java // public final class HttpResponse { // // private final int statusCode; // private final String statusMessage; // // private final String content; // // private final Long consulIndex; // private final Boolean consulKnownLeader; // private final Long consulLastContact; // // public HttpResponse(int statusCode, String statusMessage, String content, Long consulIndex, Boolean consulKnownLeader, Long consulLastContact) { // this.statusCode = statusCode; // this.statusMessage = statusMessage; // this.content = content; // this.consulIndex = consulIndex; // this.consulKnownLeader = consulKnownLeader; // this.consulLastContact = consulLastContact; // } // // public int getStatusCode() { // return statusCode; // } // // public String getStatusMessage() { // return statusMessage; // } // // public String getContent() { // return content; // } // // public Long getConsulIndex() { // return consulIndex; // } // // public Boolean isConsulKnownLeader() { // return consulKnownLeader; // } // // public Long getConsulLastContact() { // return consulLastContact; // } // } // Path: src/main/java/com/ecwid/consul/v1/OperationException.java import com.ecwid.consul.ConsulException; import com.ecwid.consul.transport.HttpResponse; package com.ecwid.consul.v1; /** * @author Vasily Vasilkov (vgv@ecwid.com) */ public final class OperationException extends ConsulException { private final int statusCode; private final String statusMessage; private final String statusContent; public OperationException(int statusCode, String statusMessage, String statusContent) { super("OperationException(statusCode=" + statusCode + ", statusMessage='" + statusMessage + "', statusContent='" + statusContent + "')"); this.statusCode = statusCode; this.statusMessage = statusMessage; this.statusContent = statusContent; }
public OperationException(HttpResponse httpResponse) {
Ecwid/consul-api
src/test/java/com/ecwid/consul/v1/kv/KeyValueConsulClientTest.java
// Path: src/test/java/com/ecwid/consul/ConsulTestConstants.java // public class ConsulTestConstants { // // public static final String CONSUL_VERSION = "1.6.0"; // // }
import com.ecwid.consul.ConsulTestConstants; import com.pszymczyk.consul.ConsulProcess; import com.pszymczyk.consul.ConsulStarterBuilder; import com.pszymczyk.consul.infrastructure.Ports; import org.apache.commons.lang.math.RandomUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.Random;
package com.ecwid.consul.v1.kv; class KeyValueConsulClientTest { private static final Random rnd = new Random(); private ConsulProcess consul; private int port = Ports.nextAvailable(); private KeyValueConsulClient consulClient = new KeyValueConsulClient("localhost", port); @BeforeEach void setUp() { consul = ConsulStarterBuilder.consulStarter()
// Path: src/test/java/com/ecwid/consul/ConsulTestConstants.java // public class ConsulTestConstants { // // public static final String CONSUL_VERSION = "1.6.0"; // // } // Path: src/test/java/com/ecwid/consul/v1/kv/KeyValueConsulClientTest.java import com.ecwid.consul.ConsulTestConstants; import com.pszymczyk.consul.ConsulProcess; import com.pszymczyk.consul.ConsulStarterBuilder; import com.pszymczyk.consul.infrastructure.Ports; import org.apache.commons.lang.math.RandomUtils; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import java.util.Random; package com.ecwid.consul.v1.kv; class KeyValueConsulClientTest { private static final Random rnd = new Random(); private ConsulProcess consul; private int port = Ports.nextAvailable(); private KeyValueConsulClient consulClient = new KeyValueConsulClient("localhost", port); @BeforeEach void setUp() { consul = ConsulStarterBuilder.consulStarter()
.withConsulVersion(ConsulTestConstants.CONSUL_VERSION)
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/event/model/EventParams.java
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // }
import java.util.ArrayList; import java.util.List; import java.util.Objects; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils;
public String getService() { return service; } public void setService(String service) { this.service = service; } public String getTag() { return tag; } public void setTag(String tag) { this.tag = tag; } public String getNode() { return node; } public void setNode(String node) { this.node = node; } @Override public List<String> toUrlParameters() { List<String> result = new ArrayList<String>(); if (name != null) {
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // } // Path: src/main/java/com/ecwid/consul/v1/event/model/EventParams.java import java.util.ArrayList; import java.util.List; import java.util.Objects; import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; public String getService() { return service; } public void setService(String service) { this.service = service; } public String getTag() { return tag; } public void setTag(String tag) { this.tag = tag; } public String getNode() { return node; } public void setNode(String node) { this.node = node; } @Override public List<String> toUrlParameters() { List<String> result = new ArrayList<String>(); if (name != null) {
result.add("name=" + Utils.encodeValue(name));
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/ConsulRawClient.java
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // }
import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; import com.ecwid.consul.transport.*; import org.apache.http.client.HttpClient; import java.util.Arrays; import java.util.List;
this(DEFAULT_HOST, httpClient); } public ConsulRawClient(String agentHost, HttpClient httpClient) { this(new DefaultHttpTransport(httpClient), agentHost, DEFAULT_PORT, DEFAULT_PATH); } public ConsulRawClient(String agentHost, int agentPort, HttpClient httpClient) { this(new DefaultHttpTransport(httpClient), agentHost, agentPort, DEFAULT_PATH); } public ConsulRawClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new DefaultHttpsTransport(tlsConfig), agentHost, agentPort, DEFAULT_PATH); } public ConsulRawClient(HttpClient httpClient, String host, int port, String path) { this(new DefaultHttpTransport(httpClient), host, port, path); } // hidden constructor, for tests ConsulRawClient(HttpTransport httpTransport, String agentHost, int agentPort, String path) { this.httpTransport = httpTransport; // check that agentHost has scheme or not String agentHostLowercase = agentHost.toLowerCase(); if (!agentHostLowercase.startsWith("https://") && !agentHostLowercase.startsWith("http://")) { // no scheme in host, use default 'http' agentHost = "http://" + agentHost; }
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // } // Path: src/main/java/com/ecwid/consul/v1/ConsulRawClient.java import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; import com.ecwid.consul.transport.*; import org.apache.http.client.HttpClient; import java.util.Arrays; import java.util.List; this(DEFAULT_HOST, httpClient); } public ConsulRawClient(String agentHost, HttpClient httpClient) { this(new DefaultHttpTransport(httpClient), agentHost, DEFAULT_PORT, DEFAULT_PATH); } public ConsulRawClient(String agentHost, int agentPort, HttpClient httpClient) { this(new DefaultHttpTransport(httpClient), agentHost, agentPort, DEFAULT_PATH); } public ConsulRawClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new DefaultHttpsTransport(tlsConfig), agentHost, agentPort, DEFAULT_PATH); } public ConsulRawClient(HttpClient httpClient, String host, int port, String path) { this(new DefaultHttpTransport(httpClient), host, port, path); } // hidden constructor, for tests ConsulRawClient(HttpTransport httpTransport, String agentHost, int agentPort, String path) { this.httpTransport = httpTransport; // check that agentHost has scheme or not String agentHostLowercase = agentHost.toLowerCase(); if (!agentHostLowercase.startsWith("https://") && !agentHostLowercase.startsWith("http://")) { // no scheme in host, use default 'http' agentHost = "http://" + agentHost; }
this.agentAddress = Utils.assembleAgentAddress(agentHost, agentPort, path);
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/ConsulRawClient.java
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // }
import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; import com.ecwid.consul.transport.*; import org.apache.http.client.HttpClient; import java.util.Arrays; import java.util.List;
public ConsulRawClient(String agentHost, HttpClient httpClient) { this(new DefaultHttpTransport(httpClient), agentHost, DEFAULT_PORT, DEFAULT_PATH); } public ConsulRawClient(String agentHost, int agentPort, HttpClient httpClient) { this(new DefaultHttpTransport(httpClient), agentHost, agentPort, DEFAULT_PATH); } public ConsulRawClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new DefaultHttpsTransport(tlsConfig), agentHost, agentPort, DEFAULT_PATH); } public ConsulRawClient(HttpClient httpClient, String host, int port, String path) { this(new DefaultHttpTransport(httpClient), host, port, path); } // hidden constructor, for tests ConsulRawClient(HttpTransport httpTransport, String agentHost, int agentPort, String path) { this.httpTransport = httpTransport; // check that agentHost has scheme or not String agentHostLowercase = agentHost.toLowerCase(); if (!agentHostLowercase.startsWith("https://") && !agentHostLowercase.startsWith("http://")) { // no scheme in host, use default 'http' agentHost = "http://" + agentHost; } this.agentAddress = Utils.assembleAgentAddress(agentHost, agentPort, path); }
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // } // Path: src/main/java/com/ecwid/consul/v1/ConsulRawClient.java import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; import com.ecwid.consul.transport.*; import org.apache.http.client.HttpClient; import java.util.Arrays; import java.util.List; public ConsulRawClient(String agentHost, HttpClient httpClient) { this(new DefaultHttpTransport(httpClient), agentHost, DEFAULT_PORT, DEFAULT_PATH); } public ConsulRawClient(String agentHost, int agentPort, HttpClient httpClient) { this(new DefaultHttpTransport(httpClient), agentHost, agentPort, DEFAULT_PATH); } public ConsulRawClient(String agentHost, int agentPort, TLSConfig tlsConfig) { this(new DefaultHttpsTransport(tlsConfig), agentHost, agentPort, DEFAULT_PATH); } public ConsulRawClient(HttpClient httpClient, String host, int port, String path) { this(new DefaultHttpTransport(httpClient), host, port, path); } // hidden constructor, for tests ConsulRawClient(HttpTransport httpTransport, String agentHost, int agentPort, String path) { this.httpTransport = httpTransport; // check that agentHost has scheme or not String agentHostLowercase = agentHost.toLowerCase(); if (!agentHostLowercase.startsWith("https://") && !agentHostLowercase.startsWith("http://")) { // no scheme in host, use default 'http' agentHost = "http://" + agentHost; } this.agentAddress = Utils.assembleAgentAddress(agentHost, agentPort, path); }
public HttpResponse makeGetRequest(String endpoint, UrlParameters... urlParams) {
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/QueryParams.java
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // }
import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; import java.util.ArrayList; import java.util.List; import java.util.Objects;
public QueryParams(String datacenter, long waitTime, long index) { this(datacenter, ConsistencyMode.DEFAULT, waitTime, index, null); } public String getDatacenter() { return datacenter; } public ConsistencyMode getConsistencyMode() { return consistencyMode; } public long getWaitTime() { return waitTime; } public long getIndex() { return index; } public String getNear() { return near; } @Override public List<String> toUrlParameters() { List<String> params = new ArrayList<String>(); // add basic params if (datacenter != null) {
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // } // Path: src/main/java/com/ecwid/consul/v1/QueryParams.java import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; import java.util.ArrayList; import java.util.List; import java.util.Objects; public QueryParams(String datacenter, long waitTime, long index) { this(datacenter, ConsistencyMode.DEFAULT, waitTime, index, null); } public String getDatacenter() { return datacenter; } public ConsistencyMode getConsistencyMode() { return consistencyMode; } public long getWaitTime() { return waitTime; } public long getIndex() { return index; } public String getNear() { return near; } @Override public List<String> toUrlParameters() { List<String> params = new ArrayList<String>(); // add basic params if (datacenter != null) {
params.add("dc=" + Utils.encodeValue(datacenter));
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/kv/model/PutParams.java
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // }
import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; import java.math.BigInteger; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Objects;
this.cas = cas; } public String getAcquireSession() { return acquireSession; } public void setAcquireSession(String acquireSession) { this.acquireSession = acquireSession; } public String getReleaseSession() { return releaseSession; } public void setReleaseSession(String releaseSession) { this.releaseSession = releaseSession; } @Override public List<String> toUrlParameters() { List<String> params = new ArrayList<String>(); if (flags != 0) { params.add("flags=" + flags); } if (cas != null) { params.add("cas=" + cas); } if (acquireSession != null) {
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/Utils.java // public class Utils { // // public static String encodeValue(String value) { // try { // return URLEncoder.encode(value, "UTF-8"); // } catch (UnsupportedEncodingException e) { // throw new RuntimeException("So strange - every JVM has to support UTF-8 encoding."); // } // } // // public static String encodeUrl(String str) { // try { // URL url = new URL(str); // URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef()); // return uri.toASCIIString(); // } catch (Exception e) { // throw new RuntimeException("Can't encode url", e); // } // } // // public static String generateUrl(String baseUrl, UrlParameters... params) { // return generateUrl(baseUrl, Arrays.asList(params)); // } // // public static String generateUrl(String baseUrl, List<UrlParameters> params) { // if (params == null) { // return baseUrl; // } // // List<String> allParams = new ArrayList<String>(); // for (UrlParameters item : params) { // if (item != null) { // allParams.addAll(item.toUrlParameters()); // } // } // // // construct the whole url // StringBuilder result = new StringBuilder(baseUrl); // // Iterator<String> paramsIterator = allParams.iterator(); // if (paramsIterator.hasNext()) { // result.append("?").append(paramsIterator.next()); // while (paramsIterator.hasNext()) { // result.append("&").append(paramsIterator.next()); // } // } // return result.toString(); // } // // public static Map<String, String> createTokenMap(String token) { // Map<String, String> headers = new HashMap<>(); // headers.put("X-Consul-Token", token); // return headers; // } // // public static String toSecondsString(long waitTime) { // return String.valueOf(waitTime) + "s"; // } // // public static String assembleAgentAddress(String host, int port, String path) { // String agentPath = ""; // if (path != null && !path.trim().isEmpty()) { // agentPath = "/" + path; // } // // return String.format("%s:%d%s", host, port, agentPath); // } // } // Path: src/main/java/com/ecwid/consul/v1/kv/model/PutParams.java import com.ecwid.consul.UrlParameters; import com.ecwid.consul.Utils; import java.math.BigInteger; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Objects; this.cas = cas; } public String getAcquireSession() { return acquireSession; } public void setAcquireSession(String acquireSession) { this.acquireSession = acquireSession; } public String getReleaseSession() { return releaseSession; } public void setReleaseSession(String releaseSession) { this.releaseSession = releaseSession; } @Override public List<String> toUrlParameters() { List<String> params = new ArrayList<String>(); if (flags != 0) { params.add("flags=" + flags); } if (cas != null) { params.add("cas=" + cas); } if (acquireSession != null) {
params.add("acquire=" + Utils.encodeValue(acquireSession));
Ecwid/consul-api
src/main/java/com/ecwid/consul/transport/DefaultHttpsTransport.java
// Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // }
import java.io.FileInputStream; import java.io.IOException; import java.security.*; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import com.ecwid.consul.transport.TLSConfig.KeyStoreInstanceType; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContexts;
package com.ecwid.consul.transport; /** * Default HTTPS client This class is thread safe * * @author Carlos Augusto Ribeiro Mantovani (gutomantovani@gmail.com) */ public final class DefaultHttpsTransport extends AbstractHttpTransport { private final HttpClient httpClient; public DefaultHttpsTransport(TLSConfig tlsConfig) { try { KeyStore clientStore = KeyStore.getInstance(tlsConfig.getKeyStoreInstanceType().name()); clientStore.load(new FileInputStream(tlsConfig.getCertificatePath()), tlsConfig.getCertificatePassword().toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(clientStore, tlsConfig.getCertificatePassword().toCharArray()); KeyManager[] kms = kmf.getKeyManagers();
// Path: src/main/java/com/ecwid/consul/transport/TLSConfig.java // public enum KeyStoreInstanceType { // JKS, JCEKS, PKCS12, PKCS11, DKS // } // Path: src/main/java/com/ecwid/consul/transport/DefaultHttpsTransport.java import java.io.FileInputStream; import java.io.IOException; import java.security.*; import javax.net.ssl.KeyManager; import javax.net.ssl.KeyManagerFactory; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManagerFactory; import org.apache.http.client.HttpClient; import org.apache.http.client.config.RequestConfig; import org.apache.http.config.Registry; import org.apache.http.config.RegistryBuilder; import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import com.ecwid.consul.transport.TLSConfig.KeyStoreInstanceType; import org.apache.http.conn.ssl.TrustSelfSignedStrategy; import org.apache.http.impl.client.HttpClientBuilder; import org.apache.http.impl.conn.PoolingHttpClientConnectionManager; import org.apache.http.ssl.SSLContexts; package com.ecwid.consul.transport; /** * Default HTTPS client This class is thread safe * * @author Carlos Augusto Ribeiro Mantovani (gutomantovani@gmail.com) */ public final class DefaultHttpsTransport extends AbstractHttpTransport { private final HttpClient httpClient; public DefaultHttpsTransport(TLSConfig tlsConfig) { try { KeyStore clientStore = KeyStore.getInstance(tlsConfig.getKeyStoreInstanceType().name()); clientStore.load(new FileInputStream(tlsConfig.getCertificatePath()), tlsConfig.getCertificatePassword().toCharArray()); KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm()); kmf.init(clientStore, tlsConfig.getCertificatePassword().toCharArray()); KeyManager[] kms = kmf.getKeyManagers();
KeyStore trustStore = KeyStore.getInstance(KeyStoreInstanceType.JKS.name());
Ecwid/consul-api
src/main/java/com/ecwid/consul/v1/Request.java
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpRequest.java // public final class HttpRequest { // // private final String url; // private final Map<String, String> headers; // // private final String content; // private final byte[] binaryContent; // // private HttpRequest(String url, Map<String, String> headers, String content, byte[] binaryContent) { // if (content != null && binaryContent != null) { // throw new IllegalArgumentException("You should set only content or binaryContent, not both."); // } // // this.url = url; // this.headers = headers; // this.content = content; // this.binaryContent = binaryContent; // } // // public String getUrl() { // return url; // } // // public Map<String, String> getHeaders() { // return headers; // } // // public String getContent() { // return content; // } // // public byte[] getBinaryContent() { // return binaryContent; // } // // // --------------------------------------- // // Builder // public static final class Builder { // private String url; // private Map<String, String> headers = new HashMap<>(); // private String content; // private byte[] binaryContent; // // public static Builder newBuilder() { // return new Builder(); // } // // public Builder setUrl(String url) { // this.url = url; // return this; // } // // public Builder addHeaders(Map<String, String> headers) { // this.headers.putAll(headers); // return this; // } // // public Builder addHeader(String name, String value) { // this.headers.put(name, value); // return this; // } // // public Builder setContent(String content) { // this.content = content; // return this; // } // // public Builder setBinaryContent(byte[] binaryContent) { // this.binaryContent = binaryContent; // return this; // } // // public HttpRequest build() { // return new HttpRequest(url, headers, content, binaryContent); // } // } // // }
import com.ecwid.consul.UrlParameters; import com.ecwid.consul.transport.HttpRequest; import java.util.ArrayList; import java.util.List;
package com.ecwid.consul.v1; public final class Request { private final String endpoint;
// Path: src/main/java/com/ecwid/consul/UrlParameters.java // public interface UrlParameters { // // public List<String> toUrlParameters(); // // } // // Path: src/main/java/com/ecwid/consul/transport/HttpRequest.java // public final class HttpRequest { // // private final String url; // private final Map<String, String> headers; // // private final String content; // private final byte[] binaryContent; // // private HttpRequest(String url, Map<String, String> headers, String content, byte[] binaryContent) { // if (content != null && binaryContent != null) { // throw new IllegalArgumentException("You should set only content or binaryContent, not both."); // } // // this.url = url; // this.headers = headers; // this.content = content; // this.binaryContent = binaryContent; // } // // public String getUrl() { // return url; // } // // public Map<String, String> getHeaders() { // return headers; // } // // public String getContent() { // return content; // } // // public byte[] getBinaryContent() { // return binaryContent; // } // // // --------------------------------------- // // Builder // public static final class Builder { // private String url; // private Map<String, String> headers = new HashMap<>(); // private String content; // private byte[] binaryContent; // // public static Builder newBuilder() { // return new Builder(); // } // // public Builder setUrl(String url) { // this.url = url; // return this; // } // // public Builder addHeaders(Map<String, String> headers) { // this.headers.putAll(headers); // return this; // } // // public Builder addHeader(String name, String value) { // this.headers.put(name, value); // return this; // } // // public Builder setContent(String content) { // this.content = content; // return this; // } // // public Builder setBinaryContent(byte[] binaryContent) { // this.binaryContent = binaryContent; // return this; // } // // public HttpRequest build() { // return new HttpRequest(url, headers, content, binaryContent); // } // } // // } // Path: src/main/java/com/ecwid/consul/v1/Request.java import com.ecwid.consul.UrlParameters; import com.ecwid.consul.transport.HttpRequest; import java.util.ArrayList; import java.util.List; package com.ecwid.consul.v1; public final class Request { private final String endpoint;
private final List<UrlParameters> urlParameters;
pgentile/zucchini-ui
zucchini-ui-backend/src/main/java/io/zucchiniui/backend/scenario/views/ScenarioViewAccess.java
// Path: zucchini-ui-backend/src/main/java/io/zucchiniui/backend/scenario/domain/ScenarioQuery.java // public interface ScenarioQuery { // // ScenarioQuery withFeatureId(String featureId); // // ScenarioQuery withScenarioKey(String scenarioKey); // // ScenarioQuery withTestRunId(String testRunId); // // ScenarioQuery withSearch(String search); // // ScenarioQuery withName(String name); // // ScenarioQuery orderedByName(); // // ScenarioQuery withSelectedTags(TagSelection tagSelection); // // ScenarioQuery havingErrorMessage(); // }
import io.zucchiniui.backend.scenario.dao.ScenarioDAO; import io.zucchiniui.backend.scenario.domain.Scenario; import io.zucchiniui.backend.scenario.domain.ScenarioQuery; import io.zucchiniui.backend.scenario.domain.ScenarioStatus; import io.zucchiniui.backend.scenario.domain.Step; import io.zucchiniui.backend.shared.domain.TagSelection; import io.zucchiniui.backend.support.ddd.morphia.MorphiaRawQuery; import io.zucchiniui.backend.support.ddd.morphia.MorphiaUtils; import io.zucchiniui.backend.testrun.domain.TestRunQuery; import io.zucchiniui.backend.testrun.domain.TestRunRepository; import xyz.morphia.query.Query; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream;
package io.zucchiniui.backend.scenario.views; @Component public class ScenarioViewAccess { private final ScenarioDAO scenarioDAO; private final TestRunRepository testRunRepository; private final ScenarioToListItemViewMapper scenarioToListItemViewMapper; private final FailedScenarioToListItemViewMapper failedScenarioToListItemViewMapper; private final ScenarioToHistoryItemViewMapper scenarioToHistoryItemViewMapper; public ScenarioViewAccess( final ScenarioDAO scenarioDAO, final TestRunRepository testRunRepository, final ScenarioToListItemViewMapper scenarioToListItemViewMapper, FailedScenarioToListItemViewMapper failedScenarioToListItemViewMapper, ScenarioToHistoryItemViewMapper scenarioToHistoryItemViewMapper) { this.scenarioDAO = scenarioDAO; this.testRunRepository = testRunRepository; this.scenarioToListItemViewMapper = scenarioToListItemViewMapper; this.failedScenarioToListItemViewMapper = failedScenarioToListItemViewMapper; this.scenarioToHistoryItemViewMapper = scenarioToHistoryItemViewMapper; }
// Path: zucchini-ui-backend/src/main/java/io/zucchiniui/backend/scenario/domain/ScenarioQuery.java // public interface ScenarioQuery { // // ScenarioQuery withFeatureId(String featureId); // // ScenarioQuery withScenarioKey(String scenarioKey); // // ScenarioQuery withTestRunId(String testRunId); // // ScenarioQuery withSearch(String search); // // ScenarioQuery withName(String name); // // ScenarioQuery orderedByName(); // // ScenarioQuery withSelectedTags(TagSelection tagSelection); // // ScenarioQuery havingErrorMessage(); // } // Path: zucchini-ui-backend/src/main/java/io/zucchiniui/backend/scenario/views/ScenarioViewAccess.java import io.zucchiniui.backend.scenario.dao.ScenarioDAO; import io.zucchiniui.backend.scenario.domain.Scenario; import io.zucchiniui.backend.scenario.domain.ScenarioQuery; import io.zucchiniui.backend.scenario.domain.ScenarioStatus; import io.zucchiniui.backend.scenario.domain.Step; import io.zucchiniui.backend.shared.domain.TagSelection; import io.zucchiniui.backend.support.ddd.morphia.MorphiaRawQuery; import io.zucchiniui.backend.support.ddd.morphia.MorphiaUtils; import io.zucchiniui.backend.testrun.domain.TestRunQuery; import io.zucchiniui.backend.testrun.domain.TestRunRepository; import xyz.morphia.query.Query; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; import java.util.function.Consumer; import java.util.function.Predicate; import java.util.stream.Collectors; import java.util.stream.Stream; package io.zucchiniui.backend.scenario.views; @Component public class ScenarioViewAccess { private final ScenarioDAO scenarioDAO; private final TestRunRepository testRunRepository; private final ScenarioToListItemViewMapper scenarioToListItemViewMapper; private final FailedScenarioToListItemViewMapper failedScenarioToListItemViewMapper; private final ScenarioToHistoryItemViewMapper scenarioToHistoryItemViewMapper; public ScenarioViewAccess( final ScenarioDAO scenarioDAO, final TestRunRepository testRunRepository, final ScenarioToListItemViewMapper scenarioToListItemViewMapper, FailedScenarioToListItemViewMapper failedScenarioToListItemViewMapper, ScenarioToHistoryItemViewMapper scenarioToHistoryItemViewMapper) { this.scenarioDAO = scenarioDAO; this.testRunRepository = testRunRepository; this.scenarioToListItemViewMapper = scenarioToListItemViewMapper; this.failedScenarioToListItemViewMapper = failedScenarioToListItemViewMapper; this.scenarioToHistoryItemViewMapper = scenarioToHistoryItemViewMapper; }
public List<ScenarioListItemView> getScenarioListItems(final Consumer<ScenarioQuery> preparator) {
pgentile/zucchini-ui
zucchini-ui-backend/src/main/java/io/zucchiniui/backend/testrun/rest/TestRunResource.java
// Path: zucchini-ui-backend/src/main/java/io/zucchiniui/backend/testrun/views/TestRunViewAccess.java // @Component // public class TestRunViewAccess { // // private final TestRunRepository testRunRepository; // // private final TestRunDAO testRunDAO; // // private final ScenarioViewAccess scenarioViewAccess; // // private final TestRunToListItemMapper testRunToListItemMapper; // // public TestRunViewAccess( // final TestRunRepository testRunRepository, // final TestRunDAO testRunDAO, // final ScenarioViewAccess scenarioViewAccess, // TestRunToListItemMapper testRunToListItemMapper // ) { // this.testRunRepository = testRunRepository; // this.testRunDAO = testRunDAO; // this.scenarioViewAccess = scenarioViewAccess; // this.testRunToListItemMapper = testRunToListItemMapper; // } // // public List<TestRunListItem> getTestRunListItems(final Consumer<TestRunQuery> preparator, final boolean withStats) { // return MorphiaUtils.streamQuery(testRunDAO.prepareTypedQuery(preparator)) // .map(testRun -> { // final TestRunListItem item = testRunToListItemMapper.map(testRun); // if (withStats) { // final ScenarioStats stats = scenarioViewAccess.getStats(q -> q.withTestRunId(item.getId())); // item.setStats(stats); // } // return item; // }) // .collect(Collectors.toList()); // } // // public TestRunScenarioDiff getScenarioDiff(final String leftTestRunId, final String rightTestRunId) { // final TestRun leftTestRun = testRunRepository.getById(leftTestRunId); // final TestRun rightTestRun = testRunRepository.getById(rightTestRunId); // // final Map<String, ScenarioListItemView> leftScenarii = scenarioViewAccess.getScenarioListItemsGroupedByScenarioKey(q -> q.withTestRunId(leftTestRunId)); // final Map<String, ScenarioListItemView> rightScenarii = scenarioViewAccess.getScenarioListItemsGroupedByScenarioKey(q -> q.withTestRunId(rightTestRunId)); // // final Set<String> newScenarioFeatureKeys = Sets.difference(rightScenarii.keySet(), leftScenarii.keySet()); // final List<ScenarioListItemView> newScenarii = newScenarioFeatureKeys.stream() // .map(rightScenarii::get) // .sorted(Comparator.comparing(item -> item.getInfo().getName())) // .collect(Collectors.toList()); // // final Set<String> deletedScenarioFeatureKeys = Sets.difference(leftScenarii.keySet(), rightScenarii.keySet()); // final List<ScenarioListItemView> deletedScenarii = deletedScenarioFeatureKeys.stream() // .map(leftScenarii::get) // .sorted(Comparator.comparing(item -> item.getInfo().getName())) // .collect(Collectors.toList()); // // final Set<String> commonFeatureKeys = Sets.intersection(leftScenarii.keySet(), rightScenarii.keySet()); // // final List<TestRunScenarioDiff.ScenarioDiff> scenarioDiffs = commonFeatureKeys.stream() // .map(scenarioKey -> { // final ScenarioListItemView leftScenario = leftScenarii.get(scenarioKey); // final ScenarioListItemView rightScenario = rightScenarii.get(scenarioKey); // // if (leftScenario.getStatus() != rightScenario.getStatus()) { // return new TestRunScenarioDiff.ScenarioDiff(leftScenario, rightScenario); // } // // return null; // }) // .filter(Objects::nonNull) // .sorted(Comparator.comparing(d -> d.getLeft().getInfo().getName())) // .collect(Collectors.toList()); // // final TestRunScenarioDiff diff = new TestRunScenarioDiff(); // diff.setLeftTestRun(leftTestRun); // diff.setRightTestRun(rightTestRun); // diff.setNewScenarii(newScenarii); // diff.setDeletedScenarii(deletedScenarii); // diff.setDifferentScenarii(scenarioDiffs); // return diff; // } // // }
import com.google.common.base.Strings; import io.dropwizard.jersey.PATCH; import io.zucchiniui.backend.reportconverter.domain.ReportConverterService; import io.zucchiniui.backend.testrun.domain.Label; import io.zucchiniui.backend.testrun.domain.TestRun; import io.zucchiniui.backend.testrun.domain.TestRunQuery; import io.zucchiniui.backend.testrun.domain.TestRunRepository; import io.zucchiniui.backend.testrun.domain.TestRunService; import io.zucchiniui.backend.testrun.views.TestRunListItem; import io.zucchiniui.backend.testrun.views.TestRunScenarioDiff; import io.zucchiniui.backend.testrun.views.TestRunViewAccess; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import java.io.InputStream; import java.net.URI; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import java.util.stream.Collectors;
package io.zucchiniui.backend.testrun.rest; @Component @Path("/testRuns") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public class TestRunResource { private static final Logger LOGGER = LoggerFactory.getLogger(TestRunResource.class); private final TestRunRepository testRunRepository; private final TestRunService testRunService;
// Path: zucchini-ui-backend/src/main/java/io/zucchiniui/backend/testrun/views/TestRunViewAccess.java // @Component // public class TestRunViewAccess { // // private final TestRunRepository testRunRepository; // // private final TestRunDAO testRunDAO; // // private final ScenarioViewAccess scenarioViewAccess; // // private final TestRunToListItemMapper testRunToListItemMapper; // // public TestRunViewAccess( // final TestRunRepository testRunRepository, // final TestRunDAO testRunDAO, // final ScenarioViewAccess scenarioViewAccess, // TestRunToListItemMapper testRunToListItemMapper // ) { // this.testRunRepository = testRunRepository; // this.testRunDAO = testRunDAO; // this.scenarioViewAccess = scenarioViewAccess; // this.testRunToListItemMapper = testRunToListItemMapper; // } // // public List<TestRunListItem> getTestRunListItems(final Consumer<TestRunQuery> preparator, final boolean withStats) { // return MorphiaUtils.streamQuery(testRunDAO.prepareTypedQuery(preparator)) // .map(testRun -> { // final TestRunListItem item = testRunToListItemMapper.map(testRun); // if (withStats) { // final ScenarioStats stats = scenarioViewAccess.getStats(q -> q.withTestRunId(item.getId())); // item.setStats(stats); // } // return item; // }) // .collect(Collectors.toList()); // } // // public TestRunScenarioDiff getScenarioDiff(final String leftTestRunId, final String rightTestRunId) { // final TestRun leftTestRun = testRunRepository.getById(leftTestRunId); // final TestRun rightTestRun = testRunRepository.getById(rightTestRunId); // // final Map<String, ScenarioListItemView> leftScenarii = scenarioViewAccess.getScenarioListItemsGroupedByScenarioKey(q -> q.withTestRunId(leftTestRunId)); // final Map<String, ScenarioListItemView> rightScenarii = scenarioViewAccess.getScenarioListItemsGroupedByScenarioKey(q -> q.withTestRunId(rightTestRunId)); // // final Set<String> newScenarioFeatureKeys = Sets.difference(rightScenarii.keySet(), leftScenarii.keySet()); // final List<ScenarioListItemView> newScenarii = newScenarioFeatureKeys.stream() // .map(rightScenarii::get) // .sorted(Comparator.comparing(item -> item.getInfo().getName())) // .collect(Collectors.toList()); // // final Set<String> deletedScenarioFeatureKeys = Sets.difference(leftScenarii.keySet(), rightScenarii.keySet()); // final List<ScenarioListItemView> deletedScenarii = deletedScenarioFeatureKeys.stream() // .map(leftScenarii::get) // .sorted(Comparator.comparing(item -> item.getInfo().getName())) // .collect(Collectors.toList()); // // final Set<String> commonFeatureKeys = Sets.intersection(leftScenarii.keySet(), rightScenarii.keySet()); // // final List<TestRunScenarioDiff.ScenarioDiff> scenarioDiffs = commonFeatureKeys.stream() // .map(scenarioKey -> { // final ScenarioListItemView leftScenario = leftScenarii.get(scenarioKey); // final ScenarioListItemView rightScenario = rightScenarii.get(scenarioKey); // // if (leftScenario.getStatus() != rightScenario.getStatus()) { // return new TestRunScenarioDiff.ScenarioDiff(leftScenario, rightScenario); // } // // return null; // }) // .filter(Objects::nonNull) // .sorted(Comparator.comparing(d -> d.getLeft().getInfo().getName())) // .collect(Collectors.toList()); // // final TestRunScenarioDiff diff = new TestRunScenarioDiff(); // diff.setLeftTestRun(leftTestRun); // diff.setRightTestRun(rightTestRun); // diff.setNewScenarii(newScenarii); // diff.setDeletedScenarii(deletedScenarii); // diff.setDifferentScenarii(scenarioDiffs); // return diff; // } // // } // Path: zucchini-ui-backend/src/main/java/io/zucchiniui/backend/testrun/rest/TestRunResource.java import com.google.common.base.Strings; import io.dropwizard.jersey.PATCH; import io.zucchiniui.backend.reportconverter.domain.ReportConverterService; import io.zucchiniui.backend.testrun.domain.Label; import io.zucchiniui.backend.testrun.domain.TestRun; import io.zucchiniui.backend.testrun.domain.TestRunQuery; import io.zucchiniui.backend.testrun.domain.TestRunRepository; import io.zucchiniui.backend.testrun.domain.TestRunService; import io.zucchiniui.backend.testrun.views.TestRunListItem; import io.zucchiniui.backend.testrun.views.TestRunScenarioDiff; import io.zucchiniui.backend.testrun.views.TestRunViewAccess; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import javax.validation.Valid; import javax.validation.constraints.NotNull; import javax.ws.rs.*; import javax.ws.rs.core.Context; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriInfo; import java.io.InputStream; import java.net.URI; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.Consumer; import java.util.stream.Collectors; package io.zucchiniui.backend.testrun.rest; @Component @Path("/testRuns") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) public class TestRunResource { private static final Logger LOGGER = LoggerFactory.getLogger(TestRunResource.class); private final TestRunRepository testRunRepository; private final TestRunService testRunService;
private final TestRunViewAccess testRunViewAccess;
hamadmarri/Biscuit
main/java/com/biscuit/commands/project/AddProject.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; import com.biscuit.models.Dashboard; import jline.console.ConsoleReader;
package com.biscuit.commands.project; public class AddProject implements Command { Dashboard dashboard = Dashboard.getInstance();
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // Path: main/java/com/biscuit/commands/project/AddProject.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; import com.biscuit.models.Dashboard; import jline.console.ConsoleReader; package com.biscuit.commands.project; public class AddProject implements Command { Dashboard dashboard = Dashboard.getInstance();
Project project = new Project();
hamadmarri/Biscuit
main/java/com/biscuit/commands/project/AddProject.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; import com.biscuit.models.Dashboard; import jline.console.ConsoleReader;
package com.biscuit.commands.project; public class AddProject implements Command { Dashboard dashboard = Dashboard.getInstance(); Project project = new Project(); ConsoleReader reader = null; public AddProject(ConsoleReader reader) { super(); this.reader = reader; } public boolean execute() throws IOException { StringBuilder description = new StringBuilder(); String line; String prompt = reader.getPrompt(); project.backlog.project = project;
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // Path: main/java/com/biscuit/commands/project/AddProject.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; import com.biscuit.models.Dashboard; import jline.console.ConsoleReader; package com.biscuit.commands.project; public class AddProject implements Command { Dashboard dashboard = Dashboard.getInstance(); Project project = new Project(); ConsoleReader reader = null; public AddProject(ConsoleReader reader) { super(); this.reader = reader; } public boolean execute() throws IOException { StringBuilder description = new StringBuilder(); String line; String prompt = reader.getPrompt(); project.backlog.project = project;
reader.setPrompt(ColorCodes.BLUE + "project name: " + ColorCodes.RESET);
hamadmarri/Biscuit
main/java/com/biscuit/factories/ReleasesCompleterFactory.java
// Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/services/Finder.java // public static class Releases { // // public static List<String> getAllNames(Project p) { // return p.releases.stream().map(r -> r.name).collect(Collectors.toList()); // } // // // public static Release find(Project p, String name) { // return p.releases.stream().filter(r -> r.name.equals(name)).findAny().orElse(null); // } // // // public static Release findContains(Project p, String sprintName) { // for (Release r : p.releases) { // for (Sprint s : r.sprints) { // if (s.name.equals(sprintName)) { // return r; // } // } // } // // return null; // } // }
import java.util.ArrayList; import java.util.List; import com.biscuit.models.Project; import com.biscuit.models.services.Finder.Releases; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter;
package com.biscuit.factories; public class ReleasesCompleterFactory { public static List<Completer> getReleasesCompleters(Project project) { List<Completer> completers = new ArrayList<Completer>(); // TODO: releases commands // completers.add(new ArgumentCompleter(new StringsCompleter("summary", // "back"), new NullCompleter())); // completers.add( // new ArgumentCompleter(new StringsCompleter("list"), new // StringsCompleter("past"), new StringsCompleter("filter", "sort"), new // NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("future"), new StringsCompleter("filter", // "sort"), // new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("current"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("all"), new StringsCompleter("filter"), new // NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("all"), new StringsCompleter("sort"), // new StringsCompleter(Release.fields), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("back", "releases"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("add"), new StringsCompleter("release"), new NullCompleter()));
// Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/services/Finder.java // public static class Releases { // // public static List<String> getAllNames(Project p) { // return p.releases.stream().map(r -> r.name).collect(Collectors.toList()); // } // // // public static Release find(Project p, String name) { // return p.releases.stream().filter(r -> r.name.equals(name)).findAny().orElse(null); // } // // // public static Release findContains(Project p, String sprintName) { // for (Release r : p.releases) { // for (Sprint s : r.sprints) { // if (s.name.equals(sprintName)) { // return r; // } // } // } // // return null; // } // } // Path: main/java/com/biscuit/factories/ReleasesCompleterFactory.java import java.util.ArrayList; import java.util.List; import com.biscuit.models.Project; import com.biscuit.models.services.Finder.Releases; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter; package com.biscuit.factories; public class ReleasesCompleterFactory { public static List<Completer> getReleasesCompleters(Project project) { List<Completer> completers = new ArrayList<Completer>(); // TODO: releases commands // completers.add(new ArgumentCompleter(new StringsCompleter("summary", // "back"), new NullCompleter())); // completers.add( // new ArgumentCompleter(new StringsCompleter("list"), new // StringsCompleter("past"), new StringsCompleter("filter", "sort"), new // NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("future"), new StringsCompleter("filter", // "sort"), // new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("current"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("all"), new StringsCompleter("filter"), new // NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("all"), new StringsCompleter("sort"), // new StringsCompleter(Release.fields), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("back", "releases"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("add"), new StringsCompleter("release"), new NullCompleter()));
completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), new StringsCompleter(Releases.getAllNames(project)), new NullCompleter()));
hamadmarri/Biscuit
main/java/com/biscuit/commands/task/ListTasks.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService; import de.vandermeer.asciitable.v2.RenderedTable; import de.vandermeer.asciitable.v2.V2_AsciiTable; import de.vandermeer.asciitable.v2.render.V2_AsciiTableRenderer; import de.vandermeer.asciitable.v2.render.WidthLongestLine; import de.vandermeer.asciitable.v2.themes.V2_E_TableThemes;
package com.biscuit.commands.task; public class ListTasks implements Command { UserStory userStory = null; String title = ""; boolean isFilter = false; boolean isSort = false; static boolean isReverse = false; private String filterBy; private String sortBy; private static String lastSortBy = ""; public ListTasks(UserStory userStory, String title) { super(); this.userStory = userStory; this.title = title; } public ListTasks(UserStory userStory, String title, boolean isFilter, String filterBy, boolean isSort, String sortBy) { super(); this.userStory = userStory; this.title = title; this.isFilter = isFilter; this.filterBy = filterBy.toLowerCase(); this.isSort = isSort; this.sortBy = sortBy.toLowerCase(); } @Override public boolean execute() throws IOException { V2_AsciiTable at = new V2_AsciiTable(); String tableString;
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/task/ListTasks.java import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService; import de.vandermeer.asciitable.v2.RenderedTable; import de.vandermeer.asciitable.v2.V2_AsciiTable; import de.vandermeer.asciitable.v2.render.V2_AsciiTableRenderer; import de.vandermeer.asciitable.v2.render.WidthLongestLine; import de.vandermeer.asciitable.v2.themes.V2_E_TableThemes; package com.biscuit.commands.task; public class ListTasks implements Command { UserStory userStory = null; String title = ""; boolean isFilter = false; boolean isSort = false; static boolean isReverse = false; private String filterBy; private String sortBy; private static String lastSortBy = ""; public ListTasks(UserStory userStory, String title) { super(); this.userStory = userStory; this.title = title; } public ListTasks(UserStory userStory, String title, boolean isFilter, String filterBy, boolean isSort, String sortBy) { super(); this.userStory = userStory; this.title = title; this.isFilter = isFilter; this.filterBy = filterBy.toLowerCase(); this.isSort = isSort; this.sortBy = sortBy.toLowerCase(); } @Override public boolean execute() throws IOException { V2_AsciiTable at = new V2_AsciiTable(); String tableString;
List<Task> tasks = new ArrayList<>();
hamadmarri/Biscuit
main/java/com/biscuit/commands/task/ListTasks.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService; import de.vandermeer.asciitable.v2.RenderedTable; import de.vandermeer.asciitable.v2.V2_AsciiTable; import de.vandermeer.asciitable.v2.render.V2_AsciiTableRenderer; import de.vandermeer.asciitable.v2.render.WidthLongestLine; import de.vandermeer.asciitable.v2.themes.V2_E_TableThemes;
if (isFilter) { doFilter(tasks); } if (isSort) { doSort(tasks); } at.addRule(); if (!this.title.isEmpty()) { at.addRow(null, null, null, null, null, null, this.title).setAlignment(new char[] { 'c', 'c', 'c', 'c', 'c', 'c', 'c' }); at.addRule(); } at.addRow("Title", "Description", "State", "Initiated Date", "Planned Date", "Due Date", "Estimated Time") .setAlignment(new char[] { 'l', 'l', 'c', 'c', 'c', 'c', 'c' }); if (tasks.size() == 0) { String message; if (!isFilter) { message = "There are no tasks!"; } else { message = "No results"; } at.addRule(); at.addRow(null, null, null, null, null, null, message); } else { for (Task t : tasks) { at.addRule();
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/task/ListTasks.java import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService; import de.vandermeer.asciitable.v2.RenderedTable; import de.vandermeer.asciitable.v2.V2_AsciiTable; import de.vandermeer.asciitable.v2.render.V2_AsciiTableRenderer; import de.vandermeer.asciitable.v2.render.WidthLongestLine; import de.vandermeer.asciitable.v2.themes.V2_E_TableThemes; if (isFilter) { doFilter(tasks); } if (isSort) { doSort(tasks); } at.addRule(); if (!this.title.isEmpty()) { at.addRow(null, null, null, null, null, null, this.title).setAlignment(new char[] { 'c', 'c', 'c', 'c', 'c', 'c', 'c' }); at.addRule(); } at.addRow("Title", "Description", "State", "Initiated Date", "Planned Date", "Due Date", "Estimated Time") .setAlignment(new char[] { 'l', 'l', 'c', 'c', 'c', 'c', 'c' }); if (tasks.size() == 0) { String message; if (!isFilter) { message = "There are no tasks!"; } else { message = "No results"; } at.addRule(); at.addRow(null, null, null, null, null, null, message); } else { for (Task t : tasks) { at.addRule();
at.addRow(t.title, t.description, t.state, DateService.getDateAsString(t.initiatedDate), DateService.getDateAsString(t.plannedDate),
hamadmarri/Biscuit
main/java/com/biscuit/commands/task/ListTasks.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService; import de.vandermeer.asciitable.v2.RenderedTable; import de.vandermeer.asciitable.v2.V2_AsciiTable; import de.vandermeer.asciitable.v2.render.V2_AsciiTableRenderer; import de.vandermeer.asciitable.v2.render.WidthLongestLine; import de.vandermeer.asciitable.v2.themes.V2_E_TableThemes;
if (sortBy.equals(lastSortBy)) { isReverse = !isReverse; if (isReverse) { Collections.reverse(sorted); } } else { lastSortBy = sortBy; isReverse = false; } tasks.clear(); tasks.addAll(sorted); } private void doFilter(List<Task> tasks) { List<Task> filtered = tasks.stream() .filter(us -> us.title.toLowerCase().contains(filterBy) || us.description.toLowerCase().contains(filterBy) || us.state.toString().toLowerCase().contains(filterBy) || String.valueOf(us.estimatedTime).contains(filterBy) || DateService.getDateAsString(us.initiatedDate).toLowerCase().contains(filterBy) || DateService.getDateAsString(us.plannedDate).toLowerCase().contains(filterBy) || DateService.getDateAsString(us.dueDate).toLowerCase().contains(filterBy)) .collect(Collectors.toList()); tasks.clear(); tasks.addAll(filtered); } private String colorize(String tableString) {
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/task/ListTasks.java import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService; import de.vandermeer.asciitable.v2.RenderedTable; import de.vandermeer.asciitable.v2.V2_AsciiTable; import de.vandermeer.asciitable.v2.render.V2_AsciiTableRenderer; import de.vandermeer.asciitable.v2.render.WidthLongestLine; import de.vandermeer.asciitable.v2.themes.V2_E_TableThemes; if (sortBy.equals(lastSortBy)) { isReverse = !isReverse; if (isReverse) { Collections.reverse(sorted); } } else { lastSortBy = sortBy; isReverse = false; } tasks.clear(); tasks.addAll(sorted); } private void doFilter(List<Task> tasks) { List<Task> filtered = tasks.stream() .filter(us -> us.title.toLowerCase().contains(filterBy) || us.description.toLowerCase().contains(filterBy) || us.state.toString().toLowerCase().contains(filterBy) || String.valueOf(us.estimatedTime).contains(filterBy) || DateService.getDateAsString(us.initiatedDate).toLowerCase().contains(filterBy) || DateService.getDateAsString(us.plannedDate).toLowerCase().contains(filterBy) || DateService.getDateAsString(us.dueDate).toLowerCase().contains(filterBy)) .collect(Collectors.toList()); tasks.clear(); tasks.addAll(filtered); } private String colorize(String tableString) {
tableString = tableString.replaceFirst("Title", ColorCodes.BLUE + "Title" + ColorCodes.RESET);
hamadmarri/Biscuit
main/java/com/biscuit/commands/project/RemoveProject.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; import com.biscuit.models.Dashboard; import jline.console.ConsoleReader;
package com.biscuit.commands.project; public class RemoveProject implements Command { Dashboard dashboard = Dashboard.getInstance();
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // Path: main/java/com/biscuit/commands/project/RemoveProject.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; import com.biscuit.models.Dashboard; import jline.console.ConsoleReader; package com.biscuit.commands.project; public class RemoveProject implements Command { Dashboard dashboard = Dashboard.getInstance();
Project project;
hamadmarri/Biscuit
main/java/com/biscuit/commands/project/RemoveProject.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; import com.biscuit.models.Dashboard; import jline.console.ConsoleReader;
package com.biscuit.commands.project; public class RemoveProject implements Command { Dashboard dashboard = Dashboard.getInstance(); Project project; ConsoleReader reader = null; public RemoveProject(ConsoleReader reader, Project project) { super(); this.reader = reader; this.project = project; } public boolean execute() throws IOException { String line; boolean yes = false; String prompt = reader.getPrompt();
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // Path: main/java/com/biscuit/commands/project/RemoveProject.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; import com.biscuit.models.Dashboard; import jline.console.ConsoleReader; package com.biscuit.commands.project; public class RemoveProject implements Command { Dashboard dashboard = Dashboard.getInstance(); Project project; ConsoleReader reader = null; public RemoveProject(ConsoleReader reader, Project project) { super(); this.reader = reader; this.project = project; } public boolean execute() throws IOException { String line; boolean yes = false; String prompt = reader.getPrompt();
reader.setPrompt(ColorCodes.BLUE + "Are you sure you want to remove " + project.name + "? [Y/n] " + ColorCodes.RESET);
hamadmarri/Biscuit
main/java/com/biscuit/commands/sprint/ShowSprint.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Sprint.java // public class Sprint { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // public int velocity; // // public List<UserStory> userStories = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort", "velocity" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort", "Velocity" }; // } // // public void addUserStory(UserStory userStory) { // this.userStories.add(userStory); // } // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Sprint; import com.biscuit.models.services.DateService;
package com.biscuit.commands.sprint; public class ShowSprint implements Command { Sprint s = null; public ShowSprint(Sprint s) { super(); this.s = s; } @Override public boolean execute() throws IOException {
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Sprint.java // public class Sprint { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // public int velocity; // // public List<UserStory> userStories = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort", "velocity" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort", "Velocity" }; // } // // public void addUserStory(UserStory userStory) { // this.userStories.add(userStory); // } // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/sprint/ShowSprint.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Sprint; import com.biscuit.models.services.DateService; package com.biscuit.commands.sprint; public class ShowSprint implements Command { Sprint s = null; public ShowSprint(Sprint s) { super(); this.s = s; } @Override public boolean execute() throws IOException {
System.out.println(ColorCodes.BLUE + "name: " + ColorCodes.RESET + s.name);
hamadmarri/Biscuit
main/java/com/biscuit/commands/sprint/ShowSprint.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Sprint.java // public class Sprint { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // public int velocity; // // public List<UserStory> userStories = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort", "velocity" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort", "Velocity" }; // } // // public void addUserStory(UserStory userStory) { // this.userStories.add(userStory); // } // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Sprint; import com.biscuit.models.services.DateService;
package com.biscuit.commands.sprint; public class ShowSprint implements Command { Sprint s = null; public ShowSprint(Sprint s) { super(); this.s = s; } @Override public boolean execute() throws IOException { System.out.println(ColorCodes.BLUE + "name: " + ColorCodes.RESET + s.name); System.out.println(ColorCodes.BLUE + "description: "); System.out.println(ColorCodes.RESET + s.description); System.out.println(ColorCodes.BLUE + "state: " + ColorCodes.RESET + s.state); System.out.println(
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Sprint.java // public class Sprint { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // public int velocity; // // public List<UserStory> userStories = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort", "velocity" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort", "Velocity" }; // } // // public void addUserStory(UserStory userStory) { // this.userStories.add(userStory); // } // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/sprint/ShowSprint.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Sprint; import com.biscuit.models.services.DateService; package com.biscuit.commands.sprint; public class ShowSprint implements Command { Sprint s = null; public ShowSprint(Sprint s) { super(); this.s = s; } @Override public boolean execute() throws IOException { System.out.println(ColorCodes.BLUE + "name: " + ColorCodes.RESET + s.name); System.out.println(ColorCodes.BLUE + "description: "); System.out.println(ColorCodes.RESET + s.description); System.out.println(ColorCodes.BLUE + "state: " + ColorCodes.RESET + s.state); System.out.println(
ColorCodes.BLUE + "Start date: " + ColorCodes.RESET + DateService.getDateAsString(s.startDate));
hamadmarri/Biscuit
main/java/com/biscuit/factories/TaskCompleterFactory.java
// Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.util.ArrayList; import java.util.List; import com.biscuit.models.Task; import com.biscuit.models.enums.Status; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter;
package com.biscuit.factories; public class TaskCompleterFactory { public static List<Completer> getTaskCompleters(Task task) { List<Completer> completers = new ArrayList<Completer>(); // TODO: Task commands // completers.add(new ArgumentCompleter(new StringsCompleter("summary", // "show", "times", "edit", "back"), // new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("show", "edit", "back"), new NullCompleter()));
// Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/factories/TaskCompleterFactory.java import java.util.ArrayList; import java.util.List; import com.biscuit.models.Task; import com.biscuit.models.enums.Status; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter; package com.biscuit.factories; public class TaskCompleterFactory { public static List<Completer> getTaskCompleters(Task task) { List<Completer> completers = new ArrayList<Completer>(); // TODO: Task commands // completers.add(new ArgumentCompleter(new StringsCompleter("summary", // "show", "times", "edit", "back"), // new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("show", "edit", "back"), new NullCompleter()));
completers.add(new ArgumentCompleter(new StringsCompleter("change_status_to"), new StringsCompleter(Status.values), new NullCompleter()));
hamadmarri/Biscuit
main/java/com/biscuit/models/Task.java
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import com.biscuit.models.enums.Status; import java.util.Date; import java.util.List;
/* Author: Hamad Al Marri; */ package com.biscuit.models; public class Task { public transient Project project; public String title; public String description;
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/models/Task.java import com.biscuit.models.enums.Status; import java.util.Date; import java.util.List; /* Author: Hamad Al Marri; */ package com.biscuit.models; public class Task { public transient Project project; public String title; public String description;
public Status state;
hamadmarri/Biscuit
main/java/com/biscuit/commands/project/EditProject.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Dashboard; import com.biscuit.models.Project; import jline.console.ConsoleReader;
package com.biscuit.commands.project; public class EditProject implements Command { ConsoleReader reader = null;
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // Path: main/java/com/biscuit/commands/project/EditProject.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Dashboard; import com.biscuit.models.Project; import jline.console.ConsoleReader; package com.biscuit.commands.project; public class EditProject implements Command { ConsoleReader reader = null;
Project p = new Project();
hamadmarri/Biscuit
main/java/com/biscuit/commands/project/EditProject.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Dashboard; import com.biscuit.models.Project; import jline.console.ConsoleReader;
package com.biscuit.commands.project; public class EditProject implements Command { ConsoleReader reader = null; Project p = new Project(); public EditProject(ConsoleReader reader, Project p) { super(); this.reader = reader; this.p = p; } public boolean execute() throws IOException { String prompt = reader.getPrompt(); String oldName; oldName = p.name; setName(); setDescription(); try {
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // Path: main/java/com/biscuit/commands/project/EditProject.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Dashboard; import com.biscuit.models.Project; import jline.console.ConsoleReader; package com.biscuit.commands.project; public class EditProject implements Command { ConsoleReader reader = null; Project p = new Project(); public EditProject(ConsoleReader reader, Project p) { super(); this.reader = reader; this.p = p; } public boolean execute() throws IOException { String prompt = reader.getPrompt(); String oldName; oldName = p.name; setName(); setDescription(); try {
Dashboard.getInstance().renameProject(oldName, p.name);
hamadmarri/Biscuit
main/java/com/biscuit/commands/project/ShowProject.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project;
package com.biscuit.commands.project; public class ShowProject implements Command { Project p = null; public ShowProject(Project p) { super(); this.p = p; } @Override public boolean execute() throws IOException {
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Project.java // public class Project { // // public String name; // public String description; // public Backlog backlog = new Backlog(); // public List<Release> releases = new ArrayList<>(); // public List<Sprint> sprints = new ArrayList<>(); // // // public void save() { // ModelHelper.save(this, name); // } // // // public void delete() { // ModelHelper.delete(name); // } // // // static public Project load(String name) { // return ModelHelper.loadProject(name); // } // // // public void updateChildrenReferences() { // // this.backlog.project = this; // // for (Release r : releases) { // r.project = this; // updateSprintReferences(r.sprints); // } // // updateSprintReferences(sprints); // updateUserStoryReferences(backlog.userStories); // } // // // private void updateSprintReferences(List<Sprint> sprints) { // for (Sprint s : sprints) { // s.project = this; // updateUserStoryReferences(s.userStories); // } // } // // // private void updateUserStoryReferences(List<UserStory> userStories) { // for (UserStory us : userStories) { // us.project = this; // // for (Task t : us.tasks) { // t.project = this; // } // // // for (Bug b : us.bugs) { // // b.project = this; // // } // // // for (Test t : us.tests) { // // t.project = this; // // } // } // } // // // public void addRelease(Release r) { // releases.add(r); // } // // // public void addSprint(Sprint s) { // sprints.add(s); // } // // // @Override // public String toString() { // return "project name: " + name + "\n\ndescription:-\n" + description; // } // // } // Path: main/java/com/biscuit/commands/project/ShowProject.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Project; package com.biscuit.commands.project; public class ShowProject implements Command { Project p = null; public ShowProject(Project p) { super(); this.p = p; } @Override public boolean execute() throws IOException {
System.out.println(ColorCodes.BLUE + "title: " + ColorCodes.RESET + p.name);
hamadmarri/Biscuit
main/java/com/biscuit/App.java
// Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // // Path: main/java/com/biscuit/views/DashboardView.java // public class DashboardView extends View { // // public DashboardView() { // super(null, "Dashboard"); // } // // // @Override // void addSpecificCompleters(List<Completer> completers) { // completers.addAll(DashboardCompleterFactory.getDashboardCompleters()); // } // // // @Override // boolean executeCommand(String[] words) throws IOException { // // if (words.length == 1) { // return execute1Keyword(words); // } else if (words.length == 2) { // return execute2Keyword(words); // } else if (words.length == 3) { // return execute3Keyword(words); // } // // return false; // } // // // private boolean execute3Keyword(String[] words) throws IOException { // if (words[0].equals("go_to")) { // // "project#1", "users", "contacts", "groups" // // if (words[1].equals("project")) { // // check if project name // Project p = Projects.getProject(words[2]); // if (p != null) { // ProjectView pv = new ProjectView(this, p); // pv.view(); // return true; // } // return false; // } // } else if (words[1].equals("project")) { // if (words[0].equals("edit")) { // Project p = Projects.getProject(words[2]); // if (p != null) { // (new EditProject(reader, p)).execute(); // resetCompleters(); // return true; // } // return false; // } else if (words[0].equals("remove")) { // Project p = Projects.getProject(words[2]); // if (p != null) { // (new RemoveProject(reader, p)).execute(); // resetCompleters(); // return true; // } // return false; // } // } // // return false; // } // // // private boolean execute2Keyword(String[] words) throws IOException { // if (words[0].equals("go_to")) { // // "project#1", "users", "contacts", "groups" // // // check if project name // Project p = Projects.getProject(words[1]); // if (p != null) { // ProjectView pv = new ProjectView(this, p); // pv.view(); // return true; // } // return false; // // } else if (words[0].equals("list")) { // // projects // // "filter", "sort" // } else if (words[1].equals("project")) { // if (words[0].equals("add")) { // (new AddProject(reader)).execute(); // resetCompleters(); // return true; // } // } // // return false; // } // // // private boolean execute1Keyword(String[] words) throws IOException { // if (words[0].equals("summary")) { // } else if (words[0].equals("projects")) { // } else if (words[0].equals("alerts")) { // } else if (words[0].equals("check_alert")) { // } else if (words[0].equals("search")) { // } else if (words[0].equals("help")) { // return (new DashboardHelp().execute()); // } // // return false; // } // // }
import com.biscuit.models.Dashboard; import com.biscuit.views.DashboardView;
/* Author: Hamad Al Marri; */ package com.biscuit; //import java.util.Calendar; //import java.util.GregorianCalendar; public class App { public static void main(String[] args) { initialize(); } private static void initialize() {
// Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // // Path: main/java/com/biscuit/views/DashboardView.java // public class DashboardView extends View { // // public DashboardView() { // super(null, "Dashboard"); // } // // // @Override // void addSpecificCompleters(List<Completer> completers) { // completers.addAll(DashboardCompleterFactory.getDashboardCompleters()); // } // // // @Override // boolean executeCommand(String[] words) throws IOException { // // if (words.length == 1) { // return execute1Keyword(words); // } else if (words.length == 2) { // return execute2Keyword(words); // } else if (words.length == 3) { // return execute3Keyword(words); // } // // return false; // } // // // private boolean execute3Keyword(String[] words) throws IOException { // if (words[0].equals("go_to")) { // // "project#1", "users", "contacts", "groups" // // if (words[1].equals("project")) { // // check if project name // Project p = Projects.getProject(words[2]); // if (p != null) { // ProjectView pv = new ProjectView(this, p); // pv.view(); // return true; // } // return false; // } // } else if (words[1].equals("project")) { // if (words[0].equals("edit")) { // Project p = Projects.getProject(words[2]); // if (p != null) { // (new EditProject(reader, p)).execute(); // resetCompleters(); // return true; // } // return false; // } else if (words[0].equals("remove")) { // Project p = Projects.getProject(words[2]); // if (p != null) { // (new RemoveProject(reader, p)).execute(); // resetCompleters(); // return true; // } // return false; // } // } // // return false; // } // // // private boolean execute2Keyword(String[] words) throws IOException { // if (words[0].equals("go_to")) { // // "project#1", "users", "contacts", "groups" // // // check if project name // Project p = Projects.getProject(words[1]); // if (p != null) { // ProjectView pv = new ProjectView(this, p); // pv.view(); // return true; // } // return false; // // } else if (words[0].equals("list")) { // // projects // // "filter", "sort" // } else if (words[1].equals("project")) { // if (words[0].equals("add")) { // (new AddProject(reader)).execute(); // resetCompleters(); // return true; // } // } // // return false; // } // // // private boolean execute1Keyword(String[] words) throws IOException { // if (words[0].equals("summary")) { // } else if (words[0].equals("projects")) { // } else if (words[0].equals("alerts")) { // } else if (words[0].equals("check_alert")) { // } else if (words[0].equals("search")) { // } else if (words[0].equals("help")) { // return (new DashboardHelp().execute()); // } // // return false; // } // // } // Path: main/java/com/biscuit/App.java import com.biscuit.models.Dashboard; import com.biscuit.views.DashboardView; /* Author: Hamad Al Marri; */ package com.biscuit; //import java.util.Calendar; //import java.util.GregorianCalendar; public class App { public static void main(String[] args) { initialize(); } private static void initialize() {
Dashboard.setInstance(Dashboard.load());
hamadmarri/Biscuit
main/java/com/biscuit/App.java
// Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // // Path: main/java/com/biscuit/views/DashboardView.java // public class DashboardView extends View { // // public DashboardView() { // super(null, "Dashboard"); // } // // // @Override // void addSpecificCompleters(List<Completer> completers) { // completers.addAll(DashboardCompleterFactory.getDashboardCompleters()); // } // // // @Override // boolean executeCommand(String[] words) throws IOException { // // if (words.length == 1) { // return execute1Keyword(words); // } else if (words.length == 2) { // return execute2Keyword(words); // } else if (words.length == 3) { // return execute3Keyword(words); // } // // return false; // } // // // private boolean execute3Keyword(String[] words) throws IOException { // if (words[0].equals("go_to")) { // // "project#1", "users", "contacts", "groups" // // if (words[1].equals("project")) { // // check if project name // Project p = Projects.getProject(words[2]); // if (p != null) { // ProjectView pv = new ProjectView(this, p); // pv.view(); // return true; // } // return false; // } // } else if (words[1].equals("project")) { // if (words[0].equals("edit")) { // Project p = Projects.getProject(words[2]); // if (p != null) { // (new EditProject(reader, p)).execute(); // resetCompleters(); // return true; // } // return false; // } else if (words[0].equals("remove")) { // Project p = Projects.getProject(words[2]); // if (p != null) { // (new RemoveProject(reader, p)).execute(); // resetCompleters(); // return true; // } // return false; // } // } // // return false; // } // // // private boolean execute2Keyword(String[] words) throws IOException { // if (words[0].equals("go_to")) { // // "project#1", "users", "contacts", "groups" // // // check if project name // Project p = Projects.getProject(words[1]); // if (p != null) { // ProjectView pv = new ProjectView(this, p); // pv.view(); // return true; // } // return false; // // } else if (words[0].equals("list")) { // // projects // // "filter", "sort" // } else if (words[1].equals("project")) { // if (words[0].equals("add")) { // (new AddProject(reader)).execute(); // resetCompleters(); // return true; // } // } // // return false; // } // // // private boolean execute1Keyword(String[] words) throws IOException { // if (words[0].equals("summary")) { // } else if (words[0].equals("projects")) { // } else if (words[0].equals("alerts")) { // } else if (words[0].equals("check_alert")) { // } else if (words[0].equals("search")) { // } else if (words[0].equals("help")) { // return (new DashboardHelp().execute()); // } // // return false; // } // // }
import com.biscuit.models.Dashboard; import com.biscuit.views.DashboardView;
/* Author: Hamad Al Marri; */ package com.biscuit; //import java.util.Calendar; //import java.util.GregorianCalendar; public class App { public static void main(String[] args) { initialize(); } private static void initialize() { Dashboard.setInstance(Dashboard.load()); if (Dashboard.getInstance() == null) { Dashboard.setInstance(new Dashboard()); } Dashboard.getInstance().save(); // test();
// Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // // Path: main/java/com/biscuit/views/DashboardView.java // public class DashboardView extends View { // // public DashboardView() { // super(null, "Dashboard"); // } // // // @Override // void addSpecificCompleters(List<Completer> completers) { // completers.addAll(DashboardCompleterFactory.getDashboardCompleters()); // } // // // @Override // boolean executeCommand(String[] words) throws IOException { // // if (words.length == 1) { // return execute1Keyword(words); // } else if (words.length == 2) { // return execute2Keyword(words); // } else if (words.length == 3) { // return execute3Keyword(words); // } // // return false; // } // // // private boolean execute3Keyword(String[] words) throws IOException { // if (words[0].equals("go_to")) { // // "project#1", "users", "contacts", "groups" // // if (words[1].equals("project")) { // // check if project name // Project p = Projects.getProject(words[2]); // if (p != null) { // ProjectView pv = new ProjectView(this, p); // pv.view(); // return true; // } // return false; // } // } else if (words[1].equals("project")) { // if (words[0].equals("edit")) { // Project p = Projects.getProject(words[2]); // if (p != null) { // (new EditProject(reader, p)).execute(); // resetCompleters(); // return true; // } // return false; // } else if (words[0].equals("remove")) { // Project p = Projects.getProject(words[2]); // if (p != null) { // (new RemoveProject(reader, p)).execute(); // resetCompleters(); // return true; // } // return false; // } // } // // return false; // } // // // private boolean execute2Keyword(String[] words) throws IOException { // if (words[0].equals("go_to")) { // // "project#1", "users", "contacts", "groups" // // // check if project name // Project p = Projects.getProject(words[1]); // if (p != null) { // ProjectView pv = new ProjectView(this, p); // pv.view(); // return true; // } // return false; // // } else if (words[0].equals("list")) { // // projects // // "filter", "sort" // } else if (words[1].equals("project")) { // if (words[0].equals("add")) { // (new AddProject(reader)).execute(); // resetCompleters(); // return true; // } // } // // return false; // } // // // private boolean execute1Keyword(String[] words) throws IOException { // if (words[0].equals("summary")) { // } else if (words[0].equals("projects")) { // } else if (words[0].equals("alerts")) { // } else if (words[0].equals("check_alert")) { // } else if (words[0].equals("search")) { // } else if (words[0].equals("help")) { // return (new DashboardHelp().execute()); // } // // return false; // } // // } // Path: main/java/com/biscuit/App.java import com.biscuit.models.Dashboard; import com.biscuit.views.DashboardView; /* Author: Hamad Al Marri; */ package com.biscuit; //import java.util.Calendar; //import java.util.GregorianCalendar; public class App { public static void main(String[] args) { initialize(); } private static void initialize() { Dashboard.setInstance(Dashboard.load()); if (Dashboard.getInstance() == null) { Dashboard.setInstance(new Dashboard()); } Dashboard.getInstance().save(); // test();
DashboardView dbv = new DashboardView();
hamadmarri/Biscuit
main/java/com/biscuit/commands/release/ShowRelease.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Release.java // public class Release { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // // public List<Sprint> sprints = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort" }; // } // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Release; import com.biscuit.models.services.DateService;
package com.biscuit.commands.release; public class ShowRelease implements Command { Release r = null; public ShowRelease(Release r) { super(); this.r = r; } @Override public boolean execute() throws IOException {
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Release.java // public class Release { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // // public List<Sprint> sprints = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort" }; // } // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/release/ShowRelease.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Release; import com.biscuit.models.services.DateService; package com.biscuit.commands.release; public class ShowRelease implements Command { Release r = null; public ShowRelease(Release r) { super(); this.r = r; } @Override public boolean execute() throws IOException {
System.out.println(ColorCodes.BLUE + "name: " + ColorCodes.RESET + r.name);
hamadmarri/Biscuit
main/java/com/biscuit/commands/release/ShowRelease.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Release.java // public class Release { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // // public List<Sprint> sprints = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort" }; // } // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Release; import com.biscuit.models.services.DateService;
package com.biscuit.commands.release; public class ShowRelease implements Command { Release r = null; public ShowRelease(Release r) { super(); this.r = r; } @Override public boolean execute() throws IOException { System.out.println(ColorCodes.BLUE + "name: " + ColorCodes.RESET + r.name); System.out.println(ColorCodes.BLUE + "description: "); System.out.println(ColorCodes.RESET + r.description); System.out.println(ColorCodes.BLUE + "state: " + ColorCodes.RESET + r.state); System.out.println(
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Release.java // public class Release { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // // public List<Sprint> sprints = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort" }; // } // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/release/ShowRelease.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Release; import com.biscuit.models.services.DateService; package com.biscuit.commands.release; public class ShowRelease implements Command { Release r = null; public ShowRelease(Release r) { super(); this.r = r; } @Override public boolean execute() throws IOException { System.out.println(ColorCodes.BLUE + "name: " + ColorCodes.RESET + r.name); System.out.println(ColorCodes.BLUE + "description: "); System.out.println(ColorCodes.RESET + r.description); System.out.println(ColorCodes.BLUE + "state: " + ColorCodes.RESET + r.state); System.out.println(
ColorCodes.BLUE + "Start date: " + ColorCodes.RESET + DateService.getDateAsString(r.startDate));
hamadmarri/Biscuit
main/java/com/biscuit/commands/help/UserStoryHelp.java
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import com.biscuit.models.enums.Status; import de.vandermeer.asciitable.v2.V2_AsciiTable;
package com.biscuit.commands.help; public class UserStoryHelp extends UniversalHelp { @Override public void executeChild(V2_AsciiTable at) { at.addRow(null, "User Story Commands").setAlignment(new char[] { 'c', 'c' }); at.addRule(); at.addRow("show", "Show user story information").setAlignment(new char[] { 'l', 'l' }); at.addRow("edit", "Edit user story").setAlignment(new char[] { 'l', 'l' });
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/help/UserStoryHelp.java import com.biscuit.models.enums.Status; import de.vandermeer.asciitable.v2.V2_AsciiTable; package com.biscuit.commands.help; public class UserStoryHelp extends UniversalHelp { @Override public void executeChild(V2_AsciiTable at) { at.addRow(null, "User Story Commands").setAlignment(new char[] { 'c', 'c' }); at.addRule(); at.addRow("show", "Show user story information").setAlignment(new char[] { 'l', 'l' }); at.addRow("edit", "Edit user story").setAlignment(new char[] { 'l', 'l' });
at.addRow("change_status_to", "Change status of user story (use TAB to autocomplete)\n" + "Status: " + Status.allStatus() + "\n")
hamadmarri/Biscuit
main/java/com/biscuit/commands/release/ChangeStatusRelease.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Release.java // public class Release { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // // public List<Sprint> sprints = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort" }; // } // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Release; import com.biscuit.models.enums.Status;
package com.biscuit.commands.release; public class ChangeStatusRelease implements Command { Release r = null;
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Release.java // public class Release { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // // public List<Sprint> sprints = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort" }; // } // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/release/ChangeStatusRelease.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Release; import com.biscuit.models.enums.Status; package com.biscuit.commands.release; public class ChangeStatusRelease implements Command { Release r = null;
Status state = null;
hamadmarri/Biscuit
main/java/com/biscuit/commands/release/ChangeStatusRelease.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Release.java // public class Release { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // // public List<Sprint> sprints = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort" }; // } // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Release; import com.biscuit.models.enums.Status;
package com.biscuit.commands.release; public class ChangeStatusRelease implements Command { Release r = null; Status state = null; public ChangeStatusRelease(Release r, Status state) { super(); this.r = r; this.state = state; } @Override public boolean execute() throws IOException { Status oldState = r.state; r.state = state; r.save();
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Release.java // public class Release { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // // public List<Sprint> sprints = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort" }; // } // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/release/ChangeStatusRelease.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Release; import com.biscuit.models.enums.Status; package com.biscuit.commands.release; public class ChangeStatusRelease implements Command { Release r = null; Status state = null; public ChangeStatusRelease(Release r, Status state) { super(); this.r = r; this.state = state; } @Override public boolean execute() throws IOException { Status oldState = r.state; r.state = state; r.save();
System.out.println(ColorCodes.GREEN + "State of release " + r.name + " has been changed from " + oldState
hamadmarri/Biscuit
main/java/com/biscuit/commands/help/ReleaseHelp.java
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import com.biscuit.models.enums.Status; import de.vandermeer.asciitable.v2.V2_AsciiTable;
package com.biscuit.commands.help; public class ReleaseHelp extends UniversalHelp { @Override public void executeChild(V2_AsciiTable at) { at.addRow(null, "Release Commands").setAlignment(new char[] { 'c', 'c' }); at.addRule(); at.addRow("show", "Show release information").setAlignment(new char[] { 'l', 'l' }); at.addRow("edit", "Edit release").setAlignment(new char[] { 'l', 'l' });
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/help/ReleaseHelp.java import com.biscuit.models.enums.Status; import de.vandermeer.asciitable.v2.V2_AsciiTable; package com.biscuit.commands.help; public class ReleaseHelp extends UniversalHelp { @Override public void executeChild(V2_AsciiTable at) { at.addRow(null, "Release Commands").setAlignment(new char[] { 'c', 'c' }); at.addRule(); at.addRow("show", "Show release information").setAlignment(new char[] { 'l', 'l' }); at.addRow("edit", "Edit release").setAlignment(new char[] { 'l', 'l' });
at.addRow("change_status_to", "Change status of release (use TAB to autocomplete)\n" + "Status: " + Status.allStatus() + "\n")
hamadmarri/Biscuit
main/java/com/biscuit/commands/help/SprintHelp.java
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import com.biscuit.models.enums.Status; import de.vandermeer.asciitable.v2.V2_AsciiTable;
package com.biscuit.commands.help; public class SprintHelp extends UniversalHelp { @Override public void executeChild(V2_AsciiTable at) { at.addRow(null, "Sprint Commands").setAlignment(new char[] { 'c', 'c' }); at.addRule(); at.addRow("show", "Show sprint information").setAlignment(new char[] { 'l', 'l' }); at.addRow("edit", "Edit sprint").setAlignment(new char[] { 'l', 'l' });
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/help/SprintHelp.java import com.biscuit.models.enums.Status; import de.vandermeer.asciitable.v2.V2_AsciiTable; package com.biscuit.commands.help; public class SprintHelp extends UniversalHelp { @Override public void executeChild(V2_AsciiTable at) { at.addRow(null, "Sprint Commands").setAlignment(new char[] { 'c', 'c' }); at.addRule(); at.addRow("show", "Show sprint information").setAlignment(new char[] { 'l', 'l' }); at.addRow("edit", "Edit sprint").setAlignment(new char[] { 'l', 'l' });
at.addRow("change_status_to", "Change status of sprint (use TAB to autocomplete)\n" + "Status: " + Status.allStatus() + "\n")
hamadmarri/Biscuit
main/java/com/biscuit/commands/userStory/ChangeStatusUserStory.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.UserStory; import com.biscuit.models.enums.Status;
package com.biscuit.commands.userStory; public class ChangeStatusUserStory implements Command { UserStory us = null;
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/userStory/ChangeStatusUserStory.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.UserStory; import com.biscuit.models.enums.Status; package com.biscuit.commands.userStory; public class ChangeStatusUserStory implements Command { UserStory us = null;
Status state = null;
hamadmarri/Biscuit
main/java/com/biscuit/commands/userStory/ChangeStatusUserStory.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.UserStory; import com.biscuit.models.enums.Status;
package com.biscuit.commands.userStory; public class ChangeStatusUserStory implements Command { UserStory us = null; Status state = null; public ChangeStatusUserStory(UserStory us, Status state) { super(); this.us = us; this.state = state; } @Override public boolean execute() throws IOException { Status oldState = us.state; us.state = state; us.save();
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/userStory/ChangeStatusUserStory.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.UserStory; import com.biscuit.models.enums.Status; package com.biscuit.commands.userStory; public class ChangeStatusUserStory implements Command { UserStory us = null; Status state = null; public ChangeStatusUserStory(UserStory us, Status state) { super(); this.us = us; this.state = state; } @Override public boolean execute() throws IOException { Status oldState = us.state; us.state = state; us.save();
System.out.println(ColorCodes.GREEN + "State of user story " + us.title + " has been changed from " + oldState
hamadmarri/Biscuit
main/java/com/biscuit/models/Sprint.java
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.util.List; import com.biscuit.models.enums.Status; import java.util.ArrayList; import java.util.Date;
/* Author: Hamad Al Marri; */ package com.biscuit.models; public class Sprint { public transient Project project; // info public String name; public String description;
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/models/Sprint.java import java.util.List; import com.biscuit.models.enums.Status; import java.util.ArrayList; import java.util.Date; /* Author: Hamad Al Marri; */ package com.biscuit.models; public class Sprint { public transient Project project; // info public String name; public String description;
public Status state;
hamadmarri/Biscuit
main/java/com/biscuit/commands/task/ChangeStatusTask.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.enums.Status;
package com.biscuit.commands.task; public class ChangeStatusTask implements Command { Task t = null;
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/task/ChangeStatusTask.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.enums.Status; package com.biscuit.commands.task; public class ChangeStatusTask implements Command { Task t = null;
Status state = null;
hamadmarri/Biscuit
main/java/com/biscuit/commands/task/ChangeStatusTask.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.enums.Status;
package com.biscuit.commands.task; public class ChangeStatusTask implements Command { Task t = null; Status state = null; public ChangeStatusTask(Task t, Status state) { super(); this.t = t; this.state = state; } @Override public boolean execute() throws IOException { Status oldState = t.state; t.state = state; t.save();
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/task/ChangeStatusTask.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.enums.Status; package com.biscuit.commands.task; public class ChangeStatusTask implements Command { Task t = null; Status state = null; public ChangeStatusTask(Task t, Status state) { super(); this.t = t; this.state = state; } @Override public boolean execute() throws IOException { Status oldState = t.state; t.state = state; t.save();
System.out.println(ColorCodes.GREEN + "State of task " + t.title + " has been changed from " + oldState + " to "
hamadmarri/Biscuit
main/java/com/biscuit/commands/task/ShowTask.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.services.DateService;
package com.biscuit.commands.task; public class ShowTask implements Command { Task t = null; public ShowTask(Task t) { super(); this.t = t; } @Override public boolean execute() throws IOException {
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/task/ShowTask.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.services.DateService; package com.biscuit.commands.task; public class ShowTask implements Command { Task t = null; public ShowTask(Task t) { super(); this.t = t; } @Override public boolean execute() throws IOException {
System.out.println(ColorCodes.BLUE + "title: " + ColorCodes.RESET + t.title);
hamadmarri/Biscuit
main/java/com/biscuit/commands/task/ShowTask.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.services.DateService;
package com.biscuit.commands.task; public class ShowTask implements Command { Task t = null; public ShowTask(Task t) { super(); this.t = t; } @Override public boolean execute() throws IOException { System.out.println(ColorCodes.BLUE + "title: " + ColorCodes.RESET + t.title); System.out.println(ColorCodes.BLUE + "description: "); System.out.println(ColorCodes.RESET + t.description); System.out.println(ColorCodes.BLUE + "state: " + ColorCodes.RESET + t.state); System.out.println(
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Task.java // public class Task { // // public transient Project project; // // public String title; // public String description; // public Status state; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public float estimatedTime; // // public static String[] fields; // // List<Bug> bugs; // List<Test> tests; // // static { // fields = new String[8]; // fields[0] = "title"; // fields[1] = "description"; // fields[2] = "state"; // fields[3] = "initiated_date"; // fields[4] = "planned_date"; // fields[5] = "due_date"; // fields[6] = "estimated_time"; // } // // // public void save() { // project.save(); // } // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/task/ShowTask.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Task; import com.biscuit.models.services.DateService; package com.biscuit.commands.task; public class ShowTask implements Command { Task t = null; public ShowTask(Task t) { super(); this.t = t; } @Override public boolean execute() throws IOException { System.out.println(ColorCodes.BLUE + "title: " + ColorCodes.RESET + t.title); System.out.println(ColorCodes.BLUE + "description: "); System.out.println(ColorCodes.RESET + t.description); System.out.println(ColorCodes.BLUE + "state: " + ColorCodes.RESET + t.state); System.out.println(
ColorCodes.BLUE + "initiated date: " + ColorCodes.RESET + DateService.getDateAsString(t.initiatedDate));
hamadmarri/Biscuit
main/java/com/biscuit/commands/userStory/ShowUserStory.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService;
package com.biscuit.commands.userStory; public class ShowUserStory implements Command { UserStory us = null; public ShowUserStory(UserStory us) { super(); this.us = us; } @Override public boolean execute() throws IOException {
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/userStory/ShowUserStory.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService; package com.biscuit.commands.userStory; public class ShowUserStory implements Command { UserStory us = null; public ShowUserStory(UserStory us) { super(); this.us = us; } @Override public boolean execute() throws IOException {
System.out.println(ColorCodes.BLUE + "title: " + ColorCodes.RESET + us.title);
hamadmarri/Biscuit
main/java/com/biscuit/commands/userStory/ShowUserStory.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService;
package com.biscuit.commands.userStory; public class ShowUserStory implements Command { UserStory us = null; public ShowUserStory(UserStory us) { super(); this.us = us; } @Override public boolean execute() throws IOException { System.out.println(ColorCodes.BLUE + "title: " + ColorCodes.RESET + us.title); System.out.println(ColorCodes.BLUE + "description: "); System.out.println(ColorCodes.RESET + us.description); System.out.println(ColorCodes.BLUE + "state: " + ColorCodes.RESET + us.state); System.out.println(ColorCodes.BLUE + "business value: " + ColorCodes.RESET + us.businessValue); System.out.println(ColorCodes.BLUE + "initiated date: " + ColorCodes.RESET
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/services/DateService.java // public class DateService { // // public static transient SimpleDateFormat dateFormat = new SimpleDateFormat("MMM. dd, yyyy"); // // // public static boolean isSet(Date d) { // return (d.compareTo(new Date(0)) > 0); // } // // // public static String getDateAsString(Date d) { // if (DateService.isSet(d)) { // return DateService.dateFormat.format(d); // } // return "Not set yet"; // } // // } // Path: main/java/com/biscuit/commands/userStory/ShowUserStory.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.UserStory; import com.biscuit.models.services.DateService; package com.biscuit.commands.userStory; public class ShowUserStory implements Command { UserStory us = null; public ShowUserStory(UserStory us) { super(); this.us = us; } @Override public boolean execute() throws IOException { System.out.println(ColorCodes.BLUE + "title: " + ColorCodes.RESET + us.title); System.out.println(ColorCodes.BLUE + "description: "); System.out.println(ColorCodes.RESET + us.description); System.out.println(ColorCodes.BLUE + "state: " + ColorCodes.RESET + us.state); System.out.println(ColorCodes.BLUE + "business value: " + ColorCodes.RESET + us.businessValue); System.out.println(ColorCodes.BLUE + "initiated date: " + ColorCodes.RESET
+ DateService.getDateAsString(us.initiatedDate));
hamadmarri/Biscuit
main/java/com/biscuit/models/Release.java
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.util.List; import com.biscuit.models.enums.Status; import java.util.ArrayList; import java.util.Date;
/* Author: Hamad Al Marri; */ package com.biscuit.models; public class Release { public transient Project project; // info public String name; public String description;
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/models/Release.java import java.util.List; import com.biscuit.models.enums.Status; import java.util.ArrayList; import java.util.Date; /* Author: Hamad Al Marri; */ package com.biscuit.models; public class Release { public transient Project project; // info public String name; public String description;
public Status state;
hamadmarri/Biscuit
main/java/com/biscuit/factories/DashboardCompleterFactory.java
// Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // }
import java.util.ArrayList; import java.util.List; import com.biscuit.models.Dashboard; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter;
package com.biscuit.factories; public class DashboardCompleterFactory { public static List<Completer> getDashboardCompleters() { List<Completer> completers = new ArrayList<Completer>(); // TODO: dashboard commands // completers.add(new ArgumentCompleter( // new StringsCompleter("summary", "projects", "alerts", "check_alert", // "search"), // new NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), // new StringsCompleter("users", "contacts", "groups"), new // NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("projects"), new StringsCompleter("filter", // "sort"), // new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("alerts"), new StringsCompleter("filter", // "sort"), // new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), new StringsCompleter("project"), new StringsCompleter(getProjectsNames()), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), new StringsCompleter(getProjectsNames()), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("add", "edit", "remove"), new StringsCompleter("project"), new NullCompleter())); return completers; } private static List<String> getProjectsNames() {
// Path: main/java/com/biscuit/models/Dashboard.java // public class Dashboard { // // // users // // contacts // // groups // // private static transient Dashboard thisInstance = null; // // // public static Dashboard getInstance() { // return thisInstance; // } // // // public static void setInstance(Dashboard r) { // thisInstance = r; // } // // private transient String name = "dashboard"; // // public List<String> projectsNames = new ArrayList<String>(); // // // public void addProject(Project p) { // projectsNames.add(p.name); // } // // // public void removeProject(Project p) { // projectsNames.remove(p.name); // } // // // public void renameProject(String oldName, String newName) throws IOException { // ModelHelper.rename(oldName, newName); // projectsNames.remove(oldName); // projectsNames.add(newName); // } // // // public void save() { // ModelHelper.save(this, name); // } // // // static public Dashboard load() { // return ModelHelper.loadDashboard("dashboard"); // } // // } // Path: main/java/com/biscuit/factories/DashboardCompleterFactory.java import java.util.ArrayList; import java.util.List; import com.biscuit.models.Dashboard; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter; package com.biscuit.factories; public class DashboardCompleterFactory { public static List<Completer> getDashboardCompleters() { List<Completer> completers = new ArrayList<Completer>(); // TODO: dashboard commands // completers.add(new ArgumentCompleter( // new StringsCompleter("summary", "projects", "alerts", "check_alert", // "search"), // new NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), // new StringsCompleter("users", "contacts", "groups"), new // NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("projects"), new StringsCompleter("filter", // "sort"), // new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("alerts"), new StringsCompleter("filter", // "sort"), // new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), new StringsCompleter("project"), new StringsCompleter(getProjectsNames()), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), new StringsCompleter(getProjectsNames()), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("add", "edit", "remove"), new StringsCompleter("project"), new NullCompleter())); return completers; } private static List<String> getProjectsNames() {
return Dashboard.getInstance().projectsNames;
hamadmarri/Biscuit
main/java/com/biscuit/factories/UserStoryCompleterFactory.java
// Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // // Path: main/java/com/biscuit/models/services/Finder.java // public static class Tasks { // // public static List<String> getAllNames(UserStory us) { // return us.tasks.stream().map(t -> t.title).collect(Collectors.toList()); // } // // // public static Task find(UserStory us, String title) { // return us.tasks.stream().filter(t -> t.title.equals(title)).findAny().orElse(null); // } // }
import java.util.ArrayList; import java.util.List; import com.biscuit.models.UserStory; import com.biscuit.models.enums.Status; import com.biscuit.models.services.Finder.Tasks; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter;
package com.biscuit.factories; public class UserStoryCompleterFactory { public static List<Completer> getUserStoryCompleters(UserStory userStory) { List<Completer> completers = new ArrayList<Completer>(); // TODO: user story commands // "summary","times", // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("open"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("planned"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("in_progress"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("in_testing"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("done"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("tasks"), new StringsCompleter("filter"), new // NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("add"), new // StringsCompleter("task", "bug", "test"), new NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), // new StringsCompleter("bug#", "test#"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("show", "edit", "tasks", "back"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("add"), new StringsCompleter("task"), new NullCompleter()));
// Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // // Path: main/java/com/biscuit/models/services/Finder.java // public static class Tasks { // // public static List<String> getAllNames(UserStory us) { // return us.tasks.stream().map(t -> t.title).collect(Collectors.toList()); // } // // // public static Task find(UserStory us, String title) { // return us.tasks.stream().filter(t -> t.title.equals(title)).findAny().orElse(null); // } // } // Path: main/java/com/biscuit/factories/UserStoryCompleterFactory.java import java.util.ArrayList; import java.util.List; import com.biscuit.models.UserStory; import com.biscuit.models.enums.Status; import com.biscuit.models.services.Finder.Tasks; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter; package com.biscuit.factories; public class UserStoryCompleterFactory { public static List<Completer> getUserStoryCompleters(UserStory userStory) { List<Completer> completers = new ArrayList<Completer>(); // TODO: user story commands // "summary","times", // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("open"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("planned"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("in_progress"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("in_testing"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("done"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("tasks"), new StringsCompleter("filter"), new // NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("add"), new // StringsCompleter("task", "bug", "test"), new NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), // new StringsCompleter("bug#", "test#"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("show", "edit", "tasks", "back"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("add"), new StringsCompleter("task"), new NullCompleter()));
completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), new StringsCompleter("task"), new StringsCompleter(Tasks.getAllNames(userStory)),
hamadmarri/Biscuit
main/java/com/biscuit/factories/UserStoryCompleterFactory.java
// Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // // Path: main/java/com/biscuit/models/services/Finder.java // public static class Tasks { // // public static List<String> getAllNames(UserStory us) { // return us.tasks.stream().map(t -> t.title).collect(Collectors.toList()); // } // // // public static Task find(UserStory us, String title) { // return us.tasks.stream().filter(t -> t.title.equals(title)).findAny().orElse(null); // } // }
import java.util.ArrayList; import java.util.List; import com.biscuit.models.UserStory; import com.biscuit.models.enums.Status; import com.biscuit.models.services.Finder.Tasks; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter;
package com.biscuit.factories; public class UserStoryCompleterFactory { public static List<Completer> getUserStoryCompleters(UserStory userStory) { List<Completer> completers = new ArrayList<Completer>(); // TODO: user story commands // "summary","times", // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("open"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("planned"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("in_progress"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("in_testing"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("done"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("tasks"), new StringsCompleter("filter"), new // NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("add"), new // StringsCompleter("task", "bug", "test"), new NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), // new StringsCompleter("bug#", "test#"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("show", "edit", "tasks", "back"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("add"), new StringsCompleter("task"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), new StringsCompleter("task"), new StringsCompleter(Tasks.getAllNames(userStory)), new NullCompleter()));
// Path: main/java/com/biscuit/models/UserStory.java // public class UserStory { // // public transient Project project; // // public String title; // public String description; // public Status state; // public BusinessValue businessValue; // public Date initiatedDate = null; // public Date plannedDate = null; // public Date dueDate = null; // public int points; // // public static String[] fields; // // public List<Task> tasks = new ArrayList<>(); // public List<Bug> bugs = new ArrayList<>(); // public List<Test> tests = new ArrayList<>(); // // static { // fields = new String[] { "title", "description", "state", "business_value", "initiated_date", "planned_date", "due_date", "tasks", "points" }; // } // // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // // Path: main/java/com/biscuit/models/services/Finder.java // public static class Tasks { // // public static List<String> getAllNames(UserStory us) { // return us.tasks.stream().map(t -> t.title).collect(Collectors.toList()); // } // // // public static Task find(UserStory us, String title) { // return us.tasks.stream().filter(t -> t.title.equals(title)).findAny().orElse(null); // } // } // Path: main/java/com/biscuit/factories/UserStoryCompleterFactory.java import java.util.ArrayList; import java.util.List; import com.biscuit.models.UserStory; import com.biscuit.models.enums.Status; import com.biscuit.models.services.Finder.Tasks; import jline.console.completer.ArgumentCompleter; import jline.console.completer.Completer; import jline.console.completer.NullCompleter; import jline.console.completer.StringsCompleter; package com.biscuit.factories; public class UserStoryCompleterFactory { public static List<Completer> getUserStoryCompleters(UserStory userStory) { List<Completer> completers = new ArrayList<Completer>(); // TODO: user story commands // "summary","times", // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("open"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("planned"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("in_progress"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("in_testing"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("done"), new StringsCompleter("tasks"), // new StringsCompleter("filter", "sort"), new NullCompleter())); // // completers.add(new ArgumentCompleter(new StringsCompleter("list"), // new StringsCompleter("tasks"), new StringsCompleter("filter"), new // NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("add"), new // StringsCompleter("task", "bug", "test"), new NullCompleter())); // completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), // new StringsCompleter("bug#", "test#"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("show", "edit", "tasks", "back"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("add"), new StringsCompleter("task"), new NullCompleter())); completers.add(new ArgumentCompleter(new StringsCompleter("go_to"), new StringsCompleter("task"), new StringsCompleter(Tasks.getAllNames(userStory)), new NullCompleter()));
completers.add(new ArgumentCompleter(new StringsCompleter("change_status_to"), new StringsCompleter(Status.values), new NullCompleter()));
hamadmarri/Biscuit
main/java/com/biscuit/commands/sprint/ChangeStatusSprint.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Sprint.java // public class Sprint { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // public int velocity; // // public List<UserStory> userStories = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort", "velocity" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort", "Velocity" }; // } // // public void addUserStory(UserStory userStory) { // this.userStories.add(userStory); // } // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Sprint; import com.biscuit.models.enums.Status;
package com.biscuit.commands.sprint; public class ChangeStatusSprint implements Command { Sprint s = null;
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Sprint.java // public class Sprint { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // public int velocity; // // public List<UserStory> userStories = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort", "velocity" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort", "Velocity" }; // } // // public void addUserStory(UserStory userStory) { // this.userStories.add(userStory); // } // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/sprint/ChangeStatusSprint.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Sprint; import com.biscuit.models.enums.Status; package com.biscuit.commands.sprint; public class ChangeStatusSprint implements Command { Sprint s = null;
Status state = null;
hamadmarri/Biscuit
main/java/com/biscuit/commands/sprint/ChangeStatusSprint.java
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Sprint.java // public class Sprint { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // public int velocity; // // public List<UserStory> userStories = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort", "velocity" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort", "Velocity" }; // } // // public void addUserStory(UserStory userStory) { // this.userStories.add(userStory); // } // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Sprint; import com.biscuit.models.enums.Status;
package com.biscuit.commands.sprint; public class ChangeStatusSprint implements Command { Sprint s = null; Status state = null; public ChangeStatusSprint(Sprint s, Status state) { super(); this.s = s; this.state = state; } @Override public boolean execute() throws IOException { Status oldState = s.state; s.state = state; s.save();
// Path: main/java/com/biscuit/ColorCodes.java // public class ColorCodes { // // // with normal background // public static final String RESET = "\u001B[0m"; // public static final String BLACK = "\u001B[30;1m"; // public static final String RED = "\u001B[31;1m"; // public static final String GREEN = "\u001B[32;1m"; // public static final String YELLOW = "\u001B[33;1m"; // public static final String BLUE = "\u001B[34;1m"; // public static final String PURPLE = "\u001B[35;1m"; // public static final String CYAN = "\u001B[36;1m"; // public static final String WHITE = "\u001B[37;1m"; // // // with black background // public static final String B_RESET = "\u001B[0m"; // public static final String B_BLACK = "\u001B[30;40;1m"; // public static final String B_RED = "\u001B[31;40;1m"; // public static final String B_GREEN = "\u001B[32;40;1m"; // public static final String B_YELLOW = "\u001B[33;40;1m"; // public static final String B_BLUE = "\u001B[34;40;1m"; // public static final String B_PURPLE = "\u001B[35;40;1m"; // public static final String B_CYAN = "\u001B[36;40;1m"; // public static final String B_WHITE = "\u001B[37;40;1m"; // // } // // Path: main/java/com/biscuit/commands/Command.java // public interface Command { // // boolean execute() throws IOException; // } // // Path: main/java/com/biscuit/models/Sprint.java // public class Sprint { // // public transient Project project; // // // info // public String name; // public String description; // public Status state; // public Date startDate; // public Date dueDate; // public int assignedEffort; // public int velocity; // // public List<UserStory> userStories = new ArrayList<>(); // public List<Bug> bugs; // public List<Test> tests; // // // Completed 0pt 0% ToDo 8pt // // public static String[] fields; // public static String[] fieldsAsHeader; // // static { // fields = new String[] { "name", "description", "state", "start_date", "due_date", "assigned_effort", "velocity" }; // fieldsAsHeader = new String[] { "Name", "Description", "State", "Start Date", "Due Date", "Assigned Effort", "Velocity" }; // } // // public void addUserStory(UserStory userStory) { // this.userStories.add(userStory); // } // // public void save() { // project.save(); // } // // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/sprint/ChangeStatusSprint.java import java.io.IOException; import com.biscuit.ColorCodes; import com.biscuit.commands.Command; import com.biscuit.models.Sprint; import com.biscuit.models.enums.Status; package com.biscuit.commands.sprint; public class ChangeStatusSprint implements Command { Sprint s = null; Status state = null; public ChangeStatusSprint(Sprint s, Status state) { super(); this.s = s; this.state = state; } @Override public boolean execute() throws IOException { Status oldState = s.state; s.state = state; s.save();
System.out.println(ColorCodes.GREEN + "State of sprint " + s.name + " has been changed from " + oldState
hamadmarri/Biscuit
main/java/com/biscuit/models/UserStory.java
// Path: main/java/com/biscuit/models/enums/BusinessValue.java // public enum BusinessValue { // // MUST_HAVE(0), GREAT(1), GOOD(2), AVERAGE(3), NICE_TO_HAVE(4); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("nice_to_have", "average", "good", "great", "must_have")); // // // private BusinessValue(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.util.ArrayList; import java.util.Date; import java.util.List; import com.biscuit.models.enums.BusinessValue; import com.biscuit.models.enums.Status;
/* Author: Hamad Al Marri; */ package com.biscuit.models; public class UserStory { public transient Project project; public String title; public String description;
// Path: main/java/com/biscuit/models/enums/BusinessValue.java // public enum BusinessValue { // // MUST_HAVE(0), GREAT(1), GOOD(2), AVERAGE(3), NICE_TO_HAVE(4); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("nice_to_have", "average", "good", "great", "must_have")); // // // private BusinessValue(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/models/UserStory.java import java.util.ArrayList; import java.util.Date; import java.util.List; import com.biscuit.models.enums.BusinessValue; import com.biscuit.models.enums.Status; /* Author: Hamad Al Marri; */ package com.biscuit.models; public class UserStory { public transient Project project; public String title; public String description;
public Status state;
hamadmarri/Biscuit
main/java/com/biscuit/models/UserStory.java
// Path: main/java/com/biscuit/models/enums/BusinessValue.java // public enum BusinessValue { // // MUST_HAVE(0), GREAT(1), GOOD(2), AVERAGE(3), NICE_TO_HAVE(4); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("nice_to_have", "average", "good", "great", "must_have")); // // // private BusinessValue(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import java.util.ArrayList; import java.util.Date; import java.util.List; import com.biscuit.models.enums.BusinessValue; import com.biscuit.models.enums.Status;
/* Author: Hamad Al Marri; */ package com.biscuit.models; public class UserStory { public transient Project project; public String title; public String description; public Status state;
// Path: main/java/com/biscuit/models/enums/BusinessValue.java // public enum BusinessValue { // // MUST_HAVE(0), GREAT(1), GOOD(2), AVERAGE(3), NICE_TO_HAVE(4); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("nice_to_have", "average", "good", "great", "must_have")); // // // private BusinessValue(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // } // // Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/models/UserStory.java import java.util.ArrayList; import java.util.Date; import java.util.List; import com.biscuit.models.enums.BusinessValue; import com.biscuit.models.enums.Status; /* Author: Hamad Al Marri; */ package com.biscuit.models; public class UserStory { public transient Project project; public String title; public String description; public Status state;
public BusinessValue businessValue;
hamadmarri/Biscuit
main/java/com/biscuit/commands/help/TaskHelp.java
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // }
import com.biscuit.models.enums.Status; import de.vandermeer.asciitable.v2.V2_AsciiTable;
package com.biscuit.commands.help; public class TaskHelp extends UniversalHelp { @Override public void executeChild(V2_AsciiTable at) { at.addRow(null, "Task Commands").setAlignment(new char[] { 'c', 'c' }); at.addRule(); at.addRow("show", "Show task information").setAlignment(new char[] { 'l', 'l' }); at.addRow("edit", "Edit task").setAlignment(new char[] { 'l', 'l' });
// Path: main/java/com/biscuit/models/enums/Status.java // public enum Status { // // CREATED(0), OPEN(1), PLANNED(2), UNPLANNED(3), IN_PROGRESS(4), IN_TESTING(5), DONE(6), OVERDUE(7), REMOVED(8); // // private final int value; // public static List<String> values = new ArrayList<>( // Arrays.asList("created", "open", "planned", "unplanned", "in_progress", "in_testing", "done", "overdue", "removed")); // // // private Status(int value) { // this.value = value; // } // // // public int getValue() { // return value; // } // // // public static String allStatus() { // StringBuilder sb = new StringBuilder(); // // for (String s : values) { // sb.append(s).append(", "); // } // // return sb.substring(0, sb.length() - 2); // } // // } // Path: main/java/com/biscuit/commands/help/TaskHelp.java import com.biscuit.models.enums.Status; import de.vandermeer.asciitable.v2.V2_AsciiTable; package com.biscuit.commands.help; public class TaskHelp extends UniversalHelp { @Override public void executeChild(V2_AsciiTable at) { at.addRow(null, "Task Commands").setAlignment(new char[] { 'c', 'c' }); at.addRule(); at.addRow("show", "Show task information").setAlignment(new char[] { 'l', 'l' }); at.addRow("edit", "Edit task").setAlignment(new char[] { 'l', 'l' });
at.addRow("change_status_to", "Change status of task (use TAB to autocomplete)\n" + "Status: " + Status.allStatus() + "\n")