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
Adipa-G/joquery
src/joquery/core/collection/expr/condition/GtConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.core.QueryException;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class GtConditionalExpr<T> extends ConditionalExpr<T> { @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/core/collection/expr/condition/GtConditionalExpr.java import joquery.core.QueryException; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class GtConditionalExpr<T> extends ConditionalExpr<T> { @Override
public Object evaluate(T t) throws QueryException
Adipa-G/joquery
src-test/joquery/QueryConditionTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class QueryConditionTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; }
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/QueryConditionTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class QueryConditionTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; }
@Test(expected = QueryException.class)
Adipa-G/joquery
src-test/joquery/QueryConditionTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection;
} @Test(expected = QueryException.class) public void condition_AndWithLeftNonBoolean_ShouldThrowException() throws QueryException { Filter<Dto> query = CQ.<Dto>filter() .from(testList) .where() .value(1) .and() .property(Dto::getId).eq().value(2); query.list(); } @Test(expected = QueryException.class) public void condition_OrWithRightNonBoolean_ShouldThrowException() throws QueryException { Filter<Dto> query = CQ.<Dto>filter() .from(testList) .where() .property(Dto::getId).eq().value(2) .or() .value(1); query.list(); } private static void assertResult(Collection<Dto> list,int[] ids) {
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/QueryConditionTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; } @Test(expected = QueryException.class) public void condition_AndWithLeftNonBoolean_ShouldThrowException() throws QueryException { Filter<Dto> query = CQ.<Dto>filter() .from(testList) .where() .value(1) .and() .property(Dto::getId).eq().value(2); query.list(); } @Test(expected = QueryException.class) public void condition_OrWithRightNonBoolean_ShouldThrowException() throws QueryException { Filter<Dto> query = CQ.<Dto>filter() .from(testList) .where() .property(Dto::getId).eq().value(2) .or() .value(1); query.list(); } private static void assertResult(Collection<Dto> list,int[] ids) {
A.exp(ids.length).act(list.size(),String.format("Expected items are not retrieved"));
Adipa-G/joquery
src-test/joquery/FilterTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class FilterTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/FilterTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class FilterTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test
public void first_WithNoFilter_ShouldReturnAll() throws QueryException
Adipa-G/joquery
src-test/joquery/FilterTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class FilterTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test public void first_WithNoFilter_ShouldReturnAll() throws QueryException { Dto first = CQ.<Dto>filter(testList).first();
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/FilterTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class FilterTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test public void first_WithNoFilter_ShouldReturnAll() throws QueryException { Dto first = CQ.<Dto>filter(testList).first();
A.exp(testList.iterator().next()).act(first);
Adipa-G/joquery
src/joquery/core/collection/ResultTransformedQueryImpl.java
// Path: src/joquery/core/JoinMode.java // public enum JoinMode // { // INNER, // LEFT_OUTER, // RIGHT_OUTER // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.*; import joquery.core.JoinMode; import joquery.core.QueryException; import java.util.Collection; import java.util.function.Function;
package joquery.core.collection; /** * User: Adipa * Date: 10/28/12 * Time: 12:44 PM */ public abstract class ResultTransformedQueryImpl<T,U,W extends ResultTransformedQuery<T,U,W>> extends QueryImpl<T,W> implements ResultTransformedQuery<T,U,W> { private ResultTransformer<T, U> directTransformer; private ResultTransformer<Object[], U> selectionTransformer; @Override
// Path: src/joquery/core/JoinMode.java // public enum JoinMode // { // INNER, // LEFT_OUTER, // RIGHT_OUTER // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/core/collection/ResultTransformedQueryImpl.java import joquery.*; import joquery.core.JoinMode; import joquery.core.QueryException; import java.util.Collection; import java.util.function.Function; package joquery.core.collection; /** * User: Adipa * Date: 10/28/12 * Time: 12:44 PM */ public abstract class ResultTransformedQueryImpl<T,U,W extends ResultTransformedQuery<T,U,W>> extends QueryImpl<T,W> implements ResultTransformedQuery<T,U,W> { private ResultTransformer<T, U> directTransformer; private ResultTransformer<Object[], U> selectionTransformer; @Override
public U first() throws QueryException
Adipa-G/joquery
src/joquery/core/collection/ResultTransformedQueryImpl.java
// Path: src/joquery/core/JoinMode.java // public enum JoinMode // { // INNER, // LEFT_OUTER, // RIGHT_OUTER // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.*; import joquery.core.JoinMode; import joquery.core.QueryException; import java.util.Collection; import java.util.function.Function;
if (directTransformer != null) return super.transformDefaultSelection(directTransformer); return super.transformDefaultSelection(); } @Override public <V> U project(IProject<T,V,U> project,Function<T,V> property) throws QueryException { return project.eval(getItems(),property); } @Override public ResultTransformedQueryImpl<T,U,W> transformDirect(ResultTransformer<T, U> transformer) { directTransformer = transformer; return this; } @Override public ResultTransformedQueryImpl<T,U,W> transformSelection(ResultTransformer<Object[], U> transformer) { selectionTransformer = transformer; return this; } @Override public <X,Y> JoinQuery<U,X,Y> innerJoin(ResultTransformedQuery<X, X, ?> rightQuery) throws QueryException {
// Path: src/joquery/core/JoinMode.java // public enum JoinMode // { // INNER, // LEFT_OUTER, // RIGHT_OUTER // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/core/collection/ResultTransformedQueryImpl.java import joquery.*; import joquery.core.JoinMode; import joquery.core.QueryException; import java.util.Collection; import java.util.function.Function; if (directTransformer != null) return super.transformDefaultSelection(directTransformer); return super.transformDefaultSelection(); } @Override public <V> U project(IProject<T,V,U> project,Function<T,V> property) throws QueryException { return project.eval(getItems(),property); } @Override public ResultTransformedQueryImpl<T,U,W> transformDirect(ResultTransformer<T, U> transformer) { directTransformer = transformer; return this; } @Override public ResultTransformedQueryImpl<T,U,W> transformSelection(ResultTransformer<Object[], U> transformer) { selectionTransformer = transformer; return this; } @Override public <X,Y> JoinQuery<U,X,Y> innerJoin(ResultTransformedQuery<X, X, ?> rightQuery) throws QueryException {
return doJoin(JoinMode.INNER,rightQuery);
Adipa-G/joquery
src-test/joquery/JoinTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Collections;
leftList.add(new LeftDto(1, "1")); rightList.add(new RightDto(1, 100)); leftList.add(new LeftDto(2, "2")); rightList.add(new RightDto(2, 101)); leftList.add(new LeftDto(3, "3")); rightList.add(new RightDto(3, 102)); leftList.add(new LeftDto(4, "4")); rightList.add(new RightDto(4, 103)); //left only items leftList.add(new LeftDto(5, "5")); leftList.add(new LeftDto(6, "6")); leftList.add(new LeftDto(7, "7")); //right only items rightList.add(new RightDto(8, 104)); rightList.add(new RightDto(9, 105)); rightList.add(new RightDto(10, 106)); } @AfterClass public static void cleanup() { leftList.clear(); rightList.clear(); leftList = null; rightList = null; } @Test
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/JoinTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; leftList.add(new LeftDto(1, "1")); rightList.add(new RightDto(1, 100)); leftList.add(new LeftDto(2, "2")); rightList.add(new RightDto(2, 101)); leftList.add(new LeftDto(3, "3")); rightList.add(new RightDto(3, 102)); leftList.add(new LeftDto(4, "4")); rightList.add(new RightDto(4, 103)); //left only items leftList.add(new LeftDto(5, "5")); leftList.add(new LeftDto(6, "6")); leftList.add(new LeftDto(7, "7")); //right only items rightList.add(new RightDto(8, 104)); rightList.add(new RightDto(9, 105)); rightList.add(new RightDto(10, 106)); } @AfterClass public static void cleanup() { leftList.clear(); rightList.clear(); leftList = null; rightList = null; } @Test
public void join_TwoEmptyQueries_ShouldReturnEmpty() throws QueryException
Adipa-G/joquery
src-test/joquery/JoinTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Collections;
rightList.add(new RightDto(4, 103)); //left only items leftList.add(new LeftDto(5, "5")); leftList.add(new LeftDto(6, "6")); leftList.add(new LeftDto(7, "7")); //right only items rightList.add(new RightDto(8, 104)); rightList.add(new RightDto(9, 105)); rightList.add(new RightDto(10, 106)); } @AfterClass public static void cleanup() { leftList.clear(); rightList.clear(); leftList = null; rightList = null; } @Test public void join_TwoEmptyQueries_ShouldReturnEmpty() throws QueryException { SelectionQuery<LeftDto, LeftDto> leftQuery = CQ.query(Collections.<LeftDto>emptyList()); SelectionQuery<RightDto, RightDto> rightQuery = CQ.query(Collections.<RightDto>emptyList()); JoinQuery<LeftDto, RightDto, JoinedDto> joinQuery = leftQuery.innerJoin(rightQuery); Collection<JoinedDto> results = joinQuery.list();
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/JoinTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; rightList.add(new RightDto(4, 103)); //left only items leftList.add(new LeftDto(5, "5")); leftList.add(new LeftDto(6, "6")); leftList.add(new LeftDto(7, "7")); //right only items rightList.add(new RightDto(8, 104)); rightList.add(new RightDto(9, 105)); rightList.add(new RightDto(10, 106)); } @AfterClass public static void cleanup() { leftList.clear(); rightList.clear(); leftList = null; rightList = null; } @Test public void join_TwoEmptyQueries_ShouldReturnEmpty() throws QueryException { SelectionQuery<LeftDto, LeftDto> leftQuery = CQ.query(Collections.<LeftDto>emptyList()); SelectionQuery<RightDto, RightDto> rightQuery = CQ.query(Collections.<RightDto>emptyList()); JoinQuery<LeftDto, RightDto, JoinedDto> joinQuery = leftQuery.innerJoin(rightQuery); Collection<JoinedDto> results = joinQuery.list();
A.exp(0).act(results.size());
Adipa-G/joquery
src-test/joquery/GroupConditionsTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.*;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class GroupConditionsTest { private static Collection<Dto> dtoList; @BeforeClass public static void setup() { dtoList = new ArrayList<>();
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/GroupConditionsTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.*; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class GroupConditionsTest { private static Collection<Dto> dtoList; @BeforeClass public static void setup() { dtoList = new ArrayList<>();
dtoList.add(new Dto(1, "A"));
Adipa-G/joquery
src-test/joquery/GroupConditionsTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.*;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class GroupConditionsTest { private static Collection<Dto> dtoList; @BeforeClass public static void setup() { dtoList = new ArrayList<>(); dtoList.add(new Dto(1, "A")); dtoList.add(new Dto(3, "C")); dtoList.add(new Dto(2, "C")); dtoList.add(new Dto(4, "B")); dtoList.add(new Dto(5, "E")); dtoList.add(new Dto(5, "F")); dtoList.add(new Dto(5, "F")); dtoList.add(new Dto(5, null)); } @AfterClass public static void cleanup() { dtoList.clear(); dtoList = null; } @Test
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/GroupConditionsTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.*; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class GroupConditionsTest { private static Collection<Dto> dtoList; @BeforeClass public static void setup() { dtoList = new ArrayList<>(); dtoList.add(new Dto(1, "A")); dtoList.add(new Dto(3, "C")); dtoList.add(new Dto(2, "C")); dtoList.add(new Dto(4, "B")); dtoList.add(new Dto(5, "E")); dtoList.add(new Dto(5, "F")); dtoList.add(new Dto(5, "F")); dtoList.add(new Dto(5, null)); } @AfterClass public static void cleanup() { dtoList.clear(); dtoList = null; } @Test
public void groupConditionById_EmptyList_ShouldReturnEmptyList() throws QueryException
Adipa-G/joquery
src/joquery/core/collection/join/JoinCondition.java
// Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // }
import joquery.core.collection.expr.IExpr;
package joquery.core.collection.join; /** * User: Adipa * Date: 10/28/12 * Time: 7:07 PM */ public class JoinCondition<T,U> {
// Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // Path: src/joquery/core/collection/join/JoinCondition.java import joquery.core.collection.expr.IExpr; package joquery.core.collection.join; /** * User: Adipa * Date: 10/28/12 * Time: 7:07 PM */ public class JoinCondition<T,U> {
private IExpr<T> left;
Adipa-G/joquery
src/joquery/core/collection/expr/IExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // }
import joquery.core.QueryException; import joquery.core.QueryMode;
package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public interface IExpr<T> {
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // Path: src/joquery/core/collection/expr/IExpr.java import joquery.core.QueryException; import joquery.core.QueryMode; package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public interface IExpr<T> {
boolean supportsMode(QueryMode mode);
Adipa-G/joquery
src/joquery/core/collection/expr/IExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // }
import joquery.core.QueryException; import joquery.core.QueryMode;
package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public interface IExpr<T> { boolean supportsMode(QueryMode mode); boolean add(IExpr<T> expr);
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // Path: src/joquery/core/collection/expr/IExpr.java import joquery.core.QueryException; import joquery.core.QueryMode; package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public interface IExpr<T> { boolean supportsMode(QueryMode mode); boolean add(IExpr<T> expr);
Object evaluate(T t) throws QueryException;
Adipa-G/joquery
src/joquery/core/collection/expr/condition/combine/BaseConditionalCombinationExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // // Path: src/joquery/core/collection/expr/condition/ConditionalExpr.java // public abstract class ConditionalExpr<T> implements IExpr<T> // { // protected IExpr<T> left; // protected IExpr<T> right; // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.WHERE; // } // // @Override // public boolean add(IExpr<T> expr) // { // if (left == null) // { // left = expr; // return true; // } // else if (right == null) // { // right = expr; // return true; // } // return false; // } // // protected void validate() throws QueryException // { // if (left == null || right == null) // throw new QueryException(String.format("%s segment of %s is null",left == null ? "Left":"Right",this)); // } // }
import joquery.core.QueryException; import joquery.core.collection.expr.IExpr; import joquery.core.collection.expr.condition.ConditionalExpr;
package joquery.core.collection.expr.condition.combine; /** * User: Adipa * Date: 10/14/12 * Time: 12:58 PM */ public abstract class BaseConditionalCombinationExpr<T> extends ConditionalExpr<T> { @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // // Path: src/joquery/core/collection/expr/condition/ConditionalExpr.java // public abstract class ConditionalExpr<T> implements IExpr<T> // { // protected IExpr<T> left; // protected IExpr<T> right; // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.WHERE; // } // // @Override // public boolean add(IExpr<T> expr) // { // if (left == null) // { // left = expr; // return true; // } // else if (right == null) // { // right = expr; // return true; // } // return false; // } // // protected void validate() throws QueryException // { // if (left == null || right == null) // throw new QueryException(String.format("%s segment of %s is null",left == null ? "Left":"Right",this)); // } // } // Path: src/joquery/core/collection/expr/condition/combine/BaseConditionalCombinationExpr.java import joquery.core.QueryException; import joquery.core.collection.expr.IExpr; import joquery.core.collection.expr.condition.ConditionalExpr; package joquery.core.collection.expr.condition.combine; /** * User: Adipa * Date: 10/14/12 * Time: 12:58 PM */ public abstract class BaseConditionalCombinationExpr<T> extends ConditionalExpr<T> { @Override
public boolean add(IExpr<T> expr)
Adipa-G/joquery
src/joquery/core/collection/expr/condition/combine/BaseConditionalCombinationExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // // Path: src/joquery/core/collection/expr/condition/ConditionalExpr.java // public abstract class ConditionalExpr<T> implements IExpr<T> // { // protected IExpr<T> left; // protected IExpr<T> right; // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.WHERE; // } // // @Override // public boolean add(IExpr<T> expr) // { // if (left == null) // { // left = expr; // return true; // } // else if (right == null) // { // right = expr; // return true; // } // return false; // } // // protected void validate() throws QueryException // { // if (left == null || right == null) // throw new QueryException(String.format("%s segment of %s is null",left == null ? "Left":"Right",this)); // } // }
import joquery.core.QueryException; import joquery.core.collection.expr.IExpr; import joquery.core.collection.expr.condition.ConditionalExpr;
package joquery.core.collection.expr.condition.combine; /** * User: Adipa * Date: 10/14/12 * Time: 12:58 PM */ public abstract class BaseConditionalCombinationExpr<T> extends ConditionalExpr<T> { @Override public boolean add(IExpr<T> expr) { if (left != null && expr instanceof BaseConditionalCombinationExpr) return false; boolean added = super.add(expr); if (added) return true; boolean canAddToRight = right.add(expr); if (canAddToRight) return true; boolean canRightAddToExpr = expr.add(right); if (canRightAddToExpr) { right = expr; return true; } return false; } @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // // Path: src/joquery/core/collection/expr/condition/ConditionalExpr.java // public abstract class ConditionalExpr<T> implements IExpr<T> // { // protected IExpr<T> left; // protected IExpr<T> right; // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.WHERE; // } // // @Override // public boolean add(IExpr<T> expr) // { // if (left == null) // { // left = expr; // return true; // } // else if (right == null) // { // right = expr; // return true; // } // return false; // } // // protected void validate() throws QueryException // { // if (left == null || right == null) // throw new QueryException(String.format("%s segment of %s is null",left == null ? "Left":"Right",this)); // } // } // Path: src/joquery/core/collection/expr/condition/combine/BaseConditionalCombinationExpr.java import joquery.core.QueryException; import joquery.core.collection.expr.IExpr; import joquery.core.collection.expr.condition.ConditionalExpr; package joquery.core.collection.expr.condition.combine; /** * User: Adipa * Date: 10/14/12 * Time: 12:58 PM */ public abstract class BaseConditionalCombinationExpr<T> extends ConditionalExpr<T> { @Override public boolean add(IExpr<T> expr) { if (left != null && expr instanceof BaseConditionalCombinationExpr) return false; boolean added = super.add(expr); if (added) return true; boolean canAddToRight = right.add(expr); if (canAddToRight) return true; boolean canRightAddToExpr = expr.add(right); if (canRightAddToExpr) { right = expr; return true; } return false; } @Override
public Object evaluate(T t) throws QueryException
Adipa-G/joquery
src/joquery/core/collection/FilterImpl.java
// Path: src/joquery/Filter.java // public interface Filter<T> extends Query<T, Filter<T>> // { // T first() throws QueryException; // // T last() throws QueryException; // // Collection<T> list() throws QueryException; // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.Filter; import joquery.core.QueryException; import java.util.Collection;
package joquery.core.collection; /** * User: Adipa * Date: 10/14/12 * Time: 11:20 AM */ public class FilterImpl<T> extends QueryImpl<T,Filter<T>> implements Filter<T> { @Override
// Path: src/joquery/Filter.java // public interface Filter<T> extends Query<T, Filter<T>> // { // T first() throws QueryException; // // T last() throws QueryException; // // Collection<T> list() throws QueryException; // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/core/collection/FilterImpl.java import joquery.Filter; import joquery.core.QueryException; import java.util.Collection; package joquery.core.collection; /** * User: Adipa * Date: 10/14/12 * Time: 11:20 AM */ public class FilterImpl<T> extends QueryImpl<T,Filter<T>> implements Filter<T> { @Override
public T first() throws QueryException
Adipa-G/joquery
src/joquery/core/collection/expr/condition/LtConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.core.QueryException;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class LtConditionalExpr<T> extends ConditionalExpr<T> { @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/core/collection/expr/condition/LtConditionalExpr.java import joquery.core.QueryException; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class LtConditionalExpr<T> extends ConditionalExpr<T> { @Override
public Object evaluate(T t) throws QueryException
Adipa-G/joquery
src/joquery/core/collection/expr/condition/InConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.core.QueryException; import java.lang.reflect.Array;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class InConditionalExpr<T> extends ConditionalExpr<T> { @SuppressWarnings("SimplifiableIfStatement") @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/core/collection/expr/condition/InConditionalExpr.java import joquery.core.QueryException; import java.lang.reflect.Array; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class InConditionalExpr<T> extends ConditionalExpr<T> { @SuppressWarnings("SimplifiableIfStatement") @Override
public Object evaluate(T t) throws QueryException
Adipa-G/joquery
src/joquery/core/collection/expr/condition/ConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // }
import joquery.core.QueryException; import joquery.core.QueryMode; import joquery.core.collection.expr.IExpr;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public abstract class ConditionalExpr<T> implements IExpr<T> { protected IExpr<T> left; protected IExpr<T> right; @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // Path: src/joquery/core/collection/expr/condition/ConditionalExpr.java import joquery.core.QueryException; import joquery.core.QueryMode; import joquery.core.collection.expr.IExpr; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public abstract class ConditionalExpr<T> implements IExpr<T> { protected IExpr<T> left; protected IExpr<T> right; @Override
public boolean supportsMode(QueryMode mode)
Adipa-G/joquery
src/joquery/core/collection/expr/condition/ConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // }
import joquery.core.QueryException; import joquery.core.QueryMode; import joquery.core.collection.expr.IExpr;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public abstract class ConditionalExpr<T> implements IExpr<T> { protected IExpr<T> left; protected IExpr<T> right; @Override public boolean supportsMode(QueryMode mode) { return mode == QueryMode.WHERE; } @Override public boolean add(IExpr<T> expr) { if (left == null) { left = expr; return true; } else if (right == null) { right = expr; return true; } return false; }
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // Path: src/joquery/core/collection/expr/condition/ConditionalExpr.java import joquery.core.QueryException; import joquery.core.QueryMode; import joquery.core.collection.expr.IExpr; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public abstract class ConditionalExpr<T> implements IExpr<T> { protected IExpr<T> left; protected IExpr<T> right; @Override public boolean supportsMode(QueryMode mode) { return mode == QueryMode.WHERE; } @Override public boolean add(IExpr<T> expr) { if (left == null) { left = expr; return true; } else if (right == null) { right = expr; return true; } return false; }
protected void validate() throws QueryException
Adipa-G/joquery
src-test/joquery/SortTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class SortTest { private static Collection<Dto> unsortedList; @BeforeClass public static void setup() { unsortedList = new ArrayList<>();
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/SortTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class SortTest { private static Collection<Dto> unsortedList; @BeforeClass public static void setup() { unsortedList = new ArrayList<>();
unsortedList.add(new Dto(1, "A"));
Adipa-G/joquery
src-test/joquery/SortTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class SortTest { private static Collection<Dto> unsortedList; @BeforeClass public static void setup() { unsortedList = new ArrayList<>(); unsortedList.add(new Dto(1, "A")); unsortedList.add(new Dto(3, "C")); unsortedList.add(new Dto(2, "C")); unsortedList.add(new Dto(4, "B")); unsortedList.add(new Dto(5, "E")); unsortedList.add(new Dto(5, "F")); unsortedList.add(new Dto(5, null)); } @AfterClass public static void cleanup() { unsortedList.clear(); unsortedList = null; } @Test
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/SortTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; import java.util.List; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class SortTest { private static Collection<Dto> unsortedList; @BeforeClass public static void setup() { unsortedList = new ArrayList<>(); unsortedList.add(new Dto(1, "A")); unsortedList.add(new Dto(3, "C")); unsortedList.add(new Dto(2, "C")); unsortedList.add(new Dto(4, "B")); unsortedList.add(new Dto(5, "E")); unsortedList.add(new Dto(5, "F")); unsortedList.add(new Dto(5, null)); } @AfterClass public static void cleanup() { unsortedList.clear(); unsortedList = null; } @Test
public void sort_EmptyList_ShouldReturnEmptyList() throws QueryException
Adipa-G/joquery
src/joquery/Projections.java
// Path: src/joquery/core/collection/project/Avg.java // public class Avg<T,U extends Number,V extends Number> implements IProject<T,U,V> // { // @Override // public V eval(Iterable<T> tList, Function<T, U> property) // { // U total = null; // int count = 0; // for (T t : tList) // { // total = add(property.apply(t),total); // count++; // } // // if (count == 0) // return (V)total; // // return devide(total,count); // } // // private U add(U u1,U u2) // { // if (u2 == null) // return u1; // if (u1 instanceof Integer) // return (U)(Integer)(((Integer)u1) + ((Integer)u2)); // if (u1 instanceof Long) // return (U)(Long)(((Long)u1) + ((Long)u2)); // return (U)(Double)(((Double)u1) + ((Double)u2)); // } // // private V devide(U u,int count) // { // if (u instanceof Integer) // return (V)(Integer)(((Integer)u) / count); // if (u instanceof Long) // return (V)(Long)(((Long)u) /count); // return (V)(Double)(((Double)u) / count); // } // } // // Path: src/joquery/core/collection/project/Sum.java // public class Sum<T,U extends Number> implements IProject<T,U,U> // { // @Override // public U eval(Iterable<T> tList, Function<T,U> property) // { // U total = null; // for (T t : tList) // { // total = add(property.apply(t),total); // } // return total; // } // // private U add(U u1,U u2) // { // if (u2 == null) // return u1; // if (u1 instanceof Integer) // return (U)(Integer)(((Integer)u1) + ((Integer)u2)); // if (u1 instanceof Long) // return (U)(Long)(((Long)u1) + ((Long)u2)); // return (U)(Double)(((Double)u1) + ((Double)u2)); // } // }
import joquery.core.collection.project.Avg; import joquery.core.collection.project.Sum;
package joquery; /** * Created by adipa_000 on 2/14/2015. */ public class Projections {
// Path: src/joquery/core/collection/project/Avg.java // public class Avg<T,U extends Number,V extends Number> implements IProject<T,U,V> // { // @Override // public V eval(Iterable<T> tList, Function<T, U> property) // { // U total = null; // int count = 0; // for (T t : tList) // { // total = add(property.apply(t),total); // count++; // } // // if (count == 0) // return (V)total; // // return devide(total,count); // } // // private U add(U u1,U u2) // { // if (u2 == null) // return u1; // if (u1 instanceof Integer) // return (U)(Integer)(((Integer)u1) + ((Integer)u2)); // if (u1 instanceof Long) // return (U)(Long)(((Long)u1) + ((Long)u2)); // return (U)(Double)(((Double)u1) + ((Double)u2)); // } // // private V devide(U u,int count) // { // if (u instanceof Integer) // return (V)(Integer)(((Integer)u) / count); // if (u instanceof Long) // return (V)(Long)(((Long)u) /count); // return (V)(Double)(((Double)u) / count); // } // } // // Path: src/joquery/core/collection/project/Sum.java // public class Sum<T,U extends Number> implements IProject<T,U,U> // { // @Override // public U eval(Iterable<T> tList, Function<T,U> property) // { // U total = null; // for (T t : tList) // { // total = add(property.apply(t),total); // } // return total; // } // // private U add(U u1,U u2) // { // if (u2 == null) // return u1; // if (u1 instanceof Integer) // return (U)(Integer)(((Integer)u1) + ((Integer)u2)); // if (u1 instanceof Long) // return (U)(Long)(((Long)u1) + ((Long)u2)); // return (U)(Double)(((Double)u1) + ((Double)u2)); // } // } // Path: src/joquery/Projections.java import joquery.core.collection.project.Avg; import joquery.core.collection.project.Sum; package joquery; /** * Created by adipa_000 on 2/14/2015. */ public class Projections {
public static <T,U extends Number> IProject<T,U,U> Sum()
Adipa-G/joquery
src/joquery/Projections.java
// Path: src/joquery/core/collection/project/Avg.java // public class Avg<T,U extends Number,V extends Number> implements IProject<T,U,V> // { // @Override // public V eval(Iterable<T> tList, Function<T, U> property) // { // U total = null; // int count = 0; // for (T t : tList) // { // total = add(property.apply(t),total); // count++; // } // // if (count == 0) // return (V)total; // // return devide(total,count); // } // // private U add(U u1,U u2) // { // if (u2 == null) // return u1; // if (u1 instanceof Integer) // return (U)(Integer)(((Integer)u1) + ((Integer)u2)); // if (u1 instanceof Long) // return (U)(Long)(((Long)u1) + ((Long)u2)); // return (U)(Double)(((Double)u1) + ((Double)u2)); // } // // private V devide(U u,int count) // { // if (u instanceof Integer) // return (V)(Integer)(((Integer)u) / count); // if (u instanceof Long) // return (V)(Long)(((Long)u) /count); // return (V)(Double)(((Double)u) / count); // } // } // // Path: src/joquery/core/collection/project/Sum.java // public class Sum<T,U extends Number> implements IProject<T,U,U> // { // @Override // public U eval(Iterable<T> tList, Function<T,U> property) // { // U total = null; // for (T t : tList) // { // total = add(property.apply(t),total); // } // return total; // } // // private U add(U u1,U u2) // { // if (u2 == null) // return u1; // if (u1 instanceof Integer) // return (U)(Integer)(((Integer)u1) + ((Integer)u2)); // if (u1 instanceof Long) // return (U)(Long)(((Long)u1) + ((Long)u2)); // return (U)(Double)(((Double)u1) + ((Double)u2)); // } // }
import joquery.core.collection.project.Avg; import joquery.core.collection.project.Sum;
package joquery; /** * Created by adipa_000 on 2/14/2015. */ public class Projections { public static <T,U extends Number> IProject<T,U,U> Sum() { return new Sum<T,U>(); }
// Path: src/joquery/core/collection/project/Avg.java // public class Avg<T,U extends Number,V extends Number> implements IProject<T,U,V> // { // @Override // public V eval(Iterable<T> tList, Function<T, U> property) // { // U total = null; // int count = 0; // for (T t : tList) // { // total = add(property.apply(t),total); // count++; // } // // if (count == 0) // return (V)total; // // return devide(total,count); // } // // private U add(U u1,U u2) // { // if (u2 == null) // return u1; // if (u1 instanceof Integer) // return (U)(Integer)(((Integer)u1) + ((Integer)u2)); // if (u1 instanceof Long) // return (U)(Long)(((Long)u1) + ((Long)u2)); // return (U)(Double)(((Double)u1) + ((Double)u2)); // } // // private V devide(U u,int count) // { // if (u instanceof Integer) // return (V)(Integer)(((Integer)u) / count); // if (u instanceof Long) // return (V)(Long)(((Long)u) /count); // return (V)(Double)(((Double)u) / count); // } // } // // Path: src/joquery/core/collection/project/Sum.java // public class Sum<T,U extends Number> implements IProject<T,U,U> // { // @Override // public U eval(Iterable<T> tList, Function<T,U> property) // { // U total = null; // for (T t : tList) // { // total = add(property.apply(t),total); // } // return total; // } // // private U add(U u1,U u2) // { // if (u2 == null) // return u1; // if (u1 instanceof Integer) // return (U)(Integer)(((Integer)u1) + ((Integer)u2)); // if (u1 instanceof Long) // return (U)(Long)(((Long)u1) + ((Long)u2)); // return (U)(Double)(((Double)u1) + ((Double)u2)); // } // } // Path: src/joquery/Projections.java import joquery.core.collection.project.Avg; import joquery.core.collection.project.Sum; package joquery; /** * Created by adipa_000 on 2/14/2015. */ public class Projections { public static <T,U extends Number> IProject<T,U,U> Sum() { return new Sum<T,U>(); }
public static <T,U extends Number,V extends Number> IProject<T,U,V> Avg()
Adipa-G/joquery
src/joquery/core/collection/expr/condition/GeConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.core.QueryException;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class GeConditionalExpr<T> extends ConditionalExpr<T> { @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/core/collection/expr/condition/GeConditionalExpr.java import joquery.core.QueryException; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class GeConditionalExpr<T> extends ConditionalExpr<T> { @Override
public Object evaluate(T t) throws QueryException
Adipa-G/joquery
src/joquery/core/collection/expr/condition/LeConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.core.QueryException;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class LeConditionalExpr<T> extends ConditionalExpr<T> { @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/core/collection/expr/condition/LeConditionalExpr.java import joquery.core.QueryException; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class LeConditionalExpr<T> extends ConditionalExpr<T> { @Override
public Object evaluate(T t) throws QueryException
Adipa-G/joquery
src/joquery/core/collection/expr/ReflectionExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // }
import joquery.core.QueryException; import joquery.core.QueryMode; import java.lang.reflect.Field; import java.lang.reflect.Method;
package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ReflectionExpr<T> implements IExpr<T> { private String property; private Method method; private Field field; public ReflectionExpr(String property) { this.property = property; } @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // Path: src/joquery/core/collection/expr/ReflectionExpr.java import joquery.core.QueryException; import joquery.core.QueryMode; import java.lang.reflect.Field; import java.lang.reflect.Method; package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ReflectionExpr<T> implements IExpr<T> { private String property; private Method method; private Field field; public ReflectionExpr(String property) { this.property = property; } @Override
public boolean supportsMode(QueryMode mode)
Adipa-G/joquery
src/joquery/core/collection/expr/ReflectionExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // }
import joquery.core.QueryException; import joquery.core.QueryMode; import java.lang.reflect.Field; import java.lang.reflect.Method;
package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ReflectionExpr<T> implements IExpr<T> { private String property; private Method method; private Field field; public ReflectionExpr(String property) { this.property = property; } @Override public boolean supportsMode(QueryMode mode) { return mode == QueryMode.SELECT || mode == QueryMode.WHERE || mode == QueryMode.SORT; } @Override public boolean add(IExpr<T> expr) { return false; } @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // Path: src/joquery/core/collection/expr/ReflectionExpr.java import joquery.core.QueryException; import joquery.core.QueryMode; import java.lang.reflect.Field; import java.lang.reflect.Method; package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ReflectionExpr<T> implements IExpr<T> { private String property; private Method method; private Field field; public ReflectionExpr(String property) { this.property = property; } @Override public boolean supportsMode(QueryMode mode) { return mode == QueryMode.SELECT || mode == QueryMode.WHERE || mode == QueryMode.SORT; } @Override public boolean add(IExpr<T> expr) { return false; } @Override
public Object evaluate(T t) throws QueryException
Adipa-G/joquery
src-test/joquery/SelectionQueryTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class SelectionQueryTest { private static Collection<SrcDto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new SrcDto(1)); testList.add(new SrcDto(2)); testList.add(new SrcDto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/SelectionQueryTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class SelectionQueryTest { private static Collection<SrcDto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new SrcDto(1)); testList.add(new SrcDto(2)); testList.add(new SrcDto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test
public void first_WithNoFilter_ShouldReturnAll() throws QueryException
Adipa-G/joquery
src-test/joquery/SelectionQueryTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class SelectionQueryTest { private static Collection<SrcDto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new SrcDto(1)); testList.add(new SrcDto(2)); testList.add(new SrcDto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test public void first_WithNoFilter_ShouldReturnAll() throws QueryException { SrcDto first = CQ.<SrcDto,SrcDto>query(testList).first();
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/SelectionQueryTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class SelectionQueryTest { private static Collection<SrcDto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new SrcDto(1)); testList.add(new SrcDto(2)); testList.add(new SrcDto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test public void first_WithNoFilter_ShouldReturnAll() throws QueryException { SrcDto first = CQ.<SrcDto,SrcDto>query(testList).first();
A.exp(testList.iterator().next()).act(first);
Adipa-G/joquery
src/joquery/Filter.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.core.QueryException; import java.util.Collection;
package joquery; /** * User: Adipa * Date: 10/14/12 * Time: 11:19 AM */ public interface Filter<T> extends Query<T, Filter<T>> {
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/Filter.java import joquery.core.QueryException; import java.util.Collection; package joquery; /** * User: Adipa * Date: 10/14/12 * Time: 11:19 AM */ public interface Filter<T> extends Query<T, Filter<T>> {
T first() throws QueryException;
Adipa-G/joquery
src/joquery/ResultTransformedQuery.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.core.QueryException; import java.util.Collection; import java.util.function.Function;
package joquery; /** * User: Adipa * Date: 10/28/12 * Time: 12:43 PM */ public interface ResultTransformedQuery<T,U,W extends ResultTransformedQuery<T,U,W>> extends Query<T,W> {
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/ResultTransformedQuery.java import joquery.core.QueryException; import java.util.Collection; import java.util.function.Function; package joquery; /** * User: Adipa * Date: 10/28/12 * Time: 12:43 PM */ public interface ResultTransformedQuery<T,U,W extends ResultTransformedQuery<T,U,W>> extends Query<T,W> {
U first() throws QueryException;
Adipa-G/joquery
src-test/joquery/ExpressionTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ExpressionTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/ExpressionTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ExpressionTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test
public void whereExpression_Exec_ShouldFilter() throws QueryException
Adipa-G/joquery
src-test/joquery/ExpressionTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection;
@Test public void whereExpression_PropertyOnlyWithField_ShouldFilter() throws QueryException { Filter<Dto> query = CQ.<Dto>filter() .from(testList) .where() .property("id2") .eq() .value(1); Collection<Dto> filtered = query.list(); assertResult(filtered, new int[]{1}); } @Test public void whereExpression_PropertyOnlyWithGetter_ShouldFilter() throws QueryException { Filter<Dto> query = CQ.<Dto>filter() .from(testList) .where() .property("id3") .eq() .value(1); Collection<Dto> filtered = query.list(); assertResult(filtered, new int[]{1}); } private static void assertResult(Collection<Dto> list,int[] ids) {
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/ExpressionTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; @Test public void whereExpression_PropertyOnlyWithField_ShouldFilter() throws QueryException { Filter<Dto> query = CQ.<Dto>filter() .from(testList) .where() .property("id2") .eq() .value(1); Collection<Dto> filtered = query.list(); assertResult(filtered, new int[]{1}); } @Test public void whereExpression_PropertyOnlyWithGetter_ShouldFilter() throws QueryException { Filter<Dto> query = CQ.<Dto>filter() .from(testList) .where() .property("id3") .eq() .value(1); Collection<Dto> filtered = query.list(); assertResult(filtered, new int[]{1}); } private static void assertResult(Collection<Dto> list,int[] ids) {
A.exp(ids.length).act(list.size(),String.format("Expected items are not retrieved"));
Adipa-G/joquery
src/joquery/core/collection/expr/condition/BetweenConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // }
import joquery.core.QueryException; import joquery.core.collection.expr.IExpr;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class BetweenConditionalExpr<T> extends ConditionalExpr<T> {
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // Path: src/joquery/core/collection/expr/condition/BetweenConditionalExpr.java import joquery.core.QueryException; import joquery.core.collection.expr.IExpr; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class BetweenConditionalExpr<T> extends ConditionalExpr<T> {
protected IExpr<T> right2;
Adipa-G/joquery
src/joquery/core/collection/expr/condition/BetweenConditionalExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // }
import joquery.core.QueryException; import joquery.core.collection.expr.IExpr;
package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class BetweenConditionalExpr<T> extends ConditionalExpr<T> { protected IExpr<T> right2; @Override public boolean add(IExpr<T> expr) { boolean result = super.add(expr); if (!result && right2 == null) { right2 = expr; return true; } return result; } @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // Path: src/joquery/core/collection/expr/condition/BetweenConditionalExpr.java import joquery.core.QueryException; import joquery.core.collection.expr.IExpr; package joquery.core.collection.expr.condition; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class BetweenConditionalExpr<T> extends ConditionalExpr<T> { protected IExpr<T> right2; @Override public boolean add(IExpr<T> expr) { boolean result = super.add(expr); if (!result && right2 == null) { right2 = expr; return true; } return result; } @Override
protected void validate() throws QueryException
Adipa-G/joquery
src/joquery/core/collection/expr/FunctionExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // }
import joquery.core.QueryException; import joquery.core.QueryMode; import java.util.function.Function;
package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class FunctionExpr<T> implements IExpr<T> { private Function<T,?> function; public FunctionExpr(Function<T,?> function) { this.function = function; } @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // Path: src/joquery/core/collection/expr/FunctionExpr.java import joquery.core.QueryException; import joquery.core.QueryMode; import java.util.function.Function; package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class FunctionExpr<T> implements IExpr<T> { private Function<T,?> function; public FunctionExpr(Function<T,?> function) { this.function = function; } @Override
public boolean supportsMode(QueryMode mode)
Adipa-G/joquery
src/joquery/core/collection/expr/FunctionExpr.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // }
import joquery.core.QueryException; import joquery.core.QueryMode; import java.util.function.Function;
package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class FunctionExpr<T> implements IExpr<T> { private Function<T,?> function; public FunctionExpr(Function<T,?> function) { this.function = function; } @Override public boolean supportsMode(QueryMode mode) { return mode == QueryMode.SELECT || mode == QueryMode.WHERE || mode == QueryMode.SORT; } @Override public boolean add(IExpr<T> expr) { return false; } @Override
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/QueryMode.java // public enum QueryMode // { // SELECT, // FROM, // WHERE, // SORT // } // Path: src/joquery/core/collection/expr/FunctionExpr.java import joquery.core.QueryException; import joquery.core.QueryMode; import java.util.function.Function; package joquery.core.collection.expr; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class FunctionExpr<T> implements IExpr<T> { private Function<T,?> function; public FunctionExpr(Function<T,?> function) { this.function = function; } @Override public boolean supportsMode(QueryMode mode) { return mode == QueryMode.SELECT || mode == QueryMode.WHERE || mode == QueryMode.SORT; } @Override public boolean add(IExpr<T> expr) { return false; } @Override
public Object evaluate(T t) throws QueryException
Adipa-G/joquery
src/joquery/core/collection/GroupQueryImpl.java
// Path: src/joquery/GroupQuery.java // public interface GroupQuery<Key,U> extends Query<Grouping<Key,U>,GroupQuery<Key,U>> // { // Collection<Grouping<Key,U>> list() throws QueryException; // // GroupQuery<Key,U> groupBy(Function<U,?> by); // // GroupQuery<Key,U> groupBy(String by); // } // // Path: src/joquery/Grouping.java // public class Grouping<T,U> // { // private T key; // private Collection<U> values; // // public Grouping(T key) // { // this.key = key; // values = new ArrayList<>(); // } // // public void Add(U u) // { // values.add(u); // } // // public T getKey() // { // return key; // } // // public Collection<U> getValues() // { // return values; // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/FunctionExpr.java // public class FunctionExpr<T> implements IExpr<T> // { // private Function<T,?> function; // // public FunctionExpr(Function<T,?> function) // { // this.function = function; // } // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.SELECT // || mode == QueryMode.WHERE // || mode == QueryMode.SORT; // } // // @Override // public boolean add(IExpr<T> expr) // { // return false; // } // // @Override // public Object evaluate(T t) throws QueryException // { // try // { // return function.apply(t); // } // catch (Exception ex) // { // throw new QueryException(String.format("Unable retrieve value for %s",function)); // } // // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // // Path: src/joquery/core/collection/expr/ReflectionExpr.java // public class ReflectionExpr<T> implements IExpr<T> // { // private String property; // private Method method; // private Field field; // // public ReflectionExpr(String property) // { // this.property = property; // } // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.SELECT // || mode == QueryMode.WHERE // || mode == QueryMode.SORT; // } // // @Override // public boolean add(IExpr<T> expr) // { // return false; // } // // @Override // public Object evaluate(T t) throws QueryException // { // init(t); // return getValue(t); // } // // private void init(T t) throws QueryException // { // if (field != null || method != null) // return; // // try // { // initFieldIfNot(t); // } // catch (Exception ignored) // { // } // // try // { // initMethodIfNot(t); // } // catch (Exception ignored) // { // } // // if (!setAccessibleIfNeeded()) // { // throw new QueryException(String.format("No property or getters can't be found for property %s",property)); // } // } // // private boolean setAccessibleIfNeeded() // { // if (field != null // && method == null // && !field.isAccessible()) // { // field.setAccessible(true); // return true; // } // else if (method != null // && !method.isAccessible()) // { // method.setAccessible(true); // return true; // } // return false; // } // // private void initFieldIfNot(T t) throws Exception // { // field = t.getClass().getDeclaredField(property); // } // // private void initMethodIfNot(T t) throws Exception // { // String camelCase = property.substring(0,1).toUpperCase() + property.substring(1); // try // { // method = t.getClass().getMethod("get" + camelCase); // } // catch (NoSuchMethodException e) // { // method = t.getClass().getMethod("is" + camelCase); // } // } // // private Object getValue(T t) throws QueryException // { // try // { // if (method != null) // return method.invoke(t); // else if (field != null) // return field.get(t); // return null; // } // catch (Exception ex) // { // throw new QueryException(String.format("Unable retrieve value for %s",property)); // } // } // }
import joquery.GroupQuery; import joquery.Grouping; import joquery.core.QueryException; import joquery.core.collection.expr.FunctionExpr; import joquery.core.collection.expr.IExpr; import joquery.core.collection.expr.ReflectionExpr; import java.util.*; import java.util.function.Function;
package joquery.core.collection; /** * User: Adipa * Date: 11/10/12 * Time: 7:05 PM */ public class GroupQueryImpl<Key,U> extends QueryImpl<Grouping<Key,U>,GroupQuery<Key,U>> implements GroupQuery<Key,U> { private Collection<U> itemsToGroup;
// Path: src/joquery/GroupQuery.java // public interface GroupQuery<Key,U> extends Query<Grouping<Key,U>,GroupQuery<Key,U>> // { // Collection<Grouping<Key,U>> list() throws QueryException; // // GroupQuery<Key,U> groupBy(Function<U,?> by); // // GroupQuery<Key,U> groupBy(String by); // } // // Path: src/joquery/Grouping.java // public class Grouping<T,U> // { // private T key; // private Collection<U> values; // // public Grouping(T key) // { // this.key = key; // values = new ArrayList<>(); // } // // public void Add(U u) // { // values.add(u); // } // // public T getKey() // { // return key; // } // // public Collection<U> getValues() // { // return values; // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/FunctionExpr.java // public class FunctionExpr<T> implements IExpr<T> // { // private Function<T,?> function; // // public FunctionExpr(Function<T,?> function) // { // this.function = function; // } // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.SELECT // || mode == QueryMode.WHERE // || mode == QueryMode.SORT; // } // // @Override // public boolean add(IExpr<T> expr) // { // return false; // } // // @Override // public Object evaluate(T t) throws QueryException // { // try // { // return function.apply(t); // } // catch (Exception ex) // { // throw new QueryException(String.format("Unable retrieve value for %s",function)); // } // // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // // Path: src/joquery/core/collection/expr/ReflectionExpr.java // public class ReflectionExpr<T> implements IExpr<T> // { // private String property; // private Method method; // private Field field; // // public ReflectionExpr(String property) // { // this.property = property; // } // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.SELECT // || mode == QueryMode.WHERE // || mode == QueryMode.SORT; // } // // @Override // public boolean add(IExpr<T> expr) // { // return false; // } // // @Override // public Object evaluate(T t) throws QueryException // { // init(t); // return getValue(t); // } // // private void init(T t) throws QueryException // { // if (field != null || method != null) // return; // // try // { // initFieldIfNot(t); // } // catch (Exception ignored) // { // } // // try // { // initMethodIfNot(t); // } // catch (Exception ignored) // { // } // // if (!setAccessibleIfNeeded()) // { // throw new QueryException(String.format("No property or getters can't be found for property %s",property)); // } // } // // private boolean setAccessibleIfNeeded() // { // if (field != null // && method == null // && !field.isAccessible()) // { // field.setAccessible(true); // return true; // } // else if (method != null // && !method.isAccessible()) // { // method.setAccessible(true); // return true; // } // return false; // } // // private void initFieldIfNot(T t) throws Exception // { // field = t.getClass().getDeclaredField(property); // } // // private void initMethodIfNot(T t) throws Exception // { // String camelCase = property.substring(0,1).toUpperCase() + property.substring(1); // try // { // method = t.getClass().getMethod("get" + camelCase); // } // catch (NoSuchMethodException e) // { // method = t.getClass().getMethod("is" + camelCase); // } // } // // private Object getValue(T t) throws QueryException // { // try // { // if (method != null) // return method.invoke(t); // else if (field != null) // return field.get(t); // return null; // } // catch (Exception ex) // { // throw new QueryException(String.format("Unable retrieve value for %s",property)); // } // } // } // Path: src/joquery/core/collection/GroupQueryImpl.java import joquery.GroupQuery; import joquery.Grouping; import joquery.core.QueryException; import joquery.core.collection.expr.FunctionExpr; import joquery.core.collection.expr.IExpr; import joquery.core.collection.expr.ReflectionExpr; import java.util.*; import java.util.function.Function; package joquery.core.collection; /** * User: Adipa * Date: 11/10/12 * Time: 7:05 PM */ public class GroupQueryImpl<Key,U> extends QueryImpl<Grouping<Key,U>,GroupQuery<Key,U>> implements GroupQuery<Key,U> { private Collection<U> itemsToGroup;
private List<IExpr<U>> groupExpressions;
Adipa-G/joquery
src/joquery/core/collection/GroupQueryImpl.java
// Path: src/joquery/GroupQuery.java // public interface GroupQuery<Key,U> extends Query<Grouping<Key,U>,GroupQuery<Key,U>> // { // Collection<Grouping<Key,U>> list() throws QueryException; // // GroupQuery<Key,U> groupBy(Function<U,?> by); // // GroupQuery<Key,U> groupBy(String by); // } // // Path: src/joquery/Grouping.java // public class Grouping<T,U> // { // private T key; // private Collection<U> values; // // public Grouping(T key) // { // this.key = key; // values = new ArrayList<>(); // } // // public void Add(U u) // { // values.add(u); // } // // public T getKey() // { // return key; // } // // public Collection<U> getValues() // { // return values; // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/FunctionExpr.java // public class FunctionExpr<T> implements IExpr<T> // { // private Function<T,?> function; // // public FunctionExpr(Function<T,?> function) // { // this.function = function; // } // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.SELECT // || mode == QueryMode.WHERE // || mode == QueryMode.SORT; // } // // @Override // public boolean add(IExpr<T> expr) // { // return false; // } // // @Override // public Object evaluate(T t) throws QueryException // { // try // { // return function.apply(t); // } // catch (Exception ex) // { // throw new QueryException(String.format("Unable retrieve value for %s",function)); // } // // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // // Path: src/joquery/core/collection/expr/ReflectionExpr.java // public class ReflectionExpr<T> implements IExpr<T> // { // private String property; // private Method method; // private Field field; // // public ReflectionExpr(String property) // { // this.property = property; // } // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.SELECT // || mode == QueryMode.WHERE // || mode == QueryMode.SORT; // } // // @Override // public boolean add(IExpr<T> expr) // { // return false; // } // // @Override // public Object evaluate(T t) throws QueryException // { // init(t); // return getValue(t); // } // // private void init(T t) throws QueryException // { // if (field != null || method != null) // return; // // try // { // initFieldIfNot(t); // } // catch (Exception ignored) // { // } // // try // { // initMethodIfNot(t); // } // catch (Exception ignored) // { // } // // if (!setAccessibleIfNeeded()) // { // throw new QueryException(String.format("No property or getters can't be found for property %s",property)); // } // } // // private boolean setAccessibleIfNeeded() // { // if (field != null // && method == null // && !field.isAccessible()) // { // field.setAccessible(true); // return true; // } // else if (method != null // && !method.isAccessible()) // { // method.setAccessible(true); // return true; // } // return false; // } // // private void initFieldIfNot(T t) throws Exception // { // field = t.getClass().getDeclaredField(property); // } // // private void initMethodIfNot(T t) throws Exception // { // String camelCase = property.substring(0,1).toUpperCase() + property.substring(1); // try // { // method = t.getClass().getMethod("get" + camelCase); // } // catch (NoSuchMethodException e) // { // method = t.getClass().getMethod("is" + camelCase); // } // } // // private Object getValue(T t) throws QueryException // { // try // { // if (method != null) // return method.invoke(t); // else if (field != null) // return field.get(t); // return null; // } // catch (Exception ex) // { // throw new QueryException(String.format("Unable retrieve value for %s",property)); // } // } // }
import joquery.GroupQuery; import joquery.Grouping; import joquery.core.QueryException; import joquery.core.collection.expr.FunctionExpr; import joquery.core.collection.expr.IExpr; import joquery.core.collection.expr.ReflectionExpr; import java.util.*; import java.util.function.Function;
package joquery.core.collection; /** * User: Adipa * Date: 11/10/12 * Time: 7:05 PM */ public class GroupQueryImpl<Key,U> extends QueryImpl<Grouping<Key,U>,GroupQuery<Key,U>> implements GroupQuery<Key,U> { private Collection<U> itemsToGroup; private List<IExpr<U>> groupExpressions; public GroupQueryImpl(Collection<U> itemsToGroup) { this.itemsToGroup = itemsToGroup; groupExpressions = new ArrayList<>(); } @Override public GroupQuery<Key, U> groupBy(Function<U, ?> by) {
// Path: src/joquery/GroupQuery.java // public interface GroupQuery<Key,U> extends Query<Grouping<Key,U>,GroupQuery<Key,U>> // { // Collection<Grouping<Key,U>> list() throws QueryException; // // GroupQuery<Key,U> groupBy(Function<U,?> by); // // GroupQuery<Key,U> groupBy(String by); // } // // Path: src/joquery/Grouping.java // public class Grouping<T,U> // { // private T key; // private Collection<U> values; // // public Grouping(T key) // { // this.key = key; // values = new ArrayList<>(); // } // // public void Add(U u) // { // values.add(u); // } // // public T getKey() // { // return key; // } // // public Collection<U> getValues() // { // return values; // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // // Path: src/joquery/core/collection/expr/FunctionExpr.java // public class FunctionExpr<T> implements IExpr<T> // { // private Function<T,?> function; // // public FunctionExpr(Function<T,?> function) // { // this.function = function; // } // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.SELECT // || mode == QueryMode.WHERE // || mode == QueryMode.SORT; // } // // @Override // public boolean add(IExpr<T> expr) // { // return false; // } // // @Override // public Object evaluate(T t) throws QueryException // { // try // { // return function.apply(t); // } // catch (Exception ex) // { // throw new QueryException(String.format("Unable retrieve value for %s",function)); // } // // } // } // // Path: src/joquery/core/collection/expr/IExpr.java // public interface IExpr<T> // { // boolean supportsMode(QueryMode mode); // // boolean add(IExpr<T> expr); // // Object evaluate(T t) throws QueryException; // } // // Path: src/joquery/core/collection/expr/ReflectionExpr.java // public class ReflectionExpr<T> implements IExpr<T> // { // private String property; // private Method method; // private Field field; // // public ReflectionExpr(String property) // { // this.property = property; // } // // @Override // public boolean supportsMode(QueryMode mode) // { // return mode == QueryMode.SELECT // || mode == QueryMode.WHERE // || mode == QueryMode.SORT; // } // // @Override // public boolean add(IExpr<T> expr) // { // return false; // } // // @Override // public Object evaluate(T t) throws QueryException // { // init(t); // return getValue(t); // } // // private void init(T t) throws QueryException // { // if (field != null || method != null) // return; // // try // { // initFieldIfNot(t); // } // catch (Exception ignored) // { // } // // try // { // initMethodIfNot(t); // } // catch (Exception ignored) // { // } // // if (!setAccessibleIfNeeded()) // { // throw new QueryException(String.format("No property or getters can't be found for property %s",property)); // } // } // // private boolean setAccessibleIfNeeded() // { // if (field != null // && method == null // && !field.isAccessible()) // { // field.setAccessible(true); // return true; // } // else if (method != null // && !method.isAccessible()) // { // method.setAccessible(true); // return true; // } // return false; // } // // private void initFieldIfNot(T t) throws Exception // { // field = t.getClass().getDeclaredField(property); // } // // private void initMethodIfNot(T t) throws Exception // { // String camelCase = property.substring(0,1).toUpperCase() + property.substring(1); // try // { // method = t.getClass().getMethod("get" + camelCase); // } // catch (NoSuchMethodException e) // { // method = t.getClass().getMethod("is" + camelCase); // } // } // // private Object getValue(T t) throws QueryException // { // try // { // if (method != null) // return method.invoke(t); // else if (field != null) // return field.get(t); // return null; // } // catch (Exception ex) // { // throw new QueryException(String.format("Unable retrieve value for %s",property)); // } // } // } // Path: src/joquery/core/collection/GroupQueryImpl.java import joquery.GroupQuery; import joquery.Grouping; import joquery.core.QueryException; import joquery.core.collection.expr.FunctionExpr; import joquery.core.collection.expr.IExpr; import joquery.core.collection.expr.ReflectionExpr; import java.util.*; import java.util.function.Function; package joquery.core.collection; /** * User: Adipa * Date: 11/10/12 * Time: 7:05 PM */ public class GroupQueryImpl<Key,U> extends QueryImpl<Grouping<Key,U>,GroupQuery<Key,U>> implements GroupQuery<Key,U> { private Collection<U> itemsToGroup; private List<IExpr<U>> groupExpressions; public GroupQueryImpl(Collection<U> itemsToGroup) { this.itemsToGroup = itemsToGroup; groupExpressions = new ArrayList<>(); } @Override public GroupQuery<Key, U> groupBy(Function<U, ?> by) {
groupExpressions.add(new FunctionExpr<>(by));
Adipa-G/joquery
src-test/joquery/ProjectionTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ProjectionTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/ProjectionTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ProjectionTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test
public void projection_Sum_ShouldSum() throws QueryException
Adipa-G/joquery
src-test/joquery/ProjectionTest.java
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection;
package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ProjectionTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test public void projection_Sum_ShouldSum() throws QueryException { Integer result = CQ.<Dto,Integer>query() .from(testList) .project(Projections.<Dto,Integer>Sum(),Dto::getId);
// Path: src-test/assertions/A.java // public class A<T> // { // private T expected; // // public A(T expected) // { // this.expected = expected; // } // // public void act(T actual) // { // compare(expected,actual,""); // } // // public void act(T actual,String message) // { // compare(expected,actual,message); // } // // private void compare(T exp,T act,String message) // { // if (exp instanceof Collection) // { // Collection expCollection = (Collection) exp; // Collection actCollection = (Collection) act; // compareCollection(expCollection,actCollection,message); // } // else // { // Assert.assertEquals(message,exp,act); // } // } // // private <U extends Collection> void compareCollection(U exp,U act,String message) // { // Assert.assertEquals(message + " -> Collection sizes does not match",exp.size(),act.size()); // // for (Object e : exp) // { // boolean found = false; // for (Object a : act) // { // if (e.equals(a)) // { // found = true; // break; // } // } // if (!found) // Assert.fail(String.format(message + " -> expected object %s does not exists in actual object list",e)); // } // } // // public static <T> A<T> exp(T t) // { // return new A<>(t); // } // } // // Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src-test/joquery/ProjectionTest.java import assertions.A; import joquery.core.QueryException; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; import java.util.ArrayList; import java.util.Collection; package joquery; /** * User: Adipa * Date: 10/6/12 * Time: 9:31 PM */ public class ProjectionTest { private static Collection<Dto> testList; @BeforeClass public static void setup() { testList = new ArrayList<>(); testList.add(new Dto(1)); testList.add(new Dto(2)); testList.add(new Dto(3)); } @AfterClass public static void cleanup() { testList.clear(); testList = null; } @Test public void projection_Sum_ShouldSum() throws QueryException { Integer result = CQ.<Dto,Integer>query() .from(testList) .project(Projections.<Dto,Integer>Sum(),Dto::getId);
A.exp(6).act(result);
Adipa-G/joquery
src/joquery/GroupQuery.java
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // }
import joquery.core.QueryException; import java.util.Collection; import java.util.function.Function;
package joquery; /** * User: Adipa * Date: 10/14/12 * Time: 11:19 AM */ public interface GroupQuery<Key,U> extends Query<Grouping<Key,U>,GroupQuery<Key,U>> {
// Path: src/joquery/core/QueryException.java // public class QueryException extends Exception // { // public QueryException(String message) // { // super(message); // } // // public QueryException(String message, Throwable cause) // { // super(message, cause); // } // } // Path: src/joquery/GroupQuery.java import joquery.core.QueryException; import java.util.Collection; import java.util.function.Function; package joquery; /** * User: Adipa * Date: 10/14/12 * Time: 11:19 AM */ public interface GroupQuery<Key,U> extends Query<Grouping<Key,U>,GroupQuery<Key,U>> {
Collection<Grouping<Key,U>> list() throws QueryException;
jbossas/jboss-vfs
src/main/java/org/jboss/vfs/util/PathTokenizer.java
// Path: src/main/java/org/jboss/vfs/VFSMessages.java // @MessageBundle(projectCode = "VFS") // public interface VFSMessages { // /** // * The messages // */ // VFSMessages MESSAGES = Messages.getBundle(VFSMessages.class); // // @Message(id = 10, value = "Can't set up temp file provider") // RuntimeException cantSetupTempFileProvider(@Cause Throwable cause); // // @Message(id = 11, value = "Temp directory closed") // IOException tempDirectoryClosed(); // // @Message(id = 12, value = "Temp file provider closed") // IOException tempFileProviderClosed(); // // // Retired // // @Message(id = 13, value = "Failed to clean existing content for temp file provider of type %s") // // IOException failedToCleanExistingContentForTempFileProvider(String providerType); // // @Message(id = 14, value = "Could not create directory for root '%s' (prefix '%s', suffix '%s') after %d attempts") // IOException couldNotCreateDirectoryForRoot(File root, String prefix, String suffix, int retries); // // @Message(id = 15, value = "Could not create directory for original name '%s' after %d attempts") // IOException couldNotCreateDirectory(String originalName, int retries); // // @Message(id = 16, value = "Root filesystem already mounted") // IOException rootFileSystemAlreadyMounted(); // // @Message(id = 17, value = "Filesystem already mounted at mount point \"%s\"") // IOException fileSystemAlreadyMountedAtMountPoint(VirtualFile mountPoint); // // @Message(id = 18, value = "Stream is closed") // IOException streamIsClosed(); // // @Message(id = 19, value = "Not a file: '%s'") // IOException notAFile(String path); // // @Message(id = 20, value = "Remote host access not supported for URLs of type '%s'") // IOException remoteHostAccessNotSupportedForUrls(String protocol); // // @Message(id = 21, value = "%s must not be null") // IllegalArgumentException nullArgument(String name); // // @Message(id = 22, value = "Null or empty %s") // IllegalArgumentException nullOrEmpty(String name); // // @Message(id = 23, value = "Given parent (%s) is not an ancestor of this virtual file") // IllegalArgumentException parentIsNotAncestor(VirtualFile parent); // // @Message(id = 24, value = "Problems creating new directory: %s") // IllegalArgumentException problemCreatingNewDirectory(VirtualFile targetChild); // // @Message(id = 25, value = "Invalid Win32 path: %s") // IllegalArgumentException invalidWin32Path(String path); // // @Message(id = 26, value = "Cannot decode: %s [%s]") // IllegalArgumentException cannotDecode(String path, String encoding, @Cause Exception e); // // @Message(id = 27, value = "Invalid jar signature %s should be %s") // IOException invalidJarSignature(String bytes, String expectedHeader); // // @Message(id = 28, value = "Invalid actions string: %s") // IllegalArgumentException invalidActionsString(String actions); // // @Message(id = 29, value = "The totalBufferLength must be larger than: %s") // IllegalArgumentException bufferMustBeLargerThan(int minimumBufferLength); // // @Message(id = 30, value = "Buffer does not have enough capacity") // IllegalArgumentException bufferDoesntHaveEnoughCapacity(); // // @Message(id = 31, value = "The preconfigured attributes are immutable") // IllegalStateException preconfiguredAttributesAreImmutable(); // // @Message(id = 32, value = ".. on root path") // IllegalStateException onRootPath(); // }
import org.jboss.vfs.VFSMessages; import static org.jboss.vfs.VFSMessages.MESSAGES; import java.util.ArrayList; import java.util.List;
/** * Get the remaining path from some tokens * * @param tokens the tokens * @param i the current location * @return the remaining path * @throws IllegalArgumentException for null tokens or i is out of range */ public static String getRemainingPath(List<String> tokens, int i) { if (tokens == null) { throw MESSAGES.nullArgument("tokens"); } return getRemainingPath(tokens, i, tokens.size()); } /** * Apply any . or .. paths in the path param. * * @param path the path * @return simple path, containing no . or .. paths */ public static String applySpecialPaths(String path) throws IllegalArgumentException { List<String> tokens = getTokens(path); if (tokens == null) { return null; } int i = 0; for (int j = 0; j < tokens.size(); j++) { String token = tokens.get(j); if (isCurrentToken(token)) { continue; } else if (isReverseToken(token)) { i--; } else { tokens.set(i++, token); } if (i < 0) {
// Path: src/main/java/org/jboss/vfs/VFSMessages.java // @MessageBundle(projectCode = "VFS") // public interface VFSMessages { // /** // * The messages // */ // VFSMessages MESSAGES = Messages.getBundle(VFSMessages.class); // // @Message(id = 10, value = "Can't set up temp file provider") // RuntimeException cantSetupTempFileProvider(@Cause Throwable cause); // // @Message(id = 11, value = "Temp directory closed") // IOException tempDirectoryClosed(); // // @Message(id = 12, value = "Temp file provider closed") // IOException tempFileProviderClosed(); // // // Retired // // @Message(id = 13, value = "Failed to clean existing content for temp file provider of type %s") // // IOException failedToCleanExistingContentForTempFileProvider(String providerType); // // @Message(id = 14, value = "Could not create directory for root '%s' (prefix '%s', suffix '%s') after %d attempts") // IOException couldNotCreateDirectoryForRoot(File root, String prefix, String suffix, int retries); // // @Message(id = 15, value = "Could not create directory for original name '%s' after %d attempts") // IOException couldNotCreateDirectory(String originalName, int retries); // // @Message(id = 16, value = "Root filesystem already mounted") // IOException rootFileSystemAlreadyMounted(); // // @Message(id = 17, value = "Filesystem already mounted at mount point \"%s\"") // IOException fileSystemAlreadyMountedAtMountPoint(VirtualFile mountPoint); // // @Message(id = 18, value = "Stream is closed") // IOException streamIsClosed(); // // @Message(id = 19, value = "Not a file: '%s'") // IOException notAFile(String path); // // @Message(id = 20, value = "Remote host access not supported for URLs of type '%s'") // IOException remoteHostAccessNotSupportedForUrls(String protocol); // // @Message(id = 21, value = "%s must not be null") // IllegalArgumentException nullArgument(String name); // // @Message(id = 22, value = "Null or empty %s") // IllegalArgumentException nullOrEmpty(String name); // // @Message(id = 23, value = "Given parent (%s) is not an ancestor of this virtual file") // IllegalArgumentException parentIsNotAncestor(VirtualFile parent); // // @Message(id = 24, value = "Problems creating new directory: %s") // IllegalArgumentException problemCreatingNewDirectory(VirtualFile targetChild); // // @Message(id = 25, value = "Invalid Win32 path: %s") // IllegalArgumentException invalidWin32Path(String path); // // @Message(id = 26, value = "Cannot decode: %s [%s]") // IllegalArgumentException cannotDecode(String path, String encoding, @Cause Exception e); // // @Message(id = 27, value = "Invalid jar signature %s should be %s") // IOException invalidJarSignature(String bytes, String expectedHeader); // // @Message(id = 28, value = "Invalid actions string: %s") // IllegalArgumentException invalidActionsString(String actions); // // @Message(id = 29, value = "The totalBufferLength must be larger than: %s") // IllegalArgumentException bufferMustBeLargerThan(int minimumBufferLength); // // @Message(id = 30, value = "Buffer does not have enough capacity") // IllegalArgumentException bufferDoesntHaveEnoughCapacity(); // // @Message(id = 31, value = "The preconfigured attributes are immutable") // IllegalStateException preconfiguredAttributesAreImmutable(); // // @Message(id = 32, value = ".. on root path") // IllegalStateException onRootPath(); // } // Path: src/main/java/org/jboss/vfs/util/PathTokenizer.java import org.jboss.vfs.VFSMessages; import static org.jboss.vfs.VFSMessages.MESSAGES; import java.util.ArrayList; import java.util.List; /** * Get the remaining path from some tokens * * @param tokens the tokens * @param i the current location * @return the remaining path * @throws IllegalArgumentException for null tokens or i is out of range */ public static String getRemainingPath(List<String> tokens, int i) { if (tokens == null) { throw MESSAGES.nullArgument("tokens"); } return getRemainingPath(tokens, i, tokens.size()); } /** * Apply any . or .. paths in the path param. * * @param path the path * @return simple path, containing no . or .. paths */ public static String applySpecialPaths(String path) throws IllegalArgumentException { List<String> tokens = getTokens(path); if (tokens == null) { return null; } int i = 0; for (int j = 0; j < tokens.size(); j++) { String token = tokens.get(j); if (isCurrentToken(token)) { continue; } else if (isReverseToken(token)) { i--; } else { tokens.set(i++, token); } if (i < 0) {
throw VFSMessages.MESSAGES.onRootPath();
jbossas/jboss-vfs
src/main/java/org/jboss/vfs/protocol/AbstractLocalURLStreamHandler.java
// Path: src/main/java/org/jboss/vfs/VFSMessages.java // @MessageBundle(projectCode = "VFS") // public interface VFSMessages { // /** // * The messages // */ // VFSMessages MESSAGES = Messages.getBundle(VFSMessages.class); // // @Message(id = 10, value = "Can't set up temp file provider") // RuntimeException cantSetupTempFileProvider(@Cause Throwable cause); // // @Message(id = 11, value = "Temp directory closed") // IOException tempDirectoryClosed(); // // @Message(id = 12, value = "Temp file provider closed") // IOException tempFileProviderClosed(); // // // Retired // // @Message(id = 13, value = "Failed to clean existing content for temp file provider of type %s") // // IOException failedToCleanExistingContentForTempFileProvider(String providerType); // // @Message(id = 14, value = "Could not create directory for root '%s' (prefix '%s', suffix '%s') after %d attempts") // IOException couldNotCreateDirectoryForRoot(File root, String prefix, String suffix, int retries); // // @Message(id = 15, value = "Could not create directory for original name '%s' after %d attempts") // IOException couldNotCreateDirectory(String originalName, int retries); // // @Message(id = 16, value = "Root filesystem already mounted") // IOException rootFileSystemAlreadyMounted(); // // @Message(id = 17, value = "Filesystem already mounted at mount point \"%s\"") // IOException fileSystemAlreadyMountedAtMountPoint(VirtualFile mountPoint); // // @Message(id = 18, value = "Stream is closed") // IOException streamIsClosed(); // // @Message(id = 19, value = "Not a file: '%s'") // IOException notAFile(String path); // // @Message(id = 20, value = "Remote host access not supported for URLs of type '%s'") // IOException remoteHostAccessNotSupportedForUrls(String protocol); // // @Message(id = 21, value = "%s must not be null") // IllegalArgumentException nullArgument(String name); // // @Message(id = 22, value = "Null or empty %s") // IllegalArgumentException nullOrEmpty(String name); // // @Message(id = 23, value = "Given parent (%s) is not an ancestor of this virtual file") // IllegalArgumentException parentIsNotAncestor(VirtualFile parent); // // @Message(id = 24, value = "Problems creating new directory: %s") // IllegalArgumentException problemCreatingNewDirectory(VirtualFile targetChild); // // @Message(id = 25, value = "Invalid Win32 path: %s") // IllegalArgumentException invalidWin32Path(String path); // // @Message(id = 26, value = "Cannot decode: %s [%s]") // IllegalArgumentException cannotDecode(String path, String encoding, @Cause Exception e); // // @Message(id = 27, value = "Invalid jar signature %s should be %s") // IOException invalidJarSignature(String bytes, String expectedHeader); // // @Message(id = 28, value = "Invalid actions string: %s") // IllegalArgumentException invalidActionsString(String actions); // // @Message(id = 29, value = "The totalBufferLength must be larger than: %s") // IllegalArgumentException bufferMustBeLargerThan(int minimumBufferLength); // // @Message(id = 30, value = "Buffer does not have enough capacity") // IllegalArgumentException bufferDoesntHaveEnoughCapacity(); // // @Message(id = 31, value = "The preconfigured attributes are immutable") // IllegalStateException preconfiguredAttributesAreImmutable(); // // @Message(id = 32, value = ".. on root path") // IllegalStateException onRootPath(); // }
import java.io.IOException; import java.net.Proxy; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; import java.util.HashSet; import java.util.Set; import org.jboss.vfs.VFSMessages;
/* * JBoss, Home of Professional Open Source * Copyright 2010, JBoss Inc., and individual contributors as indicated * by the @authors tag. * * 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 org.jboss.vfs.protocol; /** * Abstract URLStreamHandler that can be used as a base for other URLStreamHandlers that * require the URL to be local. * * @author <a href=mailto:[email protected]">John Bailey</a> * @version $Revision$ */ public abstract class AbstractLocalURLStreamHandler extends URLStreamHandler { private static final Set<String> locals; static { Set<String> set = new HashSet<String>(); set.add(null); set.add(""); set.add("~"); set.add("localhost"); locals = set; } private static String toLower(String str) { return str == null ? null : str.toLowerCase(); } @Override protected URLConnection openConnection(URL u, Proxy p) throws IOException { return openConnection(u); } @Override protected boolean hostsEqual(URL url1, URL url2) { return locals.contains(toLower(url1.getHost())) && locals.contains(toLower(url2.getHost())) || super.hostsEqual(url1, url2); } protected void ensureLocal(URL url) throws IOException { if (!locals.contains(toLower(url.getHost()))) {
// Path: src/main/java/org/jboss/vfs/VFSMessages.java // @MessageBundle(projectCode = "VFS") // public interface VFSMessages { // /** // * The messages // */ // VFSMessages MESSAGES = Messages.getBundle(VFSMessages.class); // // @Message(id = 10, value = "Can't set up temp file provider") // RuntimeException cantSetupTempFileProvider(@Cause Throwable cause); // // @Message(id = 11, value = "Temp directory closed") // IOException tempDirectoryClosed(); // // @Message(id = 12, value = "Temp file provider closed") // IOException tempFileProviderClosed(); // // // Retired // // @Message(id = 13, value = "Failed to clean existing content for temp file provider of type %s") // // IOException failedToCleanExistingContentForTempFileProvider(String providerType); // // @Message(id = 14, value = "Could not create directory for root '%s' (prefix '%s', suffix '%s') after %d attempts") // IOException couldNotCreateDirectoryForRoot(File root, String prefix, String suffix, int retries); // // @Message(id = 15, value = "Could not create directory for original name '%s' after %d attempts") // IOException couldNotCreateDirectory(String originalName, int retries); // // @Message(id = 16, value = "Root filesystem already mounted") // IOException rootFileSystemAlreadyMounted(); // // @Message(id = 17, value = "Filesystem already mounted at mount point \"%s\"") // IOException fileSystemAlreadyMountedAtMountPoint(VirtualFile mountPoint); // // @Message(id = 18, value = "Stream is closed") // IOException streamIsClosed(); // // @Message(id = 19, value = "Not a file: '%s'") // IOException notAFile(String path); // // @Message(id = 20, value = "Remote host access not supported for URLs of type '%s'") // IOException remoteHostAccessNotSupportedForUrls(String protocol); // // @Message(id = 21, value = "%s must not be null") // IllegalArgumentException nullArgument(String name); // // @Message(id = 22, value = "Null or empty %s") // IllegalArgumentException nullOrEmpty(String name); // // @Message(id = 23, value = "Given parent (%s) is not an ancestor of this virtual file") // IllegalArgumentException parentIsNotAncestor(VirtualFile parent); // // @Message(id = 24, value = "Problems creating new directory: %s") // IllegalArgumentException problemCreatingNewDirectory(VirtualFile targetChild); // // @Message(id = 25, value = "Invalid Win32 path: %s") // IllegalArgumentException invalidWin32Path(String path); // // @Message(id = 26, value = "Cannot decode: %s [%s]") // IllegalArgumentException cannotDecode(String path, String encoding, @Cause Exception e); // // @Message(id = 27, value = "Invalid jar signature %s should be %s") // IOException invalidJarSignature(String bytes, String expectedHeader); // // @Message(id = 28, value = "Invalid actions string: %s") // IllegalArgumentException invalidActionsString(String actions); // // @Message(id = 29, value = "The totalBufferLength must be larger than: %s") // IllegalArgumentException bufferMustBeLargerThan(int minimumBufferLength); // // @Message(id = 30, value = "Buffer does not have enough capacity") // IllegalArgumentException bufferDoesntHaveEnoughCapacity(); // // @Message(id = 31, value = "The preconfigured attributes are immutable") // IllegalStateException preconfiguredAttributesAreImmutable(); // // @Message(id = 32, value = ".. on root path") // IllegalStateException onRootPath(); // } // Path: src/main/java/org/jboss/vfs/protocol/AbstractLocalURLStreamHandler.java import java.io.IOException; import java.net.Proxy; import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; import java.util.HashSet; import java.util.Set; import org.jboss.vfs.VFSMessages; /* * JBoss, Home of Professional Open Source * Copyright 2010, JBoss Inc., and individual contributors as indicated * by the @authors tag. * * 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 org.jboss.vfs.protocol; /** * Abstract URLStreamHandler that can be used as a base for other URLStreamHandlers that * require the URL to be local. * * @author <a href=mailto:[email protected]">John Bailey</a> * @version $Revision$ */ public abstract class AbstractLocalURLStreamHandler extends URLStreamHandler { private static final Set<String> locals; static { Set<String> set = new HashSet<String>(); set.add(null); set.add(""); set.add("~"); set.add("localhost"); locals = set; } private static String toLower(String str) { return str == null ? null : str.toLowerCase(); } @Override protected URLConnection openConnection(URL u, Proxy p) throws IOException { return openConnection(u); } @Override protected boolean hostsEqual(URL url1, URL url2) { return locals.contains(toLower(url1.getHost())) && locals.contains(toLower(url2.getHost())) || super.hostsEqual(url1, url2); } protected void ensureLocal(URL url) throws IOException { if (!locals.contains(toLower(url.getHost()))) {
throw VFSMessages.MESSAGES.remoteHostAccessNotSupportedForUrls(url.getProtocol());
jbossas/jboss-vfs
src/main/java/org/jboss/vfs/VFSInputSource.java
// Path: src/main/java/org/jboss/vfs/util/LazyInputStream.java // public class LazyInputStream extends InputStream { // private VirtualFile file; // private InputStream stream; // // public LazyInputStream(VirtualFile file) { // if (file == null) { // throw MESSAGES.nullArgument("file"); // } // this.file = file; // } // // /** // * Open stream. // * // * @return file's stream // * @throws IOException for any IO error // */ // protected synchronized InputStream openStream() throws IOException { // if (stream == null) { stream = file.openStream(); } // return stream; // } // // @Override // public int read() throws IOException { // return openStream().read(); // } // // @Override // public int read(byte[] b) throws IOException { // return openStream().read(b); // } // // @Override // public int read(byte[] b, int off, int len) throws IOException { // return openStream().read(b, off, len); // } // // @Override // public long skip(long n) throws IOException { // return openStream().skip(n); // } // // @Override // public int available() throws IOException { // return openStream().available(); // } // // @Override // public synchronized void close() throws IOException { // if (stream == null) { return; } // // openStream().close(); // stream = null; // reset the stream // } // // @Override // public void mark(int readlimit) { // try { // openStream().mark(readlimit); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // // @Override // public void reset() throws IOException { // openStream().reset(); // } // // @Override // public boolean markSupported() { // try { // return openStream().markSupported(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // }
import java.io.InputStream; import org.jboss.vfs.util.LazyInputStream; import org.xml.sax.InputSource;
/* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * 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 org.jboss.vfs; /** * VFS based impl of InputSource. * * @author <a href="mailto:[email protected]">Ales Justin</a> */ public class VFSInputSource extends InputSource { private VirtualFile file; public VFSInputSource(VirtualFile file) { if (file == null) { throw VFSMessages.MESSAGES.nullArgument("file"); } this.file = file; } @Override public String getSystemId() { try { return VFSUtils.getVirtualURI(file).toString(); } catch (Exception e) { throw new RuntimeException(e); } } @Override public InputStream getByteStream() {
// Path: src/main/java/org/jboss/vfs/util/LazyInputStream.java // public class LazyInputStream extends InputStream { // private VirtualFile file; // private InputStream stream; // // public LazyInputStream(VirtualFile file) { // if (file == null) { // throw MESSAGES.nullArgument("file"); // } // this.file = file; // } // // /** // * Open stream. // * // * @return file's stream // * @throws IOException for any IO error // */ // protected synchronized InputStream openStream() throws IOException { // if (stream == null) { stream = file.openStream(); } // return stream; // } // // @Override // public int read() throws IOException { // return openStream().read(); // } // // @Override // public int read(byte[] b) throws IOException { // return openStream().read(b); // } // // @Override // public int read(byte[] b, int off, int len) throws IOException { // return openStream().read(b, off, len); // } // // @Override // public long skip(long n) throws IOException { // return openStream().skip(n); // } // // @Override // public int available() throws IOException { // return openStream().available(); // } // // @Override // public synchronized void close() throws IOException { // if (stream == null) { return; } // // openStream().close(); // stream = null; // reset the stream // } // // @Override // public void mark(int readlimit) { // try { // openStream().mark(readlimit); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // // @Override // public void reset() throws IOException { // openStream().reset(); // } // // @Override // public boolean markSupported() { // try { // return openStream().markSupported(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // Path: src/main/java/org/jboss/vfs/VFSInputSource.java import java.io.InputStream; import org.jboss.vfs.util.LazyInputStream; import org.xml.sax.InputSource; /* * JBoss, Home of Professional Open Source. * Copyright 2008, Red Hat Middleware LLC, and individual contributors * as indicated by the @author tags. See the copyright.txt file in the * distribution for a full listing of individual contributors. * * 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 org.jboss.vfs; /** * VFS based impl of InputSource. * * @author <a href="mailto:[email protected]">Ales Justin</a> */ public class VFSInputSource extends InputSource { private VirtualFile file; public VFSInputSource(VirtualFile file) { if (file == null) { throw VFSMessages.MESSAGES.nullArgument("file"); } this.file = file; } @Override public String getSystemId() { try { return VFSUtils.getVirtualURI(file).toString(); } catch (Exception e) { throw new RuntimeException(e); } } @Override public InputStream getByteStream() {
return new LazyInputStream(file);
danielflower/multi-module-maven-release-plugin
src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java
// Path: src/test/java/scaffolding/ReleasableModuleBuilder.java // public static ReleasableModuleBuilder aModule() { // return new ReleasableModuleBuilder() // .withGroupId("com.github.danielflower.somegroup") // .withArtifactId("some-artifact"); // }
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.util.Collection; import java.util.List; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static scaffolding.ReleasableModuleBuilder.aModule;
package com.github.danielflower.mavenplugins.release; public class ReactorTest { @Test public void canFindModulesByGroupAndArtifactName() throws Exception {
// Path: src/test/java/scaffolding/ReleasableModuleBuilder.java // public static ReleasableModuleBuilder aModule() { // return new ReleasableModuleBuilder() // .withGroupId("com.github.danielflower.somegroup") // .withArtifactId("some-artifact"); // } // Path: src/test/java/com/github/danielflower/mavenplugins/release/ReactorTest.java import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; import org.junit.Assert; import org.junit.Test; import java.io.IOException; import java.util.Collection; import java.util.List; import static java.util.Arrays.asList; import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.MatcherAssert.assertThat; import static scaffolding.ReleasableModuleBuilder.aModule; package com.github.danielflower.mavenplugins.release; public class ReactorTest { @Test public void canFindModulesByGroupAndArtifactName() throws Exception {
ReleasableModule arty = aModule().withGroupId("my.great.group").withArtifactId("some-arty").build();
danielflower/multi-module-maven-release-plugin
src/test/java/com/github/danielflower/mavenplugins/release/ReleasableModuleTest.java
// Path: src/test/java/scaffolding/ReleasableModuleBuilder.java // public static ReleasableModuleBuilder aModule() { // return new ReleasableModuleBuilder() // .withGroupId("com.github.danielflower.somegroup") // .withArtifactId("some-artifact"); // }
import org.apache.maven.project.MavenProject; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; import static scaffolding.ReleasableModuleBuilder.aModule;
package com.github.danielflower.mavenplugins.release; public class ReleasableModuleTest { @Test public void getsTheTagFromTheArtifactAndVersion() throws Exception {
// Path: src/test/java/scaffolding/ReleasableModuleBuilder.java // public static ReleasableModuleBuilder aModule() { // return new ReleasableModuleBuilder() // .withGroupId("com.github.danielflower.somegroup") // .withArtifactId("some-artifact"); // } // Path: src/test/java/com/github/danielflower/mavenplugins/release/ReleasableModuleTest.java import org.apache.maven.project.MavenProject; import org.junit.Test; import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.IsEqual.equalTo; import static scaffolding.ReleasableModuleBuilder.aModule; package com.github.danielflower.mavenplugins.release; public class ReleasableModuleTest { @Test public void getsTheTagFromTheArtifactAndVersion() throws Exception {
ReleasableModule module = aModule()
danielflower/multi-module-maven-release-plugin
src/test/java/com/github/danielflower/mavenplugins/release/ReleaseInvokerTest.java
// Path: src/main/java/com/github/danielflower/mavenplugins/release/ReleaseInvoker.java // static final String DEPLOY = "deploy"; // // Path: src/main/java/com/github/danielflower/mavenplugins/release/ReleaseInvoker.java // static final String SKIP_TESTS = "-DskipTests=true";
import org.apache.maven.model.Profile; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.Invoker; import org.apache.maven.shared.invoker.MavenInvocationException; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import java.io.File; import java.util.LinkedList; import java.util.List; import static com.github.danielflower.mavenplugins.release.ReleaseInvoker.DEPLOY; import static com.github.danielflower.mavenplugins.release.ReleaseInvoker.SKIP_TESTS; import static java.util.Arrays.asList; import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import static org.mockito.Mockito.*;
private final List<String> modulesToRelease = new LinkedList<String>(); private final List<String> releaseProfiles = new LinkedList<String>(); private final List<ReleasableModule> modulesInBuildOrder = new LinkedList<ReleasableModule>(); private final Reactor reactor = mock(Reactor.class); private final ReleasableModule module = mock(ReleasableModule.class); private final Profile activeProfile = mock(Profile.class); private final ReleaseInvoker releaseInvoker = new ReleaseInvoker(log, project, request, invoker); @Before public void setup() throws Exception { modulesInBuildOrder.add(module); when(log.isDebugEnabled()).thenReturn(true); when(invoker.execute(request)).thenReturn(result); when(activeProfile.getId()).thenReturn(ACTIVE_PROFILE_ID); when(module.getRelativePathToModule()).thenReturn(MODULE_PATH); } @Test public void verifyDefaultConstructor() { new ReleaseInvoker(log, project); } @Test public void runMavenBuild_BaseTest() throws Exception { releaseInvoker.runMavenBuild(reactor); verify(request).setBatchMode(true); verify(request).setShowErrors(true); verify(request).setDebug(true); verify(log).isDebugEnabled(); verify(request).setAlsoMake(true);
// Path: src/main/java/com/github/danielflower/mavenplugins/release/ReleaseInvoker.java // static final String DEPLOY = "deploy"; // // Path: src/main/java/com/github/danielflower/mavenplugins/release/ReleaseInvoker.java // static final String SKIP_TESTS = "-DskipTests=true"; // Path: src/test/java/com/github/danielflower/mavenplugins/release/ReleaseInvokerTest.java import org.apache.maven.model.Profile; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.Invoker; import org.apache.maven.shared.invoker.MavenInvocationException; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import java.io.File; import java.util.LinkedList; import java.util.List; import static com.github.danielflower.mavenplugins.release.ReleaseInvoker.DEPLOY; import static com.github.danielflower.mavenplugins.release.ReleaseInvoker.SKIP_TESTS; import static java.util.Arrays.asList; import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import static org.mockito.Mockito.*; private final List<String> modulesToRelease = new LinkedList<String>(); private final List<String> releaseProfiles = new LinkedList<String>(); private final List<ReleasableModule> modulesInBuildOrder = new LinkedList<ReleasableModule>(); private final Reactor reactor = mock(Reactor.class); private final ReleasableModule module = mock(ReleasableModule.class); private final Profile activeProfile = mock(Profile.class); private final ReleaseInvoker releaseInvoker = new ReleaseInvoker(log, project, request, invoker); @Before public void setup() throws Exception { modulesInBuildOrder.add(module); when(log.isDebugEnabled()).thenReturn(true); when(invoker.execute(request)).thenReturn(result); when(activeProfile.getId()).thenReturn(ACTIVE_PROFILE_ID); when(module.getRelativePathToModule()).thenReturn(MODULE_PATH); } @Test public void verifyDefaultConstructor() { new ReleaseInvoker(log, project); } @Test public void runMavenBuild_BaseTest() throws Exception { releaseInvoker.runMavenBuild(reactor); verify(request).setBatchMode(true); verify(request).setShowErrors(true); verify(request).setDebug(true); verify(log).isDebugEnabled(); verify(request).setAlsoMake(true);
verify(request).setGoals(Mockito.argThat(goals -> goals.size() == 1 && goals.contains(DEPLOY)));
danielflower/multi-module-maven-release-plugin
src/test/java/com/github/danielflower/mavenplugins/release/ReleaseInvokerTest.java
// Path: src/main/java/com/github/danielflower/mavenplugins/release/ReleaseInvoker.java // static final String DEPLOY = "deploy"; // // Path: src/main/java/com/github/danielflower/mavenplugins/release/ReleaseInvoker.java // static final String SKIP_TESTS = "-DskipTests=true";
import org.apache.maven.model.Profile; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.Invoker; import org.apache.maven.shared.invoker.MavenInvocationException; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import java.io.File; import java.util.LinkedList; import java.util.List; import static com.github.danielflower.mavenplugins.release.ReleaseInvoker.DEPLOY; import static com.github.danielflower.mavenplugins.release.ReleaseInvoker.SKIP_TESTS; import static java.util.Arrays.asList; import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import static org.mockito.Mockito.*;
@Test public void runMavenBuild_UserExplicitlyWantsThisToBeReleased() throws Exception { when(reactor.getModulesInBuildOrder()).thenReturn(modulesInBuildOrder); modulesToRelease.add(MODULE_PATH); releaseInvoker.setModulesToRelease(modulesToRelease); releaseInvoker.runMavenBuild(reactor); verify(request).setProjects(Mockito.argThat(modules -> modules.size() == 1 && modules.contains(MODULE_PATH))); } @Test public void runMavenBuild_UserImplicitlyWantsThisToBeReleased() throws Exception { when(reactor.getModulesInBuildOrder()).thenReturn(modulesInBuildOrder); when(module.willBeReleased()).thenReturn(true); releaseInvoker.setModulesToRelease(modulesToRelease); releaseInvoker.runMavenBuild(reactor); verify(request).setProjects(Mockito.argThat(modules -> modules.size() == 1 && modules.contains(MODULE_PATH))); } @Test public void runMavenBuild_UserImplicitlyWantsThisToBeReleased_WillNotBeReleased() throws Exception { when(reactor.getModulesInBuildOrder()).thenReturn(modulesInBuildOrder); releaseInvoker.setModulesToRelease(modulesToRelease); releaseInvoker.runMavenBuild(reactor); verify(request).setProjects(Mockito.argThat(List::isEmpty)); } @Test public void skipTests() throws Exception { releaseInvoker.setSkipTests(true); releaseInvoker.runMavenBuild(reactor);
// Path: src/main/java/com/github/danielflower/mavenplugins/release/ReleaseInvoker.java // static final String DEPLOY = "deploy"; // // Path: src/main/java/com/github/danielflower/mavenplugins/release/ReleaseInvoker.java // static final String SKIP_TESTS = "-DskipTests=true"; // Path: src/test/java/com/github/danielflower/mavenplugins/release/ReleaseInvokerTest.java import org.apache.maven.model.Profile; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.apache.maven.shared.invoker.InvocationRequest; import org.apache.maven.shared.invoker.InvocationResult; import org.apache.maven.shared.invoker.Invoker; import org.apache.maven.shared.invoker.MavenInvocationException; import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; import java.io.File; import java.util.LinkedList; import java.util.List; import static com.github.danielflower.mavenplugins.release.ReleaseInvoker.DEPLOY; import static com.github.danielflower.mavenplugins.release.ReleaseInvoker.SKIP_TESTS; import static java.util.Arrays.asList; import static org.junit.Assert.assertSame; import static org.junit.Assert.fail; import static org.mockito.Mockito.*; @Test public void runMavenBuild_UserExplicitlyWantsThisToBeReleased() throws Exception { when(reactor.getModulesInBuildOrder()).thenReturn(modulesInBuildOrder); modulesToRelease.add(MODULE_PATH); releaseInvoker.setModulesToRelease(modulesToRelease); releaseInvoker.runMavenBuild(reactor); verify(request).setProjects(Mockito.argThat(modules -> modules.size() == 1 && modules.contains(MODULE_PATH))); } @Test public void runMavenBuild_UserImplicitlyWantsThisToBeReleased() throws Exception { when(reactor.getModulesInBuildOrder()).thenReturn(modulesInBuildOrder); when(module.willBeReleased()).thenReturn(true); releaseInvoker.setModulesToRelease(modulesToRelease); releaseInvoker.runMavenBuild(reactor); verify(request).setProjects(Mockito.argThat(modules -> modules.size() == 1 && modules.contains(MODULE_PATH))); } @Test public void runMavenBuild_UserImplicitlyWantsThisToBeReleased_WillNotBeReleased() throws Exception { when(reactor.getModulesInBuildOrder()).thenReturn(modulesInBuildOrder); releaseInvoker.setModulesToRelease(modulesToRelease); releaseInvoker.runMavenBuild(reactor); verify(request).setProjects(Mockito.argThat(List::isEmpty)); } @Test public void skipTests() throws Exception { releaseInvoker.setSkipTests(true); releaseInvoker.runMavenBuild(reactor);
verify(request).setGoals(Mockito.argThat(goals -> goals.size() == 2 && goals.contains(DEPLOY) && goals.contains(SKIP_TESTS)));
danielflower/multi-module-maven-release-plugin
src/main/java/com/github/danielflower/mavenplugins/release/LocalGitRepo.java
// Path: src/main/java/com/github/danielflower/mavenplugins/release/FileUtils.java // public static String pathOf(File file) { // String path; // try { // path = file.getCanonicalPath(); // } catch (IOException e1) { // path = file.getAbsolutePath(); // } // return path; // }
import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.LsRemoteCommand; import org.eclipse.jgit.api.PushCommand; import org.eclipse.jgit.api.Status; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.CredentialsProvider; import java.io.File; import java.io.IOException; import java.util.*; import static com.github.danielflower.mavenplugins.release.FileUtils.pathOf;
package com.github.danielflower.mavenplugins.release; public class LocalGitRepo { public final Git git; private boolean hasReverted = false; // A premature optimisation? In the normal case, file reverting occurs twice, which this bool prevents private Collection<Ref> tags; private final TagFetcher tagFetcher; private final TagPusher tagPusher; public static class Builder { private Set<GitOperations> operationsAllowed = EnumSet.allOf(GitOperations.class); private String remoteGitUrl; private CredentialsProvider credentialsProvider; /** * Flag for which remote Git operations are permitted. Local values will * be substituted if remote operations are forbidden; this means the * local copy of the repository must be up to date! */ public Builder remoteGitOperationsAllowed(Set<GitOperations> operationsAllowed) { this.operationsAllowed = EnumSet.copyOf(operationsAllowed); return this; } /** * Overrides the URL of remote Git repository. */ public Builder remoteGitUrl(String remoteUrl) { this.remoteGitUrl = remoteUrl; return this; } /** * Sets the username/password pair for HTTPS URLs or SSH with passwordl */ public Builder credentialsProvider(CredentialsProvider credentialsProvider) { this.credentialsProvider = credentialsProvider; return this; } /** * Uses the current working dir to open the Git repository. * @throws ValidationException if anything goes wrong */ public LocalGitRepo buildFromCurrentDir() throws ValidationException { Git git; File gitDir = new File("."); try { git = Git.open(gitDir); } catch (RepositoryNotFoundException rnfe) {
// Path: src/main/java/com/github/danielflower/mavenplugins/release/FileUtils.java // public static String pathOf(File file) { // String path; // try { // path = file.getCanonicalPath(); // } catch (IOException e1) { // path = file.getAbsolutePath(); // } // return path; // } // Path: src/main/java/com/github/danielflower/mavenplugins/release/LocalGitRepo.java import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.LsRemoteCommand; import org.eclipse.jgit.api.PushCommand; import org.eclipse.jgit.api.Status; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.errors.RepositoryNotFoundException; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.transport.CredentialsProvider; import java.io.File; import java.io.IOException; import java.util.*; import static com.github.danielflower.mavenplugins.release.FileUtils.pathOf; package com.github.danielflower.mavenplugins.release; public class LocalGitRepo { public final Git git; private boolean hasReverted = false; // A premature optimisation? In the normal case, file reverting occurs twice, which this bool prevents private Collection<Ref> tags; private final TagFetcher tagFetcher; private final TagPusher tagPusher; public static class Builder { private Set<GitOperations> operationsAllowed = EnumSet.allOf(GitOperations.class); private String remoteGitUrl; private CredentialsProvider credentialsProvider; /** * Flag for which remote Git operations are permitted. Local values will * be substituted if remote operations are forbidden; this means the * local copy of the repository must be up to date! */ public Builder remoteGitOperationsAllowed(Set<GitOperations> operationsAllowed) { this.operationsAllowed = EnumSet.copyOf(operationsAllowed); return this; } /** * Overrides the URL of remote Git repository. */ public Builder remoteGitUrl(String remoteUrl) { this.remoteGitUrl = remoteUrl; return this; } /** * Sets the username/password pair for HTTPS URLs or SSH with passwordl */ public Builder credentialsProvider(CredentialsProvider credentialsProvider) { this.credentialsProvider = credentialsProvider; return this; } /** * Uses the current working dir to open the Git repository. * @throws ValidationException if anything goes wrong */ public LocalGitRepo buildFromCurrentDir() throws ValidationException { Git git; File gitDir = new File("."); try { git = Git.open(gitDir); } catch (RepositoryNotFoundException rnfe) {
String fullPathOfCurrentDir = pathOf(gitDir);
danielflower/multi-module-maven-release-plugin
src/main/java/com/github/danielflower/mavenplugins/release/Reactor.java
// Path: src/main/java/com/github/danielflower/mavenplugins/release/MavenVersionResolver.java // static void resolveVersionsDefinedThroughProperties(List<MavenProject> projects) { // for (MavenProject project : projects) { // if (isVersionDefinedWithProperty(project.getVersion())) { // project.setVersion(resolveVersion(project.getVersion(), project.getProperties())); // } // } // // }
import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import static com.github.danielflower.mavenplugins.release.MavenVersionResolver.resolveVersionsDefinedThroughProperties;
package com.github.danielflower.mavenplugins.release; public class Reactor { private final List<ReleasableModule> modulesInBuildOrder; public Reactor(List<ReleasableModule> modulesInBuildOrder) { this.modulesInBuildOrder = modulesInBuildOrder; } public List<ReleasableModule> getModulesInBuildOrder() { return modulesInBuildOrder; } public static Reactor fromProjects(Log log, LocalGitRepo gitRepo, MavenProject rootProject, List<MavenProject> projects, Long buildNumber, List<String> modulesToForceRelease, NoChangesAction actionWhenNoChangesDetected, ResolverWrapper resolverWrapper, VersionNamer versionNamer) throws ValidationException, GitAPIException, MojoExecutionException { DiffDetector detector = new TreeWalkingDiffDetector(gitRepo.git.getRepository()); List<ReleasableModule> modules = new ArrayList<ReleasableModule>();
// Path: src/main/java/com/github/danielflower/mavenplugins/release/MavenVersionResolver.java // static void resolveVersionsDefinedThroughProperties(List<MavenProject> projects) { // for (MavenProject project : projects) { // if (isVersionDefinedWithProperty(project.getVersion())) { // project.setVersion(resolveVersion(project.getVersion(), project.getProperties())); // } // } // // } // Path: src/main/java/com/github/danielflower/mavenplugins/release/Reactor.java import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.lib.Repository; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; import static com.github.danielflower.mavenplugins.release.MavenVersionResolver.resolveVersionsDefinedThroughProperties; package com.github.danielflower.mavenplugins.release; public class Reactor { private final List<ReleasableModule> modulesInBuildOrder; public Reactor(List<ReleasableModule> modulesInBuildOrder) { this.modulesInBuildOrder = modulesInBuildOrder; } public List<ReleasableModule> getModulesInBuildOrder() { return modulesInBuildOrder; } public static Reactor fromProjects(Log log, LocalGitRepo gitRepo, MavenProject rootProject, List<MavenProject> projects, Long buildNumber, List<String> modulesToForceRelease, NoChangesAction actionWhenNoChangesDetected, ResolverWrapper resolverWrapper, VersionNamer versionNamer) throws ValidationException, GitAPIException, MojoExecutionException { DiffDetector detector = new TreeWalkingDiffDetector(gitRepo.git.getRepository()); List<ReleasableModule> modules = new ArrayList<ReleasableModule>();
resolveVersionsDefinedThroughProperties(projects);
danielflower/multi-module-maven-release-plugin
src/test/java/scaffolding/TestProject.java
// Path: src/main/java/com/github/danielflower/mavenplugins/release/FileUtils.java // public static String pathOf(File file) { // String path; // try { // path = file.getCanonicalPath(); // } catch (IOException e1) { // path = file.getAbsolutePath(); // } // return path; // } // // Path: src/test/java/scaffolding/Photocopier.java // public static File copyTestProjectToTemporaryLocation(String moduleName) throws IOException { // File source = new File("test-projects", moduleName); // if (!source.isDirectory()) { // source = new File(FilenameUtils.separatorsToSystem("../test-projects/" + moduleName)); // } // if (!source.isDirectory()) { // throw new RuntimeException("Could not find module " + moduleName); // } // // File target = folderForSampleProject(moduleName); // FileUtils.copyDirectory(source, target); // return target; // }
import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.InitCommand; import org.eclipse.jgit.api.errors.GitAPIException; import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.List; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import static com.github.danielflower.mavenplugins.release.FileUtils.pathOf; import static scaffolding.Photocopier.copyTestProjectToTemporaryLocation;
return mvnRun("releaser:next", buildNumber, arguments); } public TestProject commitRandomFile(String module) throws IOException, GitAPIException { File moduleDir = new File(localDir, module); if (!moduleDir.isDirectory()) { throw new RuntimeException("Could not find " + moduleDir.getCanonicalPath()); } File random = new File(moduleDir, UUID.randomUUID() + ".txt"); random.createNewFile(); String modulePath = module.equals(".") ? "" : module + "/"; local.add().addFilepattern(modulePath + random.getName()).call(); local.commit().setMessage("Commit " + commitCounter.getAndIncrement() + ": adding " + random.getName()).call(); return this; } public void pushIt() throws GitAPIException { local.push().call(); } private List<String> mvnRun(String goal, String buildNumber, String[] arguments) { String[] args = new String[arguments.length + 2]; args[0] = "-DbuildNumber=" + buildNumber; System.arraycopy(arguments, 0, args, 1, arguments.length); args[args.length-1] = goal; return mvnRunner.runMaven(localDir, args); } private static TestProject project(String name) { try {
// Path: src/main/java/com/github/danielflower/mavenplugins/release/FileUtils.java // public static String pathOf(File file) { // String path; // try { // path = file.getCanonicalPath(); // } catch (IOException e1) { // path = file.getAbsolutePath(); // } // return path; // } // // Path: src/test/java/scaffolding/Photocopier.java // public static File copyTestProjectToTemporaryLocation(String moduleName) throws IOException { // File source = new File("test-projects", moduleName); // if (!source.isDirectory()) { // source = new File(FilenameUtils.separatorsToSystem("../test-projects/" + moduleName)); // } // if (!source.isDirectory()) { // throw new RuntimeException("Could not find module " + moduleName); // } // // File target = folderForSampleProject(moduleName); // FileUtils.copyDirectory(source, target); // return target; // } // Path: src/test/java/scaffolding/TestProject.java import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.InitCommand; import org.eclipse.jgit.api.errors.GitAPIException; import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.List; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import static com.github.danielflower.mavenplugins.release.FileUtils.pathOf; import static scaffolding.Photocopier.copyTestProjectToTemporaryLocation; return mvnRun("releaser:next", buildNumber, arguments); } public TestProject commitRandomFile(String module) throws IOException, GitAPIException { File moduleDir = new File(localDir, module); if (!moduleDir.isDirectory()) { throw new RuntimeException("Could not find " + moduleDir.getCanonicalPath()); } File random = new File(moduleDir, UUID.randomUUID() + ".txt"); random.createNewFile(); String modulePath = module.equals(".") ? "" : module + "/"; local.add().addFilepattern(modulePath + random.getName()).call(); local.commit().setMessage("Commit " + commitCounter.getAndIncrement() + ": adding " + random.getName()).call(); return this; } public void pushIt() throws GitAPIException { local.push().call(); } private List<String> mvnRun(String goal, String buildNumber, String[] arguments) { String[] args = new String[arguments.length + 2]; args[0] = "-DbuildNumber=" + buildNumber; System.arraycopy(arguments, 0, args, 1, arguments.length); args[args.length-1] = goal; return mvnRunner.runMaven(localDir, args); } private static TestProject project(String name) { try {
File originDir = copyTestProjectToTemporaryLocation(name);
danielflower/multi-module-maven-release-plugin
src/test/java/scaffolding/TestProject.java
// Path: src/main/java/com/github/danielflower/mavenplugins/release/FileUtils.java // public static String pathOf(File file) { // String path; // try { // path = file.getCanonicalPath(); // } catch (IOException e1) { // path = file.getAbsolutePath(); // } // return path; // } // // Path: src/test/java/scaffolding/Photocopier.java // public static File copyTestProjectToTemporaryLocation(String moduleName) throws IOException { // File source = new File("test-projects", moduleName); // if (!source.isDirectory()) { // source = new File(FilenameUtils.separatorsToSystem("../test-projects/" + moduleName)); // } // if (!source.isDirectory()) { // throw new RuntimeException("Could not find module " + moduleName); // } // // File target = folderForSampleProject(moduleName); // FileUtils.copyDirectory(source, target); // return target; // }
import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.InitCommand; import org.eclipse.jgit.api.errors.GitAPIException; import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.List; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import static com.github.danielflower.mavenplugins.release.FileUtils.pathOf; import static scaffolding.Photocopier.copyTestProjectToTemporaryLocation;
.setDirectory(localDir) .setURI(originDir.toURI().toString()) .call(); return new TestProject(originDir, origin, localDir, local); } catch (Exception e) { throw new RuntimeException("Error while creating copies of the test project", e); } } public static void performPomSubstitution(File sourceDir) throws IOException { File pom = new File(sourceDir, "pom.xml"); if (pom.exists()) { String xml = FileUtils.readFileToString(pom, "UTF-8"); if (xml.contains("${scm.url}")) { xml = xml.replace("${scm.url}", dirToGitScmReference(sourceDir)); } xml = xml.replace("${current.plugin.version}", PLUGIN_VERSION_FOR_TESTS); FileUtils.writeStringToFile(pom, xml, "UTF-8"); } for (File child : sourceDir.listFiles((FileFilter) FileFilterUtils.directoryFileFilter())) { performPomSubstitution(child); } } public static TestProject localPluginProject() { return project("local-plugin"); } public static String dirToGitScmReference(File sourceDir) {
// Path: src/main/java/com/github/danielflower/mavenplugins/release/FileUtils.java // public static String pathOf(File file) { // String path; // try { // path = file.getCanonicalPath(); // } catch (IOException e1) { // path = file.getAbsolutePath(); // } // return path; // } // // Path: src/test/java/scaffolding/Photocopier.java // public static File copyTestProjectToTemporaryLocation(String moduleName) throws IOException { // File source = new File("test-projects", moduleName); // if (!source.isDirectory()) { // source = new File(FilenameUtils.separatorsToSystem("../test-projects/" + moduleName)); // } // if (!source.isDirectory()) { // throw new RuntimeException("Could not find module " + moduleName); // } // // File target = folderForSampleProject(moduleName); // FileUtils.copyDirectory(source, target); // return target; // } // Path: src/test/java/scaffolding/TestProject.java import org.apache.commons.io.FileUtils; import org.apache.commons.io.filefilter.FileFilterUtils; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.InitCommand; import org.eclipse.jgit.api.errors.GitAPIException; import java.io.File; import java.io.FileFilter; import java.io.IOException; import java.util.List; import java.util.UUID; import java.util.concurrent.atomic.AtomicInteger; import static com.github.danielflower.mavenplugins.release.FileUtils.pathOf; import static scaffolding.Photocopier.copyTestProjectToTemporaryLocation; .setDirectory(localDir) .setURI(originDir.toURI().toString()) .call(); return new TestProject(originDir, origin, localDir, local); } catch (Exception e) { throw new RuntimeException("Error while creating copies of the test project", e); } } public static void performPomSubstitution(File sourceDir) throws IOException { File pom = new File(sourceDir, "pom.xml"); if (pom.exists()) { String xml = FileUtils.readFileToString(pom, "UTF-8"); if (xml.contains("${scm.url}")) { xml = xml.replace("${scm.url}", dirToGitScmReference(sourceDir)); } xml = xml.replace("${current.plugin.version}", PLUGIN_VERSION_FOR_TESTS); FileUtils.writeStringToFile(pom, xml, "UTF-8"); } for (File child : sourceDir.listFiles((FileFilter) FileFilterUtils.directoryFileFilter())) { performPomSubstitution(child); } } public static TestProject localPluginProject() { return project("local-plugin"); } public static String dirToGitScmReference(File sourceDir) {
return "scm:git:file://localhost/" + pathOf(sourceDir).replace('\\', '/').toLowerCase();
danielflower/multi-module-maven-release-plugin
src/test/java/scaffolding/ReleasableModuleBuilder.java
// Path: src/main/java/com/github/danielflower/mavenplugins/release/ValidationException.java // public class ValidationException extends Exception { // private final List<String> messages; // // public ValidationException(String summary, List<String> messages) { // super(summary); // this.messages = messages; // } // // public ValidationException(String summary, Throwable error) { // super(summary); // this.messages = Arrays.asList(summary, "" + error); // } // // public List<String> getMessages() { // return messages; // } // } // // Path: src/main/java/com/github/danielflower/mavenplugins/release/VersionNamer.java // public class VersionNamer { // // /** // * <p> // * The delimiter used to append the build number. // * </p> // * <p> // * By default, it will use ".". However, for a three-digit version, a // * dash ('-') is recommended to be in line with the maven versioning scheme. // * </p> // * <p> // * This can be specified using a command line parameter ("-Ddelimiter=2") // * or in this plugin's configuration. // * </p> // */ // @Parameter(property = "delimiter") // private String delimiter; // // public VersionNamer(String delimiter) { // this.delimiter = delimiter; // } // // public VersionNamer() { // this("."); // } // // public VersionName name(String pomVersion, Long buildNumber, Collection<Long> previousBuildNumbers) throws ValidationException { // // if (buildNumber == null) { // if (previousBuildNumbers.size() == 0) { // buildNumber = 0L; // } else { // buildNumber = nextBuildNumber(previousBuildNumbers); // } // } // // VersionName versionName = new VersionName(pomVersion, pomVersion.replace("-SNAPSHOT", ""), buildNumber, this.delimiter); // // if (!Repository.isValidRefName("refs/tags/" + versionName.releaseVersion())) { // String summary = "Sorry, '" + versionName.releaseVersion() + "' is not a valid version."; // throw new ValidationException(summary, asList( // summary, // "Version numbers are used in the Git tag, and so can only contain characters that are valid in git tags.", // "Please see https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html for tag naming rules." // )); // } // return versionName; // } // // private static long nextBuildNumber(Collection<Long> previousBuildNumbers) { // long max = 0; // for (Long buildNumber : previousBuildNumbers) { // max = Math.max(max, buildNumber); // } // return max + 1; // } // // String getDelimiter() { // return delimiter; // } // }
import com.github.danielflower.mavenplugins.release.ReleasableModule; import com.github.danielflower.mavenplugins.release.ValidationException; import com.github.danielflower.mavenplugins.release.VersionNamer; import org.apache.maven.project.MavenProject;
public ReleasableModuleBuilder withBuildNumber(long buildNumber) { this.buildNumber = buildNumber; return this; } public ReleasableModuleBuilder withEquivalentVersion(String equivalentVersion) { this.equivalentVersion = equivalentVersion; return this; } public ReleasableModuleBuilder withRelativePathToModule(String relativePathToModule) { this.relativePathToModule = relativePathToModule; return this; } public ReleasableModuleBuilder withGroupId(String groupId) { project.setGroupId(groupId); return this; } public ReleasableModuleBuilder withArtifactId(String artifactId) { project.setArtifactId(artifactId); return this; } public ReleasableModuleBuilder withSnapshotVersion(String snapshotVersion) { project.setVersion(snapshotVersion); return this; }
// Path: src/main/java/com/github/danielflower/mavenplugins/release/ValidationException.java // public class ValidationException extends Exception { // private final List<String> messages; // // public ValidationException(String summary, List<String> messages) { // super(summary); // this.messages = messages; // } // // public ValidationException(String summary, Throwable error) { // super(summary); // this.messages = Arrays.asList(summary, "" + error); // } // // public List<String> getMessages() { // return messages; // } // } // // Path: src/main/java/com/github/danielflower/mavenplugins/release/VersionNamer.java // public class VersionNamer { // // /** // * <p> // * The delimiter used to append the build number. // * </p> // * <p> // * By default, it will use ".". However, for a three-digit version, a // * dash ('-') is recommended to be in line with the maven versioning scheme. // * </p> // * <p> // * This can be specified using a command line parameter ("-Ddelimiter=2") // * or in this plugin's configuration. // * </p> // */ // @Parameter(property = "delimiter") // private String delimiter; // // public VersionNamer(String delimiter) { // this.delimiter = delimiter; // } // // public VersionNamer() { // this("."); // } // // public VersionName name(String pomVersion, Long buildNumber, Collection<Long> previousBuildNumbers) throws ValidationException { // // if (buildNumber == null) { // if (previousBuildNumbers.size() == 0) { // buildNumber = 0L; // } else { // buildNumber = nextBuildNumber(previousBuildNumbers); // } // } // // VersionName versionName = new VersionName(pomVersion, pomVersion.replace("-SNAPSHOT", ""), buildNumber, this.delimiter); // // if (!Repository.isValidRefName("refs/tags/" + versionName.releaseVersion())) { // String summary = "Sorry, '" + versionName.releaseVersion() + "' is not a valid version."; // throw new ValidationException(summary, asList( // summary, // "Version numbers are used in the Git tag, and so can only contain characters that are valid in git tags.", // "Please see https://www.kernel.org/pub/software/scm/git/docs/git-check-ref-format.html for tag naming rules." // )); // } // return versionName; // } // // private static long nextBuildNumber(Collection<Long> previousBuildNumbers) { // long max = 0; // for (Long buildNumber : previousBuildNumbers) { // max = Math.max(max, buildNumber); // } // return max + 1; // } // // String getDelimiter() { // return delimiter; // } // } // Path: src/test/java/scaffolding/ReleasableModuleBuilder.java import com.github.danielflower.mavenplugins.release.ReleasableModule; import com.github.danielflower.mavenplugins.release.ValidationException; import com.github.danielflower.mavenplugins.release.VersionNamer; import org.apache.maven.project.MavenProject; public ReleasableModuleBuilder withBuildNumber(long buildNumber) { this.buildNumber = buildNumber; return this; } public ReleasableModuleBuilder withEquivalentVersion(String equivalentVersion) { this.equivalentVersion = equivalentVersion; return this; } public ReleasableModuleBuilder withRelativePathToModule(String relativePathToModule) { this.relativePathToModule = relativePathToModule; return this; } public ReleasableModuleBuilder withGroupId(String groupId) { project.setGroupId(groupId); return this; } public ReleasableModuleBuilder withArtifactId(String artifactId) { project.setArtifactId(artifactId); return this; } public ReleasableModuleBuilder withSnapshotVersion(String snapshotVersion) { project.setVersion(snapshotVersion); return this; }
public ReleasableModule build() throws ValidationException {
danielflower/multi-module-maven-release-plugin
src/test/java/scaffolding/GitMatchers.java
// Path: src/main/java/com/github/danielflower/mavenplugins/release/GitHelper.java // public class GitHelper { // public static boolean hasLocalTag(Git repo, String tagToCheck) throws GitAPIException { // return tag(repo, new EqualsMatcher(tagToCheck)) != null; // } // // public static Ref refStartingWith(Git repo, final String tagPrefix) throws GitAPIException { // return tag(repo, new Matcher() { // @Override // public boolean matches(String tagName) { // return tagName.startsWith(tagPrefix); // } // }); // } // // private static Ref tag(Git repo, Matcher matcher) throws GitAPIException { // for (Ref ref : repo.tagList().call()) { // String currentTag = ref.getName().replace("refs/tags/", ""); // if (matcher.matches(currentTag)) { // return ref; // } // } // return null; // } // // public static String scmUrlToRemote(String scmUrl) throws ValidationException { // String GIT_PREFIX = "scm:git:"; // if (!scmUrl.startsWith(GIT_PREFIX)) { // List<String> messages = new ArrayList<String>(); // String summary = "Cannot run the release plugin with a non-Git version control system"; // messages.add(summary); // messages.add("The value in your scm tag is " + scmUrl); // throw new ValidationException(summary, messages); // } // String remote = scmUrl.substring(GIT_PREFIX.length()); // remote = remote.replace("file://localhost/", "file:///"); // return remote; // } // // private interface Matcher { // public boolean matches(String tagName); // } // // private static class EqualsMatcher implements Matcher { // private final String tagToCheck; // // public EqualsMatcher(String tagToCheck) { // this.tagToCheck = tagToCheck; // } // // @Override // public boolean matches(String tagName) { // return tagToCheck.equals(tagName); // } // } // }
import com.github.danielflower.mavenplugins.release.GitHelper; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Status; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; import java.util.List; import static org.eclipse.jgit.lib.Constants.R_TAGS;
package scaffolding; public class GitMatchers { public static Matcher<Git> hasTag(final String tag) { return new TypeSafeDiagnosingMatcher<Git>() { @Override protected boolean matchesSafely(Git repo, Description mismatchDescription) { try { mismatchDescription.appendValueList("a git repo with tags: ", ", ", "", repo.getRepository().getTags().keySet());
// Path: src/main/java/com/github/danielflower/mavenplugins/release/GitHelper.java // public class GitHelper { // public static boolean hasLocalTag(Git repo, String tagToCheck) throws GitAPIException { // return tag(repo, new EqualsMatcher(tagToCheck)) != null; // } // // public static Ref refStartingWith(Git repo, final String tagPrefix) throws GitAPIException { // return tag(repo, new Matcher() { // @Override // public boolean matches(String tagName) { // return tagName.startsWith(tagPrefix); // } // }); // } // // private static Ref tag(Git repo, Matcher matcher) throws GitAPIException { // for (Ref ref : repo.tagList().call()) { // String currentTag = ref.getName().replace("refs/tags/", ""); // if (matcher.matches(currentTag)) { // return ref; // } // } // return null; // } // // public static String scmUrlToRemote(String scmUrl) throws ValidationException { // String GIT_PREFIX = "scm:git:"; // if (!scmUrl.startsWith(GIT_PREFIX)) { // List<String> messages = new ArrayList<String>(); // String summary = "Cannot run the release plugin with a non-Git version control system"; // messages.add(summary); // messages.add("The value in your scm tag is " + scmUrl); // throw new ValidationException(summary, messages); // } // String remote = scmUrl.substring(GIT_PREFIX.length()); // remote = remote.replace("file://localhost/", "file:///"); // return remote; // } // // private interface Matcher { // public boolean matches(String tagName); // } // // private static class EqualsMatcher implements Matcher { // private final String tagToCheck; // // public EqualsMatcher(String tagToCheck) { // this.tagToCheck = tagToCheck; // } // // @Override // public boolean matches(String tagName) { // return tagToCheck.equals(tagName); // } // } // } // Path: src/test/java/scaffolding/GitMatchers.java import com.github.danielflower.mavenplugins.release.GitHelper; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.Status; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeDiagnosingMatcher; import java.util.List; import static org.eclipse.jgit.lib.Constants.R_TAGS; package scaffolding; public class GitMatchers { public static Matcher<Git> hasTag(final String tag) { return new TypeSafeDiagnosingMatcher<Git>() { @Override protected boolean matchesSafely(Git repo, Description mismatchDescription) { try { mismatchDescription.appendValueList("a git repo with tags: ", ", ", "", repo.getRepository().getTags().keySet());
return GitHelper.hasLocalTag(repo, tag);
VincentWei/live-group-chat
phone/src/mobi/espier/lgc/data/LgcDataUtil.java
// Path: phone/src/mobi/espier/lgc/util/SecurityUtils.java // public class SecurityUtils { // private static final String TAG = "SecrityUtils"; // // public static String hmacMd5(String data, String key) { // Mac mac; // try { // mac = Mac.getInstance("HmacMD5"); // SecretKeySpec sk = new SecretKeySpec(key.getBytes(), mac.getAlgorithm()); // mac.init(sk); // byte[] result = mac.doFinal(data.getBytes()); // // StringBuilder sb = new StringBuilder(); // for (byte b : result) { // sb.append(String.format("%02x", b)); // } // // return sb.toString(); // // } catch (NoSuchAlgorithmException e) {} catch (InvalidKeyException e) {} // // return ""; // } // // public static String md5(String key) { // return md5(key.getBytes()); // } // // public static String md5(byte[] input) { // String cacheKey = null; // try { // final MessageDigest mDigest = MessageDigest.getInstance("MD5"); // mDigest.update(input); // cacheKey = bytesToHexString(mDigest.digest()); // } catch (NoSuchAlgorithmException e) {} // return cacheKey; // } // // private static String bytesToHexString(byte[] bytes) { // // http://stackoverflow.com/questions/332079 // StringBuilder sb = new StringBuilder(); // for (int i = 0; i < bytes.length; i++) { // String hex = Integer.toHexString(0xFF & bytes[i]); // if (hex.length() == 1) { // sb.append('0'); // } // sb.append(hex); // } // return sb.toString(); // } // }
import java.util.ArrayList; import java.util.List; import mobi.espier.lgc.util.SecurityUtils; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.text.TextUtils;
/* * Copyright (C) 2010~2014 FMSoft (Espier Studio) * * This program is free software: you can redistribute it and/or modify it under the terms of the * GNU Affero General Public License as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License along with this program. * If not, see <http://www.gnu.org/licenses/>. */ package mobi.espier.lgc.data; public class LgcDataUtil { public static Uri saveNotification(Context context, String name, String content, int type, long time) { if (content == null || TextUtils.isEmpty(name) || TextUtils.isEmpty(content)) { return null; }
// Path: phone/src/mobi/espier/lgc/util/SecurityUtils.java // public class SecurityUtils { // private static final String TAG = "SecrityUtils"; // // public static String hmacMd5(String data, String key) { // Mac mac; // try { // mac = Mac.getInstance("HmacMD5"); // SecretKeySpec sk = new SecretKeySpec(key.getBytes(), mac.getAlgorithm()); // mac.init(sk); // byte[] result = mac.doFinal(data.getBytes()); // // StringBuilder sb = new StringBuilder(); // for (byte b : result) { // sb.append(String.format("%02x", b)); // } // // return sb.toString(); // // } catch (NoSuchAlgorithmException e) {} catch (InvalidKeyException e) {} // // return ""; // } // // public static String md5(String key) { // return md5(key.getBytes()); // } // // public static String md5(byte[] input) { // String cacheKey = null; // try { // final MessageDigest mDigest = MessageDigest.getInstance("MD5"); // mDigest.update(input); // cacheKey = bytesToHexString(mDigest.digest()); // } catch (NoSuchAlgorithmException e) {} // return cacheKey; // } // // private static String bytesToHexString(byte[] bytes) { // // http://stackoverflow.com/questions/332079 // StringBuilder sb = new StringBuilder(); // for (int i = 0; i < bytes.length; i++) { // String hex = Integer.toHexString(0xFF & bytes[i]); // if (hex.length() == 1) { // sb.append('0'); // } // sb.append(hex); // } // return sb.toString(); // } // } // Path: phone/src/mobi/espier/lgc/data/LgcDataUtil.java import java.util.ArrayList; import java.util.List; import mobi.espier.lgc.util.SecurityUtils; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.net.Uri; import android.text.TextUtils; /* * Copyright (C) 2010~2014 FMSoft (Espier Studio) * * This program is free software: you can redistribute it and/or modify it under the terms of the * GNU Affero General Public License as published by the Free Software Foundation, either version 3 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License along with this program. * If not, see <http://www.gnu.org/licenses/>. */ package mobi.espier.lgc.data; public class LgcDataUtil { public static Uri saveNotification(Context context, String name, String content, int type, long time) { if (content == null || TextUtils.isEmpty(name) || TextUtils.isEmpty(content)) { return null; }
String hash = SecurityUtils.md5(name + content + time);
a11n/devfest-2016-realm
app/src/pro/java/gdg/devfest/passwordmanager/framework/ProApplication.java
// Path: app/src/pro/java/gdg/devfest/passwordmanager/model/LoginInteractor.java // public class LoginInteractor { // private static final String AUTH_URL = "http://" + BuildConfig.REALM + "/auth"; // private static final String SERVER_URL = "realm://" + BuildConfig.REALM + "/~/default"; // // public Single<User> signIn(String userName, String password) { // return login(userName, password, false); // } // // public Single<User> signUp(String userName, String password) { // return login(userName, password, true); // } // // public void setRealmSyncConfiguration(User user) { // SyncConfiguration configuration = new SyncConfiguration.Builder(user, SERVER_URL).build(); // Realm.setDefaultConfiguration(configuration); // } // // @NonNull private Single<User> login(String userName, String password, boolean createUser) { // return Single.create(singleSubscriber -> { // try { // Credentials credentials = Credentials.usernamePassword(userName, password, createUser); // User user = User.login(credentials, AUTH_URL); // singleSubscriber.onSuccess(user); // } catch (Exception e) { // singleSubscriber.onError(e); // } // }); // } // }
import gdg.devfest.passwordmanager.model.LoginInteractor; import io.realm.Realm; import io.realm.User;
package gdg.devfest.passwordmanager.framework; public class ProApplication extends PasswordManagerApplication { @Override protected void initRealm() { Realm.init(this); User user = User.currentUser();
// Path: app/src/pro/java/gdg/devfest/passwordmanager/model/LoginInteractor.java // public class LoginInteractor { // private static final String AUTH_URL = "http://" + BuildConfig.REALM + "/auth"; // private static final String SERVER_URL = "realm://" + BuildConfig.REALM + "/~/default"; // // public Single<User> signIn(String userName, String password) { // return login(userName, password, false); // } // // public Single<User> signUp(String userName, String password) { // return login(userName, password, true); // } // // public void setRealmSyncConfiguration(User user) { // SyncConfiguration configuration = new SyncConfiguration.Builder(user, SERVER_URL).build(); // Realm.setDefaultConfiguration(configuration); // } // // @NonNull private Single<User> login(String userName, String password, boolean createUser) { // return Single.create(singleSubscriber -> { // try { // Credentials credentials = Credentials.usernamePassword(userName, password, createUser); // User user = User.login(credentials, AUTH_URL); // singleSubscriber.onSuccess(user); // } catch (Exception e) { // singleSubscriber.onError(e); // } // }); // } // } // Path: app/src/pro/java/gdg/devfest/passwordmanager/framework/ProApplication.java import gdg.devfest.passwordmanager.model.LoginInteractor; import io.realm.Realm; import io.realm.User; package gdg.devfest.passwordmanager.framework; public class ProApplication extends PasswordManagerApplication { @Override protected void initRealm() { Realm.init(this); User user = User.currentUser();
if (user != null) new LoginInteractor().setRealmSyncConfiguration(user);
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/CustomFieldDialog.java // public class CustomFieldDialog extends DialogFragment { // private static final String TITLE = "TITLE"; // private static final String NAME = "NAME"; // private static final String VALUE = "VALUE"; // // private OnCustomFieldSubmitListener customFieldSubmitListener; // private OnCustomFieldDeleteListener customFieldDeleteListener; // // public static CustomFieldDialog newInstance(String title, String name, String value, // OnCustomFieldSubmitListener customFieldSubmitListener, // OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog fragment = new CustomFieldDialog(); // // //TODO: Pass via bundle // fragment.customFieldSubmitListener = customFieldSubmitListener; // fragment.customFieldDeleteListener = customFieldDeleteListener; // // Bundle arguments = new Bundle(); // arguments.putString(TITLE, title); // arguments.putString(NAME, name); // arguments.putString(VALUE, value); // fragment.setArguments(arguments); // // return fragment; // } // // @Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // setRetainInstance(true); // } // // @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // String title = getArguments().getString(TITLE); // String name = getArguments().getString(NAME); // String value = getArguments().getString(VALUE); // // View view = LayoutInflater.from(getContext()).inflate(R.layout.custom_field_dialog, null); // EditText etName = ((EditText) view.findViewById(R.id.etName)); // EditText etValue = ((EditText) view.findViewById(R.id.etValue)); // // etName.setText(name); // etValue.setText(value); // // AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(title) // .setView(view) // .setPositiveButton("OK", // (dialog1, which) -> handleOk(etName.getText().toString(), etValue.getText().toString())) // .setNegativeButton("Cancel", null) // .setCancelable(true); // // if (customFieldDeleteListener != null) { // builder.setNeutralButton("Delete", (dialog1, which) -> handleDelete()); // } // // return builder.create(); // } // // private void handleOk(String name, String value) { // if (customFieldSubmitListener != null) customFieldSubmitListener.submit(name, value); // } // // private void handleDelete() { // customFieldDeleteListener.delete(); // } // // public interface OnCustomFieldSubmitListener { // void submit(String name, String value); // } // // public interface OnCustomFieldDeleteListener { // void delete(); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordCreateActivity.java // public class PasswordCreateActivity // extends PasswordManagerActivity<PasswordCreateActivityBinding, PasswordCreateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordCreateViewModel createViewModel() { // return new PasswordCreateViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordReadActivity.java // public class PasswordReadActivity // extends PasswordManagerActivity<PasswordReadActivityBinding, PasswordReadViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordReadViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordReadViewModel(new Navigator(this), new PasswordInteractor(realm), id); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordUpdateActivity.java // public class PasswordUpdateActivity // extends PasswordManagerActivity<PasswordUpdateActivityBinding, PasswordUpdateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected void onInitBinding() { // super.onInitBinding(); // // setTitle(viewModel.name.get()); // } // // @Override protected PasswordUpdateViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordUpdateViewModel(new Navigator(this), new PasswordInteractor(realm), // id); // } // }
import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.CustomFieldDialog; import gdg.devfest.passwordmanager.view.PasswordCreateActivity; import gdg.devfest.passwordmanager.view.PasswordReadActivity; import gdg.devfest.passwordmanager.view.PasswordUpdateActivity; import pl.coreorb.selectiondialogs.dialogs.IconSelectDialog;
package gdg.devfest.passwordmanager.framework; public class Navigator { protected final AppCompatActivity activity; public Navigator(AppCompatActivity activity) { this.activity = activity; } public void startCreatePassword() {
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/CustomFieldDialog.java // public class CustomFieldDialog extends DialogFragment { // private static final String TITLE = "TITLE"; // private static final String NAME = "NAME"; // private static final String VALUE = "VALUE"; // // private OnCustomFieldSubmitListener customFieldSubmitListener; // private OnCustomFieldDeleteListener customFieldDeleteListener; // // public static CustomFieldDialog newInstance(String title, String name, String value, // OnCustomFieldSubmitListener customFieldSubmitListener, // OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog fragment = new CustomFieldDialog(); // // //TODO: Pass via bundle // fragment.customFieldSubmitListener = customFieldSubmitListener; // fragment.customFieldDeleteListener = customFieldDeleteListener; // // Bundle arguments = new Bundle(); // arguments.putString(TITLE, title); // arguments.putString(NAME, name); // arguments.putString(VALUE, value); // fragment.setArguments(arguments); // // return fragment; // } // // @Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // setRetainInstance(true); // } // // @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // String title = getArguments().getString(TITLE); // String name = getArguments().getString(NAME); // String value = getArguments().getString(VALUE); // // View view = LayoutInflater.from(getContext()).inflate(R.layout.custom_field_dialog, null); // EditText etName = ((EditText) view.findViewById(R.id.etName)); // EditText etValue = ((EditText) view.findViewById(R.id.etValue)); // // etName.setText(name); // etValue.setText(value); // // AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(title) // .setView(view) // .setPositiveButton("OK", // (dialog1, which) -> handleOk(etName.getText().toString(), etValue.getText().toString())) // .setNegativeButton("Cancel", null) // .setCancelable(true); // // if (customFieldDeleteListener != null) { // builder.setNeutralButton("Delete", (dialog1, which) -> handleDelete()); // } // // return builder.create(); // } // // private void handleOk(String name, String value) { // if (customFieldSubmitListener != null) customFieldSubmitListener.submit(name, value); // } // // private void handleDelete() { // customFieldDeleteListener.delete(); // } // // public interface OnCustomFieldSubmitListener { // void submit(String name, String value); // } // // public interface OnCustomFieldDeleteListener { // void delete(); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordCreateActivity.java // public class PasswordCreateActivity // extends PasswordManagerActivity<PasswordCreateActivityBinding, PasswordCreateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordCreateViewModel createViewModel() { // return new PasswordCreateViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordReadActivity.java // public class PasswordReadActivity // extends PasswordManagerActivity<PasswordReadActivityBinding, PasswordReadViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordReadViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordReadViewModel(new Navigator(this), new PasswordInteractor(realm), id); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordUpdateActivity.java // public class PasswordUpdateActivity // extends PasswordManagerActivity<PasswordUpdateActivityBinding, PasswordUpdateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected void onInitBinding() { // super.onInitBinding(); // // setTitle(viewModel.name.get()); // } // // @Override protected PasswordUpdateViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordUpdateViewModel(new Navigator(this), new PasswordInteractor(realm), // id); // } // } // Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.CustomFieldDialog; import gdg.devfest.passwordmanager.view.PasswordCreateActivity; import gdg.devfest.passwordmanager.view.PasswordReadActivity; import gdg.devfest.passwordmanager.view.PasswordUpdateActivity; import pl.coreorb.selectiondialogs.dialogs.IconSelectDialog; package gdg.devfest.passwordmanager.framework; public class Navigator { protected final AppCompatActivity activity; public Navigator(AppCompatActivity activity) { this.activity = activity; } public void startCreatePassword() {
activity.startActivity(new Intent(activity, PasswordCreateActivity.class));
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/CustomFieldDialog.java // public class CustomFieldDialog extends DialogFragment { // private static final String TITLE = "TITLE"; // private static final String NAME = "NAME"; // private static final String VALUE = "VALUE"; // // private OnCustomFieldSubmitListener customFieldSubmitListener; // private OnCustomFieldDeleteListener customFieldDeleteListener; // // public static CustomFieldDialog newInstance(String title, String name, String value, // OnCustomFieldSubmitListener customFieldSubmitListener, // OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog fragment = new CustomFieldDialog(); // // //TODO: Pass via bundle // fragment.customFieldSubmitListener = customFieldSubmitListener; // fragment.customFieldDeleteListener = customFieldDeleteListener; // // Bundle arguments = new Bundle(); // arguments.putString(TITLE, title); // arguments.putString(NAME, name); // arguments.putString(VALUE, value); // fragment.setArguments(arguments); // // return fragment; // } // // @Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // setRetainInstance(true); // } // // @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // String title = getArguments().getString(TITLE); // String name = getArguments().getString(NAME); // String value = getArguments().getString(VALUE); // // View view = LayoutInflater.from(getContext()).inflate(R.layout.custom_field_dialog, null); // EditText etName = ((EditText) view.findViewById(R.id.etName)); // EditText etValue = ((EditText) view.findViewById(R.id.etValue)); // // etName.setText(name); // etValue.setText(value); // // AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(title) // .setView(view) // .setPositiveButton("OK", // (dialog1, which) -> handleOk(etName.getText().toString(), etValue.getText().toString())) // .setNegativeButton("Cancel", null) // .setCancelable(true); // // if (customFieldDeleteListener != null) { // builder.setNeutralButton("Delete", (dialog1, which) -> handleDelete()); // } // // return builder.create(); // } // // private void handleOk(String name, String value) { // if (customFieldSubmitListener != null) customFieldSubmitListener.submit(name, value); // } // // private void handleDelete() { // customFieldDeleteListener.delete(); // } // // public interface OnCustomFieldSubmitListener { // void submit(String name, String value); // } // // public interface OnCustomFieldDeleteListener { // void delete(); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordCreateActivity.java // public class PasswordCreateActivity // extends PasswordManagerActivity<PasswordCreateActivityBinding, PasswordCreateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordCreateViewModel createViewModel() { // return new PasswordCreateViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordReadActivity.java // public class PasswordReadActivity // extends PasswordManagerActivity<PasswordReadActivityBinding, PasswordReadViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordReadViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordReadViewModel(new Navigator(this), new PasswordInteractor(realm), id); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordUpdateActivity.java // public class PasswordUpdateActivity // extends PasswordManagerActivity<PasswordUpdateActivityBinding, PasswordUpdateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected void onInitBinding() { // super.onInitBinding(); // // setTitle(viewModel.name.get()); // } // // @Override protected PasswordUpdateViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordUpdateViewModel(new Navigator(this), new PasswordInteractor(realm), // id); // } // }
import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.CustomFieldDialog; import gdg.devfest.passwordmanager.view.PasswordCreateActivity; import gdg.devfest.passwordmanager.view.PasswordReadActivity; import gdg.devfest.passwordmanager.view.PasswordUpdateActivity; import pl.coreorb.selectiondialogs.dialogs.IconSelectDialog;
package gdg.devfest.passwordmanager.framework; public class Navigator { protected final AppCompatActivity activity; public Navigator(AppCompatActivity activity) { this.activity = activity; } public void startCreatePassword() { activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); } public void finish() { activity.finish(); } public void startReadPassword(int passwordId) { activity.startActivity(
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/CustomFieldDialog.java // public class CustomFieldDialog extends DialogFragment { // private static final String TITLE = "TITLE"; // private static final String NAME = "NAME"; // private static final String VALUE = "VALUE"; // // private OnCustomFieldSubmitListener customFieldSubmitListener; // private OnCustomFieldDeleteListener customFieldDeleteListener; // // public static CustomFieldDialog newInstance(String title, String name, String value, // OnCustomFieldSubmitListener customFieldSubmitListener, // OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog fragment = new CustomFieldDialog(); // // //TODO: Pass via bundle // fragment.customFieldSubmitListener = customFieldSubmitListener; // fragment.customFieldDeleteListener = customFieldDeleteListener; // // Bundle arguments = new Bundle(); // arguments.putString(TITLE, title); // arguments.putString(NAME, name); // arguments.putString(VALUE, value); // fragment.setArguments(arguments); // // return fragment; // } // // @Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // setRetainInstance(true); // } // // @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // String title = getArguments().getString(TITLE); // String name = getArguments().getString(NAME); // String value = getArguments().getString(VALUE); // // View view = LayoutInflater.from(getContext()).inflate(R.layout.custom_field_dialog, null); // EditText etName = ((EditText) view.findViewById(R.id.etName)); // EditText etValue = ((EditText) view.findViewById(R.id.etValue)); // // etName.setText(name); // etValue.setText(value); // // AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(title) // .setView(view) // .setPositiveButton("OK", // (dialog1, which) -> handleOk(etName.getText().toString(), etValue.getText().toString())) // .setNegativeButton("Cancel", null) // .setCancelable(true); // // if (customFieldDeleteListener != null) { // builder.setNeutralButton("Delete", (dialog1, which) -> handleDelete()); // } // // return builder.create(); // } // // private void handleOk(String name, String value) { // if (customFieldSubmitListener != null) customFieldSubmitListener.submit(name, value); // } // // private void handleDelete() { // customFieldDeleteListener.delete(); // } // // public interface OnCustomFieldSubmitListener { // void submit(String name, String value); // } // // public interface OnCustomFieldDeleteListener { // void delete(); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordCreateActivity.java // public class PasswordCreateActivity // extends PasswordManagerActivity<PasswordCreateActivityBinding, PasswordCreateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordCreateViewModel createViewModel() { // return new PasswordCreateViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordReadActivity.java // public class PasswordReadActivity // extends PasswordManagerActivity<PasswordReadActivityBinding, PasswordReadViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordReadViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordReadViewModel(new Navigator(this), new PasswordInteractor(realm), id); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordUpdateActivity.java // public class PasswordUpdateActivity // extends PasswordManagerActivity<PasswordUpdateActivityBinding, PasswordUpdateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected void onInitBinding() { // super.onInitBinding(); // // setTitle(viewModel.name.get()); // } // // @Override protected PasswordUpdateViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordUpdateViewModel(new Navigator(this), new PasswordInteractor(realm), // id); // } // } // Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.CustomFieldDialog; import gdg.devfest.passwordmanager.view.PasswordCreateActivity; import gdg.devfest.passwordmanager.view.PasswordReadActivity; import gdg.devfest.passwordmanager.view.PasswordUpdateActivity; import pl.coreorb.selectiondialogs.dialogs.IconSelectDialog; package gdg.devfest.passwordmanager.framework; public class Navigator { protected final AppCompatActivity activity; public Navigator(AppCompatActivity activity) { this.activity = activity; } public void startCreatePassword() { activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); } public void finish() { activity.finish(); } public void startReadPassword(int passwordId) { activity.startActivity(
new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId));
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/CustomFieldDialog.java // public class CustomFieldDialog extends DialogFragment { // private static final String TITLE = "TITLE"; // private static final String NAME = "NAME"; // private static final String VALUE = "VALUE"; // // private OnCustomFieldSubmitListener customFieldSubmitListener; // private OnCustomFieldDeleteListener customFieldDeleteListener; // // public static CustomFieldDialog newInstance(String title, String name, String value, // OnCustomFieldSubmitListener customFieldSubmitListener, // OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog fragment = new CustomFieldDialog(); // // //TODO: Pass via bundle // fragment.customFieldSubmitListener = customFieldSubmitListener; // fragment.customFieldDeleteListener = customFieldDeleteListener; // // Bundle arguments = new Bundle(); // arguments.putString(TITLE, title); // arguments.putString(NAME, name); // arguments.putString(VALUE, value); // fragment.setArguments(arguments); // // return fragment; // } // // @Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // setRetainInstance(true); // } // // @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // String title = getArguments().getString(TITLE); // String name = getArguments().getString(NAME); // String value = getArguments().getString(VALUE); // // View view = LayoutInflater.from(getContext()).inflate(R.layout.custom_field_dialog, null); // EditText etName = ((EditText) view.findViewById(R.id.etName)); // EditText etValue = ((EditText) view.findViewById(R.id.etValue)); // // etName.setText(name); // etValue.setText(value); // // AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(title) // .setView(view) // .setPositiveButton("OK", // (dialog1, which) -> handleOk(etName.getText().toString(), etValue.getText().toString())) // .setNegativeButton("Cancel", null) // .setCancelable(true); // // if (customFieldDeleteListener != null) { // builder.setNeutralButton("Delete", (dialog1, which) -> handleDelete()); // } // // return builder.create(); // } // // private void handleOk(String name, String value) { // if (customFieldSubmitListener != null) customFieldSubmitListener.submit(name, value); // } // // private void handleDelete() { // customFieldDeleteListener.delete(); // } // // public interface OnCustomFieldSubmitListener { // void submit(String name, String value); // } // // public interface OnCustomFieldDeleteListener { // void delete(); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordCreateActivity.java // public class PasswordCreateActivity // extends PasswordManagerActivity<PasswordCreateActivityBinding, PasswordCreateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordCreateViewModel createViewModel() { // return new PasswordCreateViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordReadActivity.java // public class PasswordReadActivity // extends PasswordManagerActivity<PasswordReadActivityBinding, PasswordReadViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordReadViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordReadViewModel(new Navigator(this), new PasswordInteractor(realm), id); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordUpdateActivity.java // public class PasswordUpdateActivity // extends PasswordManagerActivity<PasswordUpdateActivityBinding, PasswordUpdateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected void onInitBinding() { // super.onInitBinding(); // // setTitle(viewModel.name.get()); // } // // @Override protected PasswordUpdateViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordUpdateViewModel(new Navigator(this), new PasswordInteractor(realm), // id); // } // }
import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.CustomFieldDialog; import gdg.devfest.passwordmanager.view.PasswordCreateActivity; import gdg.devfest.passwordmanager.view.PasswordReadActivity; import gdg.devfest.passwordmanager.view.PasswordUpdateActivity; import pl.coreorb.selectiondialogs.dialogs.IconSelectDialog;
package gdg.devfest.passwordmanager.framework; public class Navigator { protected final AppCompatActivity activity; public Navigator(AppCompatActivity activity) { this.activity = activity; } public void startCreatePassword() { activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); } public void finish() { activity.finish(); } public void startReadPassword(int passwordId) { activity.startActivity( new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); } public void startUpdatePassword(int passwordId) { activity.startActivity(
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/CustomFieldDialog.java // public class CustomFieldDialog extends DialogFragment { // private static final String TITLE = "TITLE"; // private static final String NAME = "NAME"; // private static final String VALUE = "VALUE"; // // private OnCustomFieldSubmitListener customFieldSubmitListener; // private OnCustomFieldDeleteListener customFieldDeleteListener; // // public static CustomFieldDialog newInstance(String title, String name, String value, // OnCustomFieldSubmitListener customFieldSubmitListener, // OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog fragment = new CustomFieldDialog(); // // //TODO: Pass via bundle // fragment.customFieldSubmitListener = customFieldSubmitListener; // fragment.customFieldDeleteListener = customFieldDeleteListener; // // Bundle arguments = new Bundle(); // arguments.putString(TITLE, title); // arguments.putString(NAME, name); // arguments.putString(VALUE, value); // fragment.setArguments(arguments); // // return fragment; // } // // @Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // setRetainInstance(true); // } // // @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // String title = getArguments().getString(TITLE); // String name = getArguments().getString(NAME); // String value = getArguments().getString(VALUE); // // View view = LayoutInflater.from(getContext()).inflate(R.layout.custom_field_dialog, null); // EditText etName = ((EditText) view.findViewById(R.id.etName)); // EditText etValue = ((EditText) view.findViewById(R.id.etValue)); // // etName.setText(name); // etValue.setText(value); // // AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(title) // .setView(view) // .setPositiveButton("OK", // (dialog1, which) -> handleOk(etName.getText().toString(), etValue.getText().toString())) // .setNegativeButton("Cancel", null) // .setCancelable(true); // // if (customFieldDeleteListener != null) { // builder.setNeutralButton("Delete", (dialog1, which) -> handleDelete()); // } // // return builder.create(); // } // // private void handleOk(String name, String value) { // if (customFieldSubmitListener != null) customFieldSubmitListener.submit(name, value); // } // // private void handleDelete() { // customFieldDeleteListener.delete(); // } // // public interface OnCustomFieldSubmitListener { // void submit(String name, String value); // } // // public interface OnCustomFieldDeleteListener { // void delete(); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordCreateActivity.java // public class PasswordCreateActivity // extends PasswordManagerActivity<PasswordCreateActivityBinding, PasswordCreateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordCreateViewModel createViewModel() { // return new PasswordCreateViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordReadActivity.java // public class PasswordReadActivity // extends PasswordManagerActivity<PasswordReadActivityBinding, PasswordReadViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordReadViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordReadViewModel(new Navigator(this), new PasswordInteractor(realm), id); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordUpdateActivity.java // public class PasswordUpdateActivity // extends PasswordManagerActivity<PasswordUpdateActivityBinding, PasswordUpdateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected void onInitBinding() { // super.onInitBinding(); // // setTitle(viewModel.name.get()); // } // // @Override protected PasswordUpdateViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordUpdateViewModel(new Navigator(this), new PasswordInteractor(realm), // id); // } // } // Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.CustomFieldDialog; import gdg.devfest.passwordmanager.view.PasswordCreateActivity; import gdg.devfest.passwordmanager.view.PasswordReadActivity; import gdg.devfest.passwordmanager.view.PasswordUpdateActivity; import pl.coreorb.selectiondialogs.dialogs.IconSelectDialog; package gdg.devfest.passwordmanager.framework; public class Navigator { protected final AppCompatActivity activity; public Navigator(AppCompatActivity activity) { this.activity = activity; } public void startCreatePassword() { activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); } public void finish() { activity.finish(); } public void startReadPassword(int passwordId) { activity.startActivity( new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); } public void startUpdatePassword(int passwordId) { activity.startActivity(
new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId));
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/CustomFieldDialog.java // public class CustomFieldDialog extends DialogFragment { // private static final String TITLE = "TITLE"; // private static final String NAME = "NAME"; // private static final String VALUE = "VALUE"; // // private OnCustomFieldSubmitListener customFieldSubmitListener; // private OnCustomFieldDeleteListener customFieldDeleteListener; // // public static CustomFieldDialog newInstance(String title, String name, String value, // OnCustomFieldSubmitListener customFieldSubmitListener, // OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog fragment = new CustomFieldDialog(); // // //TODO: Pass via bundle // fragment.customFieldSubmitListener = customFieldSubmitListener; // fragment.customFieldDeleteListener = customFieldDeleteListener; // // Bundle arguments = new Bundle(); // arguments.putString(TITLE, title); // arguments.putString(NAME, name); // arguments.putString(VALUE, value); // fragment.setArguments(arguments); // // return fragment; // } // // @Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // setRetainInstance(true); // } // // @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // String title = getArguments().getString(TITLE); // String name = getArguments().getString(NAME); // String value = getArguments().getString(VALUE); // // View view = LayoutInflater.from(getContext()).inflate(R.layout.custom_field_dialog, null); // EditText etName = ((EditText) view.findViewById(R.id.etName)); // EditText etValue = ((EditText) view.findViewById(R.id.etValue)); // // etName.setText(name); // etValue.setText(value); // // AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(title) // .setView(view) // .setPositiveButton("OK", // (dialog1, which) -> handleOk(etName.getText().toString(), etValue.getText().toString())) // .setNegativeButton("Cancel", null) // .setCancelable(true); // // if (customFieldDeleteListener != null) { // builder.setNeutralButton("Delete", (dialog1, which) -> handleDelete()); // } // // return builder.create(); // } // // private void handleOk(String name, String value) { // if (customFieldSubmitListener != null) customFieldSubmitListener.submit(name, value); // } // // private void handleDelete() { // customFieldDeleteListener.delete(); // } // // public interface OnCustomFieldSubmitListener { // void submit(String name, String value); // } // // public interface OnCustomFieldDeleteListener { // void delete(); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordCreateActivity.java // public class PasswordCreateActivity // extends PasswordManagerActivity<PasswordCreateActivityBinding, PasswordCreateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordCreateViewModel createViewModel() { // return new PasswordCreateViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordReadActivity.java // public class PasswordReadActivity // extends PasswordManagerActivity<PasswordReadActivityBinding, PasswordReadViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordReadViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordReadViewModel(new Navigator(this), new PasswordInteractor(realm), id); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordUpdateActivity.java // public class PasswordUpdateActivity // extends PasswordManagerActivity<PasswordUpdateActivityBinding, PasswordUpdateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected void onInitBinding() { // super.onInitBinding(); // // setTitle(viewModel.name.get()); // } // // @Override protected PasswordUpdateViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordUpdateViewModel(new Navigator(this), new PasswordInteractor(realm), // id); // } // }
import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.CustomFieldDialog; import gdg.devfest.passwordmanager.view.PasswordCreateActivity; import gdg.devfest.passwordmanager.view.PasswordReadActivity; import gdg.devfest.passwordmanager.view.PasswordUpdateActivity; import pl.coreorb.selectiondialogs.dialogs.IconSelectDialog;
package gdg.devfest.passwordmanager.framework; public class Navigator { protected final AppCompatActivity activity; public Navigator(AppCompatActivity activity) { this.activity = activity; } public void startCreatePassword() { activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); } public void finish() { activity.finish(); } public void startReadPassword(int passwordId) { activity.startActivity( new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); } public void startUpdatePassword(int passwordId) { activity.startActivity( new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); } public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) .setTitle("Choose icon") .setSortIconsByName(true) .setOnIconSelectedListener(onIconSelectedListener) .build() .show(activity.getSupportFragmentManager(), "icons"); } public void startCreateCustomField(
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/CustomFieldDialog.java // public class CustomFieldDialog extends DialogFragment { // private static final String TITLE = "TITLE"; // private static final String NAME = "NAME"; // private static final String VALUE = "VALUE"; // // private OnCustomFieldSubmitListener customFieldSubmitListener; // private OnCustomFieldDeleteListener customFieldDeleteListener; // // public static CustomFieldDialog newInstance(String title, String name, String value, // OnCustomFieldSubmitListener customFieldSubmitListener, // OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog fragment = new CustomFieldDialog(); // // //TODO: Pass via bundle // fragment.customFieldSubmitListener = customFieldSubmitListener; // fragment.customFieldDeleteListener = customFieldDeleteListener; // // Bundle arguments = new Bundle(); // arguments.putString(TITLE, title); // arguments.putString(NAME, name); // arguments.putString(VALUE, value); // fragment.setArguments(arguments); // // return fragment; // } // // @Override public void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // setRetainInstance(true); // } // // @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // String title = getArguments().getString(TITLE); // String name = getArguments().getString(NAME); // String value = getArguments().getString(VALUE); // // View view = LayoutInflater.from(getContext()).inflate(R.layout.custom_field_dialog, null); // EditText etName = ((EditText) view.findViewById(R.id.etName)); // EditText etValue = ((EditText) view.findViewById(R.id.etValue)); // // etName.setText(name); // etValue.setText(value); // // AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()).setTitle(title) // .setView(view) // .setPositiveButton("OK", // (dialog1, which) -> handleOk(etName.getText().toString(), etValue.getText().toString())) // .setNegativeButton("Cancel", null) // .setCancelable(true); // // if (customFieldDeleteListener != null) { // builder.setNeutralButton("Delete", (dialog1, which) -> handleDelete()); // } // // return builder.create(); // } // // private void handleOk(String name, String value) { // if (customFieldSubmitListener != null) customFieldSubmitListener.submit(name, value); // } // // private void handleDelete() { // customFieldDeleteListener.delete(); // } // // public interface OnCustomFieldSubmitListener { // void submit(String name, String value); // } // // public interface OnCustomFieldDeleteListener { // void delete(); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordCreateActivity.java // public class PasswordCreateActivity // extends PasswordManagerActivity<PasswordCreateActivityBinding, PasswordCreateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordCreateViewModel createViewModel() { // return new PasswordCreateViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordReadActivity.java // public class PasswordReadActivity // extends PasswordManagerActivity<PasswordReadActivityBinding, PasswordReadViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected PasswordReadViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordReadViewModel(new Navigator(this), new PasswordInteractor(realm), id); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordUpdateActivity.java // public class PasswordUpdateActivity // extends PasswordManagerActivity<PasswordUpdateActivityBinding, PasswordUpdateViewModel> { // // @Override protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // } // // @Override protected void onInitBinding() { // super.onInitBinding(); // // setTitle(viewModel.name.get()); // } // // @Override protected PasswordUpdateViewModel createViewModel() { // int id = getIntent().getIntExtra("id", 0); // return new PasswordUpdateViewModel(new Navigator(this), new PasswordInteractor(realm), // id); // } // } // Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.CustomFieldDialog; import gdg.devfest.passwordmanager.view.PasswordCreateActivity; import gdg.devfest.passwordmanager.view.PasswordReadActivity; import gdg.devfest.passwordmanager.view.PasswordUpdateActivity; import pl.coreorb.selectiondialogs.dialogs.IconSelectDialog; package gdg.devfest.passwordmanager.framework; public class Navigator { protected final AppCompatActivity activity; public Navigator(AppCompatActivity activity) { this.activity = activity; } public void startCreatePassword() { activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); } public void finish() { activity.finish(); } public void startReadPassword(int passwordId) { activity.startActivity( new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); } public void startUpdatePassword(int passwordId) { activity.startActivity( new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); } public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) .setTitle("Choose icon") .setSortIconsByName(true) .setOnIconSelectedListener(onIconSelectedListener) .build() .show(activity.getSupportFragmentManager(), "icons"); } public void startCreateCustomField(
CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) {
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/view/PasswordListActivity.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java // public class Navigator { // protected final AppCompatActivity activity; // // public Navigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void startCreatePassword() { // activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); // } // // public void finish() { // activity.finish(); // } // // public void startReadPassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); // } // // public void startUpdatePassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); // } // // public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { // new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) // .setTitle("Choose icon") // .setSortIconsByName(true) // .setOnIconSelectedListener(onIconSelectedListener) // .build() // .show(activity.getSupportFragmentManager(), "icons"); // } // // public void startCreateCustomField( // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) { // CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null) // .show(activity.getSupportFragmentManager(), "field"); // } // // public void startUpdateCustomField(String name, String value, // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener, // CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener, // customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field"); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java // public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel> // extends ToolbarActivity<B, VM> { // // @CallSuper @Override protected void onInitBinding() { // binding.setVariable(BR.viewModel, viewModel); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/model/PasswordInteractor.java // public class PasswordInteractor { // private final Realm realm; // // public PasswordInteractor(Realm realm) { // this.realm = realm; // } // // public RealmResults<Password> readPasswords() { // return realm.where(Password.class).findAll(); // } // // public void createPassword(String icon, String name, String userName, String password, // List<CustomField> customFields) { // Password passwordEntity = new Password(id(), icon, name, userName, password, customFields); // realm.executeTransaction(realm1 -> realm1.copyToRealm(passwordEntity)); // } // // public Password readPassword(int id) { // return realm.where(Password.class).equalTo("id", id).findFirst(); // } // // public void updatePassword(Password realmPassword, String icon, String name, String userName, // String password, List<CustomField> customFields) { // realm.executeTransaction(realm1 -> { // realmPassword.setIcon(icon); // realmPassword.setName(name); // realmPassword.setUserName(userName); // realmPassword.setPassword(password); // realmPassword.getCustomFields().deleteAllFromRealm(); // realmPassword.getCustomFields().addAll(customFields); // }); // } // // public void deletePassword(Password password) { // realm.executeTransaction(realm1 -> { // password.getCustomFields().deleteAllFromRealm(); // password.deleteFromRealm(); // }); // } // // private int id() { // Number number = realm.where(Password.class).max("id"); // return number != null ? number.intValue() + 1 : 0; // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordListViewModel.java // public class PasswordListViewModel implements ViewModel { // private final Navigator navigator; // private final RealmResults<Password> realmPasswords; // // public ObservableList<PasswordItemViewModel> passwords; // // public PasswordListViewModel(Navigator navigator, PasswordInteractor interactor) { // this.navigator = navigator; // // passwords = new ObservableArrayList<>(); // realmPasswords = interactor.readPasswords(); // realmPasswords.addChangeListener(this::updateList); // // updateList(realmPasswords); // } // // public void navigateToCreatePassword() { // navigator.startCreatePassword(); // } // // private void updateList(RealmResults<Password> realmPasswords) { // passwords.clear(); // passwords.addAll(PasswordItemViewModel.toViewModels(realmPasswords, navigator)); // } // }
import gdg.devfest.passwordmanager.databinding.PasswordListActivityBinding; import gdg.devfest.passwordmanager.framework.Navigator; import gdg.devfest.passwordmanager.framework.PasswordManagerActivity; import gdg.devfest.passwordmanager.model.PasswordInteractor; import gdg.devfest.passwordmanager.viewmodel.PasswordListViewModel;
package gdg.devfest.passwordmanager.view; public class PasswordListActivity extends PasswordManagerActivity<PasswordListActivityBinding, PasswordListViewModel> { @Override protected PasswordListViewModel createViewModel() {
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java // public class Navigator { // protected final AppCompatActivity activity; // // public Navigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void startCreatePassword() { // activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); // } // // public void finish() { // activity.finish(); // } // // public void startReadPassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); // } // // public void startUpdatePassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); // } // // public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { // new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) // .setTitle("Choose icon") // .setSortIconsByName(true) // .setOnIconSelectedListener(onIconSelectedListener) // .build() // .show(activity.getSupportFragmentManager(), "icons"); // } // // public void startCreateCustomField( // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) { // CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null) // .show(activity.getSupportFragmentManager(), "field"); // } // // public void startUpdateCustomField(String name, String value, // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener, // CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener, // customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field"); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java // public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel> // extends ToolbarActivity<B, VM> { // // @CallSuper @Override protected void onInitBinding() { // binding.setVariable(BR.viewModel, viewModel); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/model/PasswordInteractor.java // public class PasswordInteractor { // private final Realm realm; // // public PasswordInteractor(Realm realm) { // this.realm = realm; // } // // public RealmResults<Password> readPasswords() { // return realm.where(Password.class).findAll(); // } // // public void createPassword(String icon, String name, String userName, String password, // List<CustomField> customFields) { // Password passwordEntity = new Password(id(), icon, name, userName, password, customFields); // realm.executeTransaction(realm1 -> realm1.copyToRealm(passwordEntity)); // } // // public Password readPassword(int id) { // return realm.where(Password.class).equalTo("id", id).findFirst(); // } // // public void updatePassword(Password realmPassword, String icon, String name, String userName, // String password, List<CustomField> customFields) { // realm.executeTransaction(realm1 -> { // realmPassword.setIcon(icon); // realmPassword.setName(name); // realmPassword.setUserName(userName); // realmPassword.setPassword(password); // realmPassword.getCustomFields().deleteAllFromRealm(); // realmPassword.getCustomFields().addAll(customFields); // }); // } // // public void deletePassword(Password password) { // realm.executeTransaction(realm1 -> { // password.getCustomFields().deleteAllFromRealm(); // password.deleteFromRealm(); // }); // } // // private int id() { // Number number = realm.where(Password.class).max("id"); // return number != null ? number.intValue() + 1 : 0; // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordListViewModel.java // public class PasswordListViewModel implements ViewModel { // private final Navigator navigator; // private final RealmResults<Password> realmPasswords; // // public ObservableList<PasswordItemViewModel> passwords; // // public PasswordListViewModel(Navigator navigator, PasswordInteractor interactor) { // this.navigator = navigator; // // passwords = new ObservableArrayList<>(); // realmPasswords = interactor.readPasswords(); // realmPasswords.addChangeListener(this::updateList); // // updateList(realmPasswords); // } // // public void navigateToCreatePassword() { // navigator.startCreatePassword(); // } // // private void updateList(RealmResults<Password> realmPasswords) { // passwords.clear(); // passwords.addAll(PasswordItemViewModel.toViewModels(realmPasswords, navigator)); // } // } // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordListActivity.java import gdg.devfest.passwordmanager.databinding.PasswordListActivityBinding; import gdg.devfest.passwordmanager.framework.Navigator; import gdg.devfest.passwordmanager.framework.PasswordManagerActivity; import gdg.devfest.passwordmanager.model.PasswordInteractor; import gdg.devfest.passwordmanager.viewmodel.PasswordListViewModel; package gdg.devfest.passwordmanager.view; public class PasswordListActivity extends PasswordManagerActivity<PasswordListActivityBinding, PasswordListViewModel> { @Override protected PasswordListViewModel createViewModel() {
return new PasswordListViewModel(new Navigator(this), new PasswordInteractor(realm));
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/view/PasswordListActivity.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java // public class Navigator { // protected final AppCompatActivity activity; // // public Navigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void startCreatePassword() { // activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); // } // // public void finish() { // activity.finish(); // } // // public void startReadPassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); // } // // public void startUpdatePassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); // } // // public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { // new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) // .setTitle("Choose icon") // .setSortIconsByName(true) // .setOnIconSelectedListener(onIconSelectedListener) // .build() // .show(activity.getSupportFragmentManager(), "icons"); // } // // public void startCreateCustomField( // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) { // CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null) // .show(activity.getSupportFragmentManager(), "field"); // } // // public void startUpdateCustomField(String name, String value, // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener, // CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener, // customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field"); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java // public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel> // extends ToolbarActivity<B, VM> { // // @CallSuper @Override protected void onInitBinding() { // binding.setVariable(BR.viewModel, viewModel); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/model/PasswordInteractor.java // public class PasswordInteractor { // private final Realm realm; // // public PasswordInteractor(Realm realm) { // this.realm = realm; // } // // public RealmResults<Password> readPasswords() { // return realm.where(Password.class).findAll(); // } // // public void createPassword(String icon, String name, String userName, String password, // List<CustomField> customFields) { // Password passwordEntity = new Password(id(), icon, name, userName, password, customFields); // realm.executeTransaction(realm1 -> realm1.copyToRealm(passwordEntity)); // } // // public Password readPassword(int id) { // return realm.where(Password.class).equalTo("id", id).findFirst(); // } // // public void updatePassword(Password realmPassword, String icon, String name, String userName, // String password, List<CustomField> customFields) { // realm.executeTransaction(realm1 -> { // realmPassword.setIcon(icon); // realmPassword.setName(name); // realmPassword.setUserName(userName); // realmPassword.setPassword(password); // realmPassword.getCustomFields().deleteAllFromRealm(); // realmPassword.getCustomFields().addAll(customFields); // }); // } // // public void deletePassword(Password password) { // realm.executeTransaction(realm1 -> { // password.getCustomFields().deleteAllFromRealm(); // password.deleteFromRealm(); // }); // } // // private int id() { // Number number = realm.where(Password.class).max("id"); // return number != null ? number.intValue() + 1 : 0; // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordListViewModel.java // public class PasswordListViewModel implements ViewModel { // private final Navigator navigator; // private final RealmResults<Password> realmPasswords; // // public ObservableList<PasswordItemViewModel> passwords; // // public PasswordListViewModel(Navigator navigator, PasswordInteractor interactor) { // this.navigator = navigator; // // passwords = new ObservableArrayList<>(); // realmPasswords = interactor.readPasswords(); // realmPasswords.addChangeListener(this::updateList); // // updateList(realmPasswords); // } // // public void navigateToCreatePassword() { // navigator.startCreatePassword(); // } // // private void updateList(RealmResults<Password> realmPasswords) { // passwords.clear(); // passwords.addAll(PasswordItemViewModel.toViewModels(realmPasswords, navigator)); // } // }
import gdg.devfest.passwordmanager.databinding.PasswordListActivityBinding; import gdg.devfest.passwordmanager.framework.Navigator; import gdg.devfest.passwordmanager.framework.PasswordManagerActivity; import gdg.devfest.passwordmanager.model.PasswordInteractor; import gdg.devfest.passwordmanager.viewmodel.PasswordListViewModel;
package gdg.devfest.passwordmanager.view; public class PasswordListActivity extends PasswordManagerActivity<PasswordListActivityBinding, PasswordListViewModel> { @Override protected PasswordListViewModel createViewModel() {
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java // public class Navigator { // protected final AppCompatActivity activity; // // public Navigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void startCreatePassword() { // activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); // } // // public void finish() { // activity.finish(); // } // // public void startReadPassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); // } // // public void startUpdatePassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); // } // // public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { // new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) // .setTitle("Choose icon") // .setSortIconsByName(true) // .setOnIconSelectedListener(onIconSelectedListener) // .build() // .show(activity.getSupportFragmentManager(), "icons"); // } // // public void startCreateCustomField( // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) { // CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null) // .show(activity.getSupportFragmentManager(), "field"); // } // // public void startUpdateCustomField(String name, String value, // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener, // CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener, // customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field"); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java // public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel> // extends ToolbarActivity<B, VM> { // // @CallSuper @Override protected void onInitBinding() { // binding.setVariable(BR.viewModel, viewModel); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/model/PasswordInteractor.java // public class PasswordInteractor { // private final Realm realm; // // public PasswordInteractor(Realm realm) { // this.realm = realm; // } // // public RealmResults<Password> readPasswords() { // return realm.where(Password.class).findAll(); // } // // public void createPassword(String icon, String name, String userName, String password, // List<CustomField> customFields) { // Password passwordEntity = new Password(id(), icon, name, userName, password, customFields); // realm.executeTransaction(realm1 -> realm1.copyToRealm(passwordEntity)); // } // // public Password readPassword(int id) { // return realm.where(Password.class).equalTo("id", id).findFirst(); // } // // public void updatePassword(Password realmPassword, String icon, String name, String userName, // String password, List<CustomField> customFields) { // realm.executeTransaction(realm1 -> { // realmPassword.setIcon(icon); // realmPassword.setName(name); // realmPassword.setUserName(userName); // realmPassword.setPassword(password); // realmPassword.getCustomFields().deleteAllFromRealm(); // realmPassword.getCustomFields().addAll(customFields); // }); // } // // public void deletePassword(Password password) { // realm.executeTransaction(realm1 -> { // password.getCustomFields().deleteAllFromRealm(); // password.deleteFromRealm(); // }); // } // // private int id() { // Number number = realm.where(Password.class).max("id"); // return number != null ? number.intValue() + 1 : 0; // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordListViewModel.java // public class PasswordListViewModel implements ViewModel { // private final Navigator navigator; // private final RealmResults<Password> realmPasswords; // // public ObservableList<PasswordItemViewModel> passwords; // // public PasswordListViewModel(Navigator navigator, PasswordInteractor interactor) { // this.navigator = navigator; // // passwords = new ObservableArrayList<>(); // realmPasswords = interactor.readPasswords(); // realmPasswords.addChangeListener(this::updateList); // // updateList(realmPasswords); // } // // public void navigateToCreatePassword() { // navigator.startCreatePassword(); // } // // private void updateList(RealmResults<Password> realmPasswords) { // passwords.clear(); // passwords.addAll(PasswordItemViewModel.toViewModels(realmPasswords, navigator)); // } // } // Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordListActivity.java import gdg.devfest.passwordmanager.databinding.PasswordListActivityBinding; import gdg.devfest.passwordmanager.framework.Navigator; import gdg.devfest.passwordmanager.framework.PasswordManagerActivity; import gdg.devfest.passwordmanager.model.PasswordInteractor; import gdg.devfest.passwordmanager.viewmodel.PasswordListViewModel; package gdg.devfest.passwordmanager.view; public class PasswordListActivity extends PasswordManagerActivity<PasswordListActivityBinding, PasswordListViewModel> { @Override protected PasswordListViewModel createViewModel() {
return new PasswordListViewModel(new Navigator(this), new PasswordInteractor(realm));
a11n/devfest-2016-realm
app/src/pro/java/gdg/devfest/passwordmanager/viewmodel/LoginViewModel.java
// Path: app/src/pro/java/gdg/devfest/passwordmanager/framework/ProNavigator.java // public class ProNavigator extends Navigator { // public ProNavigator(AppCompatActivity activity) { // super(activity); // } // // public void startPasswordList() { // activity.startActivity(new Intent(activity, PasswordListActivity.class)); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/model/LoginInteractor.java // public class LoginInteractor { // private static final String AUTH_URL = "http://" + BuildConfig.REALM + "/auth"; // private static final String SERVER_URL = "realm://" + BuildConfig.REALM + "/~/default"; // // public Single<User> signIn(String userName, String password) { // return login(userName, password, false); // } // // public Single<User> signUp(String userName, String password) { // return login(userName, password, true); // } // // public void setRealmSyncConfiguration(User user) { // SyncConfiguration configuration = new SyncConfiguration.Builder(user, SERVER_URL).build(); // Realm.setDefaultConfiguration(configuration); // } // // @NonNull private Single<User> login(String userName, String password, boolean createUser) { // return Single.create(singleSubscriber -> { // try { // Credentials credentials = Credentials.usernamePassword(userName, password, createUser); // User user = User.login(credentials, AUTH_URL); // singleSubscriber.onSuccess(user); // } catch (Exception e) { // singleSubscriber.onError(e); // } // }); // } // }
import android.databinding.ObservableBoolean; import android.databinding.ObservableField; import gdg.devfest.passwordmanager.framework.ProNavigator; import gdg.devfest.passwordmanager.model.LoginInteractor; import io.realm.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers;
package gdg.devfest.passwordmanager.viewmodel; public class LoginViewModel implements ViewModel { private final LoginInteractor interactor;
// Path: app/src/pro/java/gdg/devfest/passwordmanager/framework/ProNavigator.java // public class ProNavigator extends Navigator { // public ProNavigator(AppCompatActivity activity) { // super(activity); // } // // public void startPasswordList() { // activity.startActivity(new Intent(activity, PasswordListActivity.class)); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/model/LoginInteractor.java // public class LoginInteractor { // private static final String AUTH_URL = "http://" + BuildConfig.REALM + "/auth"; // private static final String SERVER_URL = "realm://" + BuildConfig.REALM + "/~/default"; // // public Single<User> signIn(String userName, String password) { // return login(userName, password, false); // } // // public Single<User> signUp(String userName, String password) { // return login(userName, password, true); // } // // public void setRealmSyncConfiguration(User user) { // SyncConfiguration configuration = new SyncConfiguration.Builder(user, SERVER_URL).build(); // Realm.setDefaultConfiguration(configuration); // } // // @NonNull private Single<User> login(String userName, String password, boolean createUser) { // return Single.create(singleSubscriber -> { // try { // Credentials credentials = Credentials.usernamePassword(userName, password, createUser); // User user = User.login(credentials, AUTH_URL); // singleSubscriber.onSuccess(user); // } catch (Exception e) { // singleSubscriber.onError(e); // } // }); // } // } // Path: app/src/pro/java/gdg/devfest/passwordmanager/viewmodel/LoginViewModel.java import android.databinding.ObservableBoolean; import android.databinding.ObservableField; import gdg.devfest.passwordmanager.framework.ProNavigator; import gdg.devfest.passwordmanager.model.LoginInteractor; import io.realm.User; import rx.android.schedulers.AndroidSchedulers; import rx.schedulers.Schedulers; package gdg.devfest.passwordmanager.viewmodel; public class LoginViewModel implements ViewModel { private final LoginInteractor interactor;
private final ProNavigator navigator;
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordItemViewModel.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java // public class Navigator { // protected final AppCompatActivity activity; // // public Navigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void startCreatePassword() { // activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); // } // // public void finish() { // activity.finish(); // } // // public void startReadPassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); // } // // public void startUpdatePassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); // } // // public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { // new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) // .setTitle("Choose icon") // .setSortIconsByName(true) // .setOnIconSelectedListener(onIconSelectedListener) // .build() // .show(activity.getSupportFragmentManager(), "icons"); // } // // public void startCreateCustomField( // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) { // CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null) // .show(activity.getSupportFragmentManager(), "field"); // } // // public void startUpdateCustomField(String name, String value, // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener, // CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener, // customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field"); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/model/Password.java // public class Password extends RealmObject { // @PrimaryKey private int id; // private String icon; // private String name; // private String userName; // private String password; // private RealmList<CustomField> customFields; // // public Password() { // } // // public Password(int id, String icon, String name, String userName, String password, // List<CustomField> customFields) { // this.id = id; // this.icon = icon; // this.name = name; // this.userName = userName; // this.password = password; // this.customFields = new RealmList<>(); // this.customFields.addAll(customFields); // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // public String getIcon() { // return icon; // } // // public void setIcon(String icon) { // this.icon = icon; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getUserName() { // return userName; // } // // public void setUserName(String userName) { // this.userName = userName; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // // public RealmList<CustomField> getCustomFields() { // return customFields; // } // // public void setCustomFields(RealmList<CustomField> customFields) { // this.customFields = customFields; // } // // //Custom equals is necessary since Realm returns proxy objects // @Override public boolean equals(Object obj) { // if (!(obj instanceof Password)) return false; // // Password password = (Password) obj; // // //TODO: verify equality of CustomFields // // return this.getId() == password.getId() && this.getIcon().equals(password.getIcon()) // && this.getName().equals(password.getName()) && this.getUserName() // .equals(password.getUserName()) && this.getPassword().equals(password.getPassword()); // } // // //TODO: hashCode // }
import android.databinding.ObservableField; import android.databinding.ObservableInt; import android.support.annotation.NonNull; import gdg.devfest.passwordmanager.framework.Navigator; import gdg.devfest.passwordmanager.model.Password; import java.util.ArrayList; import java.util.List;
package gdg.devfest.passwordmanager.viewmodel; public class PasswordItemViewModel implements ViewModel { private final Navigator navigator; public final ObservableInt id; public final ObservableField<String> icon; public final ObservableField<String> name; public final ObservableField<String> userName; PasswordItemViewModel(Navigator navigator, int id, String icon, String name, String username) { this.navigator = navigator; this.id = new ObservableInt(id); this.icon = new ObservableField<>(icon); this.name = new ObservableField<>(name); this.userName = new ObservableField<>(username); }
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java // public class Navigator { // protected final AppCompatActivity activity; // // public Navigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void startCreatePassword() { // activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); // } // // public void finish() { // activity.finish(); // } // // public void startReadPassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); // } // // public void startUpdatePassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); // } // // public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { // new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) // .setTitle("Choose icon") // .setSortIconsByName(true) // .setOnIconSelectedListener(onIconSelectedListener) // .build() // .show(activity.getSupportFragmentManager(), "icons"); // } // // public void startCreateCustomField( // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) { // CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null) // .show(activity.getSupportFragmentManager(), "field"); // } // // public void startUpdateCustomField(String name, String value, // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener, // CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener, // customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field"); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/model/Password.java // public class Password extends RealmObject { // @PrimaryKey private int id; // private String icon; // private String name; // private String userName; // private String password; // private RealmList<CustomField> customFields; // // public Password() { // } // // public Password(int id, String icon, String name, String userName, String password, // List<CustomField> customFields) { // this.id = id; // this.icon = icon; // this.name = name; // this.userName = userName; // this.password = password; // this.customFields = new RealmList<>(); // this.customFields.addAll(customFields); // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // // public String getIcon() { // return icon; // } // // public void setIcon(String icon) { // this.icon = icon; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getUserName() { // return userName; // } // // public void setUserName(String userName) { // this.userName = userName; // } // // public String getPassword() { // return password; // } // // public void setPassword(String password) { // this.password = password; // } // // public RealmList<CustomField> getCustomFields() { // return customFields; // } // // public void setCustomFields(RealmList<CustomField> customFields) { // this.customFields = customFields; // } // // //Custom equals is necessary since Realm returns proxy objects // @Override public boolean equals(Object obj) { // if (!(obj instanceof Password)) return false; // // Password password = (Password) obj; // // //TODO: verify equality of CustomFields // // return this.getId() == password.getId() && this.getIcon().equals(password.getIcon()) // && this.getName().equals(password.getName()) && this.getUserName() // .equals(password.getUserName()) && this.getPassword().equals(password.getPassword()); // } // // //TODO: hashCode // } // Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordItemViewModel.java import android.databinding.ObservableField; import android.databinding.ObservableInt; import android.support.annotation.NonNull; import gdg.devfest.passwordmanager.framework.Navigator; import gdg.devfest.passwordmanager.model.Password; import java.util.ArrayList; import java.util.List; package gdg.devfest.passwordmanager.viewmodel; public class PasswordItemViewModel implements ViewModel { private final Navigator navigator; public final ObservableInt id; public final ObservableField<String> icon; public final ObservableField<String> name; public final ObservableField<String> userName; PasswordItemViewModel(Navigator navigator, int id, String icon, String name, String username) { this.navigator = navigator; this.id = new ObservableInt(id); this.icon = new ObservableField<>(icon); this.name = new ObservableField<>(name); this.userName = new ObservableField<>(username); }
public static PasswordItemViewModel of(Password password, Navigator navigator) {
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordCreateViewModel.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java // public class Navigator { // protected final AppCompatActivity activity; // // public Navigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void startCreatePassword() { // activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); // } // // public void finish() { // activity.finish(); // } // // public void startReadPassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); // } // // public void startUpdatePassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); // } // // public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { // new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) // .setTitle("Choose icon") // .setSortIconsByName(true) // .setOnIconSelectedListener(onIconSelectedListener) // .build() // .show(activity.getSupportFragmentManager(), "icons"); // } // // public void startCreateCustomField( // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) { // CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null) // .show(activity.getSupportFragmentManager(), "field"); // } // // public void startUpdateCustomField(String name, String value, // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener, // CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener, // customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field"); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/model/PasswordInteractor.java // public class PasswordInteractor { // private final Realm realm; // // public PasswordInteractor(Realm realm) { // this.realm = realm; // } // // public RealmResults<Password> readPasswords() { // return realm.where(Password.class).findAll(); // } // // public void createPassword(String icon, String name, String userName, String password, // List<CustomField> customFields) { // Password passwordEntity = new Password(id(), icon, name, userName, password, customFields); // realm.executeTransaction(realm1 -> realm1.copyToRealm(passwordEntity)); // } // // public Password readPassword(int id) { // return realm.where(Password.class).equalTo("id", id).findFirst(); // } // // public void updatePassword(Password realmPassword, String icon, String name, String userName, // String password, List<CustomField> customFields) { // realm.executeTransaction(realm1 -> { // realmPassword.setIcon(icon); // realmPassword.setName(name); // realmPassword.setUserName(userName); // realmPassword.setPassword(password); // realmPassword.getCustomFields().deleteAllFromRealm(); // realmPassword.getCustomFields().addAll(customFields); // }); // } // // public void deletePassword(Password password) { // realm.executeTransaction(realm1 -> { // password.getCustomFields().deleteAllFromRealm(); // password.deleteFromRealm(); // }); // } // // private int id() { // Number number = realm.where(Password.class).max("id"); // return number != null ? number.intValue() + 1 : 0; // } // }
import android.databinding.ObservableArrayList; import android.databinding.ObservableField; import android.databinding.ObservableList; import android.util.Base64; import gdg.devfest.passwordmanager.framework.Navigator; import gdg.devfest.passwordmanager.model.PasswordInteractor; import java.security.SecureRandom; import pl.coreorb.selectiondialogs.data.SelectableIcon;
package gdg.devfest.passwordmanager.viewmodel; public class PasswordCreateViewModel implements ViewModel { private final Navigator navigator;
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/Navigator.java // public class Navigator { // protected final AppCompatActivity activity; // // public Navigator(AppCompatActivity activity) { // this.activity = activity; // } // // public void startCreatePassword() { // activity.startActivity(new Intent(activity, PasswordCreateActivity.class)); // } // // public void finish() { // activity.finish(); // } // // public void startReadPassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordReadActivity.class).putExtra("id", passwordId)); // } // // public void startUpdatePassword(int passwordId) { // activity.startActivity( // new Intent(activity, PasswordUpdateActivity.class).putExtra("id", passwordId)); // } // // public void startChooseIcon(IconSelectDialog.OnIconSelectedListener onIconSelectedListener) { // new IconSelectDialog.Builder(activity).setIcons(Icons.ALL) // .setTitle("Choose icon") // .setSortIconsByName(true) // .setOnIconSelectedListener(onIconSelectedListener) // .build() // .show(activity.getSupportFragmentManager(), "icons"); // } // // public void startCreateCustomField( // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener) { // CustomFieldDialog.newInstance("Create custom field", "", "", customFieldSubmitListener, null) // .show(activity.getSupportFragmentManager(), "field"); // } // // public void startUpdateCustomField(String name, String value, // CustomFieldDialog.OnCustomFieldSubmitListener customFieldSubmitListener, // CustomFieldDialog.OnCustomFieldDeleteListener customFieldDeleteListener) { // CustomFieldDialog.newInstance("Update custom field", name, value, customFieldSubmitListener, // customFieldDeleteListener).show(activity.getSupportFragmentManager(), "field"); // } // } // // Path: app/src/main/java/gdg/devfest/passwordmanager/model/PasswordInteractor.java // public class PasswordInteractor { // private final Realm realm; // // public PasswordInteractor(Realm realm) { // this.realm = realm; // } // // public RealmResults<Password> readPasswords() { // return realm.where(Password.class).findAll(); // } // // public void createPassword(String icon, String name, String userName, String password, // List<CustomField> customFields) { // Password passwordEntity = new Password(id(), icon, name, userName, password, customFields); // realm.executeTransaction(realm1 -> realm1.copyToRealm(passwordEntity)); // } // // public Password readPassword(int id) { // return realm.where(Password.class).equalTo("id", id).findFirst(); // } // // public void updatePassword(Password realmPassword, String icon, String name, String userName, // String password, List<CustomField> customFields) { // realm.executeTransaction(realm1 -> { // realmPassword.setIcon(icon); // realmPassword.setName(name); // realmPassword.setUserName(userName); // realmPassword.setPassword(password); // realmPassword.getCustomFields().deleteAllFromRealm(); // realmPassword.getCustomFields().addAll(customFields); // }); // } // // public void deletePassword(Password password) { // realm.executeTransaction(realm1 -> { // password.getCustomFields().deleteAllFromRealm(); // password.deleteFromRealm(); // }); // } // // private int id() { // Number number = realm.where(Password.class).max("id"); // return number != null ? number.intValue() + 1 : 0; // } // } // Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/PasswordCreateViewModel.java import android.databinding.ObservableArrayList; import android.databinding.ObservableField; import android.databinding.ObservableList; import android.util.Base64; import gdg.devfest.passwordmanager.framework.Navigator; import gdg.devfest.passwordmanager.model.PasswordInteractor; import java.security.SecureRandom; import pl.coreorb.selectiondialogs.data.SelectableIcon; package gdg.devfest.passwordmanager.viewmodel; public class PasswordCreateViewModel implements ViewModel { private final Navigator navigator;
private final PasswordInteractor interactor;
a11n/devfest-2016-realm
app/src/pro/java/gdg/devfest/passwordmanager/view/LoginActivity.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java // public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel> // extends ToolbarActivity<B, VM> { // // @CallSuper @Override protected void onInitBinding() { // binding.setVariable(BR.viewModel, viewModel); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/framework/ProNavigator.java // public class ProNavigator extends Navigator { // public ProNavigator(AppCompatActivity activity) { // super(activity); // } // // public void startPasswordList() { // activity.startActivity(new Intent(activity, PasswordListActivity.class)); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/model/LoginInteractor.java // public class LoginInteractor { // private static final String AUTH_URL = "http://" + BuildConfig.REALM + "/auth"; // private static final String SERVER_URL = "realm://" + BuildConfig.REALM + "/~/default"; // // public Single<User> signIn(String userName, String password) { // return login(userName, password, false); // } // // public Single<User> signUp(String userName, String password) { // return login(userName, password, true); // } // // public void setRealmSyncConfiguration(User user) { // SyncConfiguration configuration = new SyncConfiguration.Builder(user, SERVER_URL).build(); // Realm.setDefaultConfiguration(configuration); // } // // @NonNull private Single<User> login(String userName, String password, boolean createUser) { // return Single.create(singleSubscriber -> { // try { // Credentials credentials = Credentials.usernamePassword(userName, password, createUser); // User user = User.login(credentials, AUTH_URL); // singleSubscriber.onSuccess(user); // } catch (Exception e) { // singleSubscriber.onError(e); // } // }); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/viewmodel/LoginViewModel.java // public class LoginViewModel implements ViewModel { // private final LoginInteractor interactor; // private final ProNavigator navigator; // // public final ObservableField<String> email; // public final ObservableField<String> password; // public final ObservableField<String> passwordRepeat; // public final ObservableBoolean inProgress; // // public LoginViewModel(LoginInteractor interactor, ProNavigator navigator) { // this.interactor = interactor; // this.navigator = navigator; // // email = new ObservableField<>(); // password = new ObservableField<>(); // passwordRepeat = new ObservableField<>(); // inProgress = new ObservableBoolean(); // } // // public void signIn() { // inProgress.set(true); // // interactor.signIn(email.get(), password.get()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(this::onAuthenticated); // } // // public void signUp() { // inProgress.set(true); // // interactor.signUp(email.get(), password.get()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(this::onAuthenticated); // } // // private void onAuthenticated(User user){ // inProgress.set(false); // // interactor.setRealmSyncConfiguration(user); // // navigator.startPasswordList(); // navigator.finish(); // } // }
import gdg.devfest.passwordmanager.databinding.LoginActivityBinding; import gdg.devfest.passwordmanager.framework.PasswordManagerActivity; import gdg.devfest.passwordmanager.framework.ProNavigator; import gdg.devfest.passwordmanager.model.LoginInteractor; import gdg.devfest.passwordmanager.viewmodel.LoginViewModel;
package gdg.devfest.passwordmanager.view; public class LoginActivity extends PasswordManagerActivity<LoginActivityBinding, LoginViewModel> { @Override protected LoginViewModel createViewModel() {
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java // public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel> // extends ToolbarActivity<B, VM> { // // @CallSuper @Override protected void onInitBinding() { // binding.setVariable(BR.viewModel, viewModel); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/framework/ProNavigator.java // public class ProNavigator extends Navigator { // public ProNavigator(AppCompatActivity activity) { // super(activity); // } // // public void startPasswordList() { // activity.startActivity(new Intent(activity, PasswordListActivity.class)); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/model/LoginInteractor.java // public class LoginInteractor { // private static final String AUTH_URL = "http://" + BuildConfig.REALM + "/auth"; // private static final String SERVER_URL = "realm://" + BuildConfig.REALM + "/~/default"; // // public Single<User> signIn(String userName, String password) { // return login(userName, password, false); // } // // public Single<User> signUp(String userName, String password) { // return login(userName, password, true); // } // // public void setRealmSyncConfiguration(User user) { // SyncConfiguration configuration = new SyncConfiguration.Builder(user, SERVER_URL).build(); // Realm.setDefaultConfiguration(configuration); // } // // @NonNull private Single<User> login(String userName, String password, boolean createUser) { // return Single.create(singleSubscriber -> { // try { // Credentials credentials = Credentials.usernamePassword(userName, password, createUser); // User user = User.login(credentials, AUTH_URL); // singleSubscriber.onSuccess(user); // } catch (Exception e) { // singleSubscriber.onError(e); // } // }); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/viewmodel/LoginViewModel.java // public class LoginViewModel implements ViewModel { // private final LoginInteractor interactor; // private final ProNavigator navigator; // // public final ObservableField<String> email; // public final ObservableField<String> password; // public final ObservableField<String> passwordRepeat; // public final ObservableBoolean inProgress; // // public LoginViewModel(LoginInteractor interactor, ProNavigator navigator) { // this.interactor = interactor; // this.navigator = navigator; // // email = new ObservableField<>(); // password = new ObservableField<>(); // passwordRepeat = new ObservableField<>(); // inProgress = new ObservableBoolean(); // } // // public void signIn() { // inProgress.set(true); // // interactor.signIn(email.get(), password.get()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(this::onAuthenticated); // } // // public void signUp() { // inProgress.set(true); // // interactor.signUp(email.get(), password.get()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(this::onAuthenticated); // } // // private void onAuthenticated(User user){ // inProgress.set(false); // // interactor.setRealmSyncConfiguration(user); // // navigator.startPasswordList(); // navigator.finish(); // } // } // Path: app/src/pro/java/gdg/devfest/passwordmanager/view/LoginActivity.java import gdg.devfest.passwordmanager.databinding.LoginActivityBinding; import gdg.devfest.passwordmanager.framework.PasswordManagerActivity; import gdg.devfest.passwordmanager.framework.ProNavigator; import gdg.devfest.passwordmanager.model.LoginInteractor; import gdg.devfest.passwordmanager.viewmodel.LoginViewModel; package gdg.devfest.passwordmanager.view; public class LoginActivity extends PasswordManagerActivity<LoginActivityBinding, LoginViewModel> { @Override protected LoginViewModel createViewModel() {
return new LoginViewModel(new LoginInteractor(), new ProNavigator(this));
a11n/devfest-2016-realm
app/src/pro/java/gdg/devfest/passwordmanager/view/LoginActivity.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java // public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel> // extends ToolbarActivity<B, VM> { // // @CallSuper @Override protected void onInitBinding() { // binding.setVariable(BR.viewModel, viewModel); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/framework/ProNavigator.java // public class ProNavigator extends Navigator { // public ProNavigator(AppCompatActivity activity) { // super(activity); // } // // public void startPasswordList() { // activity.startActivity(new Intent(activity, PasswordListActivity.class)); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/model/LoginInteractor.java // public class LoginInteractor { // private static final String AUTH_URL = "http://" + BuildConfig.REALM + "/auth"; // private static final String SERVER_URL = "realm://" + BuildConfig.REALM + "/~/default"; // // public Single<User> signIn(String userName, String password) { // return login(userName, password, false); // } // // public Single<User> signUp(String userName, String password) { // return login(userName, password, true); // } // // public void setRealmSyncConfiguration(User user) { // SyncConfiguration configuration = new SyncConfiguration.Builder(user, SERVER_URL).build(); // Realm.setDefaultConfiguration(configuration); // } // // @NonNull private Single<User> login(String userName, String password, boolean createUser) { // return Single.create(singleSubscriber -> { // try { // Credentials credentials = Credentials.usernamePassword(userName, password, createUser); // User user = User.login(credentials, AUTH_URL); // singleSubscriber.onSuccess(user); // } catch (Exception e) { // singleSubscriber.onError(e); // } // }); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/viewmodel/LoginViewModel.java // public class LoginViewModel implements ViewModel { // private final LoginInteractor interactor; // private final ProNavigator navigator; // // public final ObservableField<String> email; // public final ObservableField<String> password; // public final ObservableField<String> passwordRepeat; // public final ObservableBoolean inProgress; // // public LoginViewModel(LoginInteractor interactor, ProNavigator navigator) { // this.interactor = interactor; // this.navigator = navigator; // // email = new ObservableField<>(); // password = new ObservableField<>(); // passwordRepeat = new ObservableField<>(); // inProgress = new ObservableBoolean(); // } // // public void signIn() { // inProgress.set(true); // // interactor.signIn(email.get(), password.get()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(this::onAuthenticated); // } // // public void signUp() { // inProgress.set(true); // // interactor.signUp(email.get(), password.get()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(this::onAuthenticated); // } // // private void onAuthenticated(User user){ // inProgress.set(false); // // interactor.setRealmSyncConfiguration(user); // // navigator.startPasswordList(); // navigator.finish(); // } // }
import gdg.devfest.passwordmanager.databinding.LoginActivityBinding; import gdg.devfest.passwordmanager.framework.PasswordManagerActivity; import gdg.devfest.passwordmanager.framework.ProNavigator; import gdg.devfest.passwordmanager.model.LoginInteractor; import gdg.devfest.passwordmanager.viewmodel.LoginViewModel;
package gdg.devfest.passwordmanager.view; public class LoginActivity extends PasswordManagerActivity<LoginActivityBinding, LoginViewModel> { @Override protected LoginViewModel createViewModel() {
// Path: app/src/main/java/gdg/devfest/passwordmanager/framework/PasswordManagerActivity.java // public abstract class PasswordManagerActivity<B extends ViewDataBinding, VM extends ViewModel> // extends ToolbarActivity<B, VM> { // // @CallSuper @Override protected void onInitBinding() { // binding.setVariable(BR.viewModel, viewModel); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/framework/ProNavigator.java // public class ProNavigator extends Navigator { // public ProNavigator(AppCompatActivity activity) { // super(activity); // } // // public void startPasswordList() { // activity.startActivity(new Intent(activity, PasswordListActivity.class)); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/model/LoginInteractor.java // public class LoginInteractor { // private static final String AUTH_URL = "http://" + BuildConfig.REALM + "/auth"; // private static final String SERVER_URL = "realm://" + BuildConfig.REALM + "/~/default"; // // public Single<User> signIn(String userName, String password) { // return login(userName, password, false); // } // // public Single<User> signUp(String userName, String password) { // return login(userName, password, true); // } // // public void setRealmSyncConfiguration(User user) { // SyncConfiguration configuration = new SyncConfiguration.Builder(user, SERVER_URL).build(); // Realm.setDefaultConfiguration(configuration); // } // // @NonNull private Single<User> login(String userName, String password, boolean createUser) { // return Single.create(singleSubscriber -> { // try { // Credentials credentials = Credentials.usernamePassword(userName, password, createUser); // User user = User.login(credentials, AUTH_URL); // singleSubscriber.onSuccess(user); // } catch (Exception e) { // singleSubscriber.onError(e); // } // }); // } // } // // Path: app/src/pro/java/gdg/devfest/passwordmanager/viewmodel/LoginViewModel.java // public class LoginViewModel implements ViewModel { // private final LoginInteractor interactor; // private final ProNavigator navigator; // // public final ObservableField<String> email; // public final ObservableField<String> password; // public final ObservableField<String> passwordRepeat; // public final ObservableBoolean inProgress; // // public LoginViewModel(LoginInteractor interactor, ProNavigator navigator) { // this.interactor = interactor; // this.navigator = navigator; // // email = new ObservableField<>(); // password = new ObservableField<>(); // passwordRepeat = new ObservableField<>(); // inProgress = new ObservableBoolean(); // } // // public void signIn() { // inProgress.set(true); // // interactor.signIn(email.get(), password.get()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(this::onAuthenticated); // } // // public void signUp() { // inProgress.set(true); // // interactor.signUp(email.get(), password.get()) // .subscribeOn(Schedulers.io()) // .observeOn(AndroidSchedulers.mainThread()) // .subscribe(this::onAuthenticated); // } // // private void onAuthenticated(User user){ // inProgress.set(false); // // interactor.setRealmSyncConfiguration(user); // // navigator.startPasswordList(); // navigator.finish(); // } // } // Path: app/src/pro/java/gdg/devfest/passwordmanager/view/LoginActivity.java import gdg.devfest.passwordmanager.databinding.LoginActivityBinding; import gdg.devfest.passwordmanager.framework.PasswordManagerActivity; import gdg.devfest.passwordmanager.framework.ProNavigator; import gdg.devfest.passwordmanager.model.LoginInteractor; import gdg.devfest.passwordmanager.viewmodel.LoginViewModel; package gdg.devfest.passwordmanager.view; public class LoginActivity extends PasswordManagerActivity<LoginActivityBinding, LoginViewModel> { @Override protected LoginViewModel createViewModel() {
return new LoginViewModel(new LoginInteractor(), new ProNavigator(this));
a11n/devfest-2016-realm
app/src/pro/java/gdg/devfest/passwordmanager/framework/ProNavigator.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordListActivity.java // public class PasswordListActivity // extends PasswordManagerActivity<PasswordListActivityBinding, PasswordListViewModel> { // // @Override protected PasswordListViewModel createViewModel() { // return new PasswordListViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // }
import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.PasswordListActivity;
package gdg.devfest.passwordmanager.framework; public class ProNavigator extends Navigator { public ProNavigator(AppCompatActivity activity) { super(activity); } public void startPasswordList() {
// Path: app/src/main/java/gdg/devfest/passwordmanager/view/PasswordListActivity.java // public class PasswordListActivity // extends PasswordManagerActivity<PasswordListActivityBinding, PasswordListViewModel> { // // @Override protected PasswordListViewModel createViewModel() { // return new PasswordListViewModel(new Navigator(this), new PasswordInteractor(realm)); // } // } // Path: app/src/pro/java/gdg/devfest/passwordmanager/framework/ProNavigator.java import android.content.Intent; import android.support.v7.app.AppCompatActivity; import gdg.devfest.passwordmanager.view.PasswordListActivity; package gdg.devfest.passwordmanager.framework; public class ProNavigator extends Navigator { public ProNavigator(AppCompatActivity activity) { super(activity); } public void startPasswordList() {
activity.startActivity(new Intent(activity, PasswordListActivity.class));
a11n/devfest-2016-realm
app/src/main/java/gdg/devfest/passwordmanager/viewmodel/CustomFieldViewModel.java
// Path: app/src/main/java/gdg/devfest/passwordmanager/model/CustomField.java // public class CustomField extends RealmObject { // private String name; // private String value; // // public CustomField() {} // // public CustomField(String name, String value) { // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // }
import android.databinding.ObservableField; import gdg.devfest.passwordmanager.model.CustomField; import java.util.ArrayList; import java.util.List;
package gdg.devfest.passwordmanager.viewmodel; public class CustomFieldViewModel implements ViewModel { public final ObservableField<String> name; public final ObservableField<String> value; private final OnUpdateListener updateListener; CustomFieldViewModel(String name, String value, OnUpdateListener updateListener) { this.name = new ObservableField<>(name); this.value = new ObservableField<>(value); this.updateListener = updateListener; } public void update() { if (updateListener != null) updateListener.update(this); }
// Path: app/src/main/java/gdg/devfest/passwordmanager/model/CustomField.java // public class CustomField extends RealmObject { // private String name; // private String value; // // public CustomField() {} // // public CustomField(String name, String value) { // this.name = name; // this.value = value; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // // public String getValue() { // return value; // } // // public void setValue(String value) { // this.value = value; // } // } // Path: app/src/main/java/gdg/devfest/passwordmanager/viewmodel/CustomFieldViewModel.java import android.databinding.ObservableField; import gdg.devfest.passwordmanager.model.CustomField; import java.util.ArrayList; import java.util.List; package gdg.devfest.passwordmanager.viewmodel; public class CustomFieldViewModel implements ViewModel { public final ObservableField<String> name; public final ObservableField<String> value; private final OnUpdateListener updateListener; CustomFieldViewModel(String name, String value, OnUpdateListener updateListener) { this.name = new ObservableField<>(name); this.value = new ObservableField<>(value); this.updateListener = updateListener; } public void update() { if (updateListener != null) updateListener.update(this); }
public static CustomFieldViewModel of(CustomField customField, OnUpdateListener updateListener) {
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // }
import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; import org.gvnix.addon.geo.annotations.GvNIXGeoConversionService;
package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService @GvNIXGeoConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); }
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; import org.gvnix.addon.geo.annotations.GvNIXGeoConversionService; package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService @GvNIXGeoConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); }
public Converter<Pet, String> getPetToStringConverter() {
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // }
import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; import org.gvnix.addon.geo.annotations.GvNIXGeoConversionService;
package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService @GvNIXGeoConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); } public Converter<Pet, String> getPetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Pet, java.lang.String>() { public String convert(Pet pet) { return new StringBuilder().append(pet.getName()).toString(); } }; }
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; import org.gvnix.addon.geo.annotations.GvNIXGeoConversionService; package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService @GvNIXGeoConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); } public Converter<Pet, String> getPetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Pet, java.lang.String>() { public String convert(Pet pet) { return new StringBuilder().append(pet.getName()).toString(); } }; }
public Converter<Vet, String> getVetToStringConverter() {
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // }
import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; import org.gvnix.addon.geo.annotations.GvNIXGeoConversionService;
package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService @GvNIXGeoConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); } public Converter<Pet, String> getPetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Pet, java.lang.String>() { public String convert(Pet pet) { return new StringBuilder().append(pet.getName()).toString(); } }; } public Converter<Vet, String> getVetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Vet, java.lang.String>() { public String convert(Vet vet) { return new StringBuilder().append(vet.getFirstName()).append(' ').append(vet.getLastName()).toString(); } }; }
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; import org.gvnix.addon.geo.annotations.GvNIXGeoConversionService; package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService @GvNIXGeoConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); } public Converter<Pet, String> getPetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Pet, java.lang.String>() { public String convert(Pet pet) { return new StringBuilder().append(pet.getName()).toString(); } }; } public Converter<Vet, String> getVetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Vet, java.lang.String>() { public String convert(Vet vet) { return new StringBuilder().append(vet.getFirstName()).append(' ').append(vet.getLastName()).toString(); } }; }
public Converter<Owner, String> getOwnerToStringConverter() {
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/PetController.java
// Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/PetBatchService.java // @Service // @GvNIXJpaBatch(entity = Pet.class) // @MonitoredWithSpring // public class PetBatchService { // }
import com.springsource.petclinic.domain.Pet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import com.springsource.petclinic.domain.PetBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; import org.gvnix.addon.fancytree.annotations.GvNIXFancyTree; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/pets") @Controller
// Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/PetBatchService.java // @Service // @GvNIXJpaBatch(entity = Pet.class) // @MonitoredWithSpring // public class PetBatchService { // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/PetController.java import com.springsource.petclinic.domain.Pet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import com.springsource.petclinic.domain.PetBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; import org.gvnix.addon.fancytree.annotations.GvNIXFancyTree; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/pets") @Controller
@RooWebScaffold(path = "pets", formBackingObject = Pet.class)
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/PetController.java
// Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/PetBatchService.java // @Service // @GvNIXJpaBatch(entity = Pet.class) // @MonitoredWithSpring // public class PetBatchService { // }
import com.springsource.petclinic.domain.Pet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import com.springsource.petclinic.domain.PetBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; import org.gvnix.addon.fancytree.annotations.GvNIXFancyTree; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/pets") @Controller @RooWebScaffold(path = "pets", formBackingObject = Pet.class) @RooWebFinder
// Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/PetBatchService.java // @Service // @GvNIXJpaBatch(entity = Pet.class) // @MonitoredWithSpring // public class PetBatchService { // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/PetController.java import com.springsource.petclinic.domain.Pet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import com.springsource.petclinic.domain.PetBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; import org.gvnix.addon.fancytree.annotations.GvNIXFancyTree; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/pets") @Controller @RooWebScaffold(path = "pets", formBackingObject = Pet.class) @RooWebFinder
@GvNIXWebJpaBatch(service = PetBatchService.class)
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VetController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // }
import com.springsource.petclinic.domain.Vet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.fancytree.annotations.GvNIXFancyTree; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/vets") @Controller
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VetController.java import com.springsource.petclinic.domain.Vet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.fancytree.annotations.GvNIXFancyTree; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/vets") @Controller
@RooWebScaffold(path = "vets", formBackingObject = Vet.class)
DISID/gvnix-samples
quickstart-repository-app/src/main/java/com/springsource/petclinic/web/OwnerController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // }
import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.annotations.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables;
package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/web/OwnerController.java import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.annotations.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller
@RooWebScaffold(path = "owners", formBackingObject = Owner.class)
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/OwnerController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/OwnerBatchService.java // @Service // @GvNIXJpaBatch(entity = Owner.class) // @MonitoredWithSpring // public class OwnerBatchService { // }
import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.OwnerBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.web.report.roo.addon.annotations.GvNIXReports; import net.bull.javamelody.MonitoredWithSpring; import org.gvnix.addon.geo.annotations.GvNIXWebEntityMapLayer;
package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/OwnerBatchService.java // @Service // @GvNIXJpaBatch(entity = Owner.class) // @MonitoredWithSpring // public class OwnerBatchService { // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/OwnerController.java import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.OwnerBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.web.report.roo.addon.annotations.GvNIXReports; import net.bull.javamelody.MonitoredWithSpring; import org.gvnix.addon.geo.annotations.GvNIXWebEntityMapLayer; package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller
@RooWebScaffold(path = "owners", formBackingObject = Owner.class)
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/OwnerController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/OwnerBatchService.java // @Service // @GvNIXJpaBatch(entity = Owner.class) // @MonitoredWithSpring // public class OwnerBatchService { // }
import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.OwnerBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.web.report.roo.addon.annotations.GvNIXReports; import net.bull.javamelody.MonitoredWithSpring; import org.gvnix.addon.geo.annotations.GvNIXWebEntityMapLayer;
package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller @RooWebScaffold(path = "owners", formBackingObject = Owner.class)
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/OwnerBatchService.java // @Service // @GvNIXJpaBatch(entity = Owner.class) // @MonitoredWithSpring // public class OwnerBatchService { // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/OwnerController.java import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.OwnerBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.web.report.roo.addon.annotations.GvNIXReports; import net.bull.javamelody.MonitoredWithSpring; import org.gvnix.addon.geo.annotations.GvNIXWebEntityMapLayer; package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller @RooWebScaffold(path = "owners", formBackingObject = Owner.class)
@GvNIXWebJpaBatch(service = OwnerBatchService.class)
DISID/gvnix-samples
quickstart-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // }
import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet;
package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); // Register application converters and formatters }
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // Path: quickstart-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); // Register application converters and formatters }
public Converter<Pet, String> getPetToStringConverter() {
DISID/gvnix-samples
quickstart-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // }
import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet;
package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); // Register application converters and formatters } public Converter<Pet, String> getPetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Pet, java.lang.String>() { public String convert(Pet pet) { return new StringBuilder().append(pet.getName()).toString(); } }; }
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // Path: quickstart-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); // Register application converters and formatters } public Converter<Pet, String> getPetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Pet, java.lang.String>() { public String convert(Pet pet) { return new StringBuilder().append(pet.getName()).toString(); } }; }
public Converter<Vet, String> getVetToStringConverter() {
DISID/gvnix-samples
quickstart-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // }
import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet;
package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); // Register application converters and formatters } public Converter<Pet, String> getPetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Pet, java.lang.String>() { public String convert(Pet pet) { return new StringBuilder().append(pet.getName()).toString(); } }; } public Converter<Vet, String> getVetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Vet, java.lang.String>() { public String convert(Vet vet) { return new StringBuilder().append(vet.getFirstName()).append(' ').append(vet.getLastName()).toString(); } }; }
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // Path: quickstart-app/src/main/java/com/springsource/petclinic/web/ApplicationConversionServiceFactoryBean.java import org.springframework.core.convert.converter.Converter; import org.springframework.format.FormatterRegistry; import org.springframework.format.support.FormattingConversionServiceFactoryBean; import org.springframework.roo.addon.web.mvc.controller.converter.RooConversionService; import com.springsource.petclinic.domain.Owner; import com.springsource.petclinic.domain.Pet; import com.springsource.petclinic.domain.Vet; package com.springsource.petclinic.web; /** * A central place to register application converters and formatters. */ @RooConversionService public class ApplicationConversionServiceFactoryBean extends FormattingConversionServiceFactoryBean { @Override protected void installFormatters(FormatterRegistry registry) { super.installFormatters(registry); // Register application converters and formatters } public Converter<Pet, String> getPetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Pet, java.lang.String>() { public String convert(Pet pet) { return new StringBuilder().append(pet.getName()).toString(); } }; } public Converter<Vet, String> getVetToStringConverter() { return new org.springframework.core.convert.converter.Converter<com.springsource.petclinic.domain.Vet, java.lang.String>() { public String convert(Vet vet) { return new StringBuilder().append(vet.getFirstName()).append(' ').append(vet.getLastName()).toString(); } }; }
public Converter<Owner, String> getOwnerToStringConverter() {
DISID/gvnix-samples
quickstart-repository-app/src/main/java/com/springsource/petclinic/web/PetController.java
// Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // }
import com.springsource.petclinic.domain.Pet; import org.springframework.roo.addon.web.mvc.controller.annotations.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController;
package com.springsource.petclinic.web; @RequestMapping("/pets") @Controller
// Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/domain/Pet.java // @RooJavaBean // @RooToString // @RooJpaEntity(sequenceName = "PET_SEQ") // public class Pet { // // /** // */ // @NotNull // private boolean sendReminders; // // /** // */ // @NotNull // @Size(min = 1) // private String name; // // /** // */ // @NotNull // @Min(0L) // private Float weight; // // /** // */ // @ManyToOne // private Owner owner; // // /** // */ // @NotNull // @Enumerated // private PetType type; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "pet") // private Set<Visit> visits = new HashSet<Visit>(); // } // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/web/PetController.java import com.springsource.petclinic.domain.Pet; import org.springframework.roo.addon.web.mvc.controller.annotations.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; package com.springsource.petclinic.web; @RequestMapping("/pets") @Controller
@RooWebScaffold(path = "pets", formBackingObject = Pet.class)
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VisitController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Visit.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord(sequenceName = "VISIT_SEQ", finders = { "findVisitsByDescriptionAndVisitDate", "findVisitsByVisitDateBetween", "findVisitsByDescriptionLike" }) // @GvNIXJpaAudit // public class Visit { // // /** // */ // @Size(max = 255) // private String description; // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Date visitDate; // // /** // */ // @NotNull // @ManyToOne // private Pet pet; // // /** // */ // @ManyToOne // private Vet vet; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/VisitBatchService.java // @Service // @GvNIXJpaBatch(entity = Visit.class) // @MonitoredWithSpring // public class VisitBatchService { // }
import com.springsource.petclinic.domain.Visit; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import com.springsource.petclinic.domain.VisitBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/visits") @Controller
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Visit.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord(sequenceName = "VISIT_SEQ", finders = { "findVisitsByDescriptionAndVisitDate", "findVisitsByVisitDateBetween", "findVisitsByDescriptionLike" }) // @GvNIXJpaAudit // public class Visit { // // /** // */ // @Size(max = 255) // private String description; // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Date visitDate; // // /** // */ // @NotNull // @ManyToOne // private Pet pet; // // /** // */ // @ManyToOne // private Vet vet; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/VisitBatchService.java // @Service // @GvNIXJpaBatch(entity = Visit.class) // @MonitoredWithSpring // public class VisitBatchService { // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VisitController.java import com.springsource.petclinic.domain.Visit; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import com.springsource.petclinic.domain.VisitBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/visits") @Controller
@RooWebScaffold(path = "visits", formBackingObject = Visit.class)
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VisitController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Visit.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord(sequenceName = "VISIT_SEQ", finders = { "findVisitsByDescriptionAndVisitDate", "findVisitsByVisitDateBetween", "findVisitsByDescriptionLike" }) // @GvNIXJpaAudit // public class Visit { // // /** // */ // @Size(max = 255) // private String description; // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Date visitDate; // // /** // */ // @NotNull // @ManyToOne // private Pet pet; // // /** // */ // @ManyToOne // private Vet vet; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/VisitBatchService.java // @Service // @GvNIXJpaBatch(entity = Visit.class) // @MonitoredWithSpring // public class VisitBatchService { // }
import com.springsource.petclinic.domain.Visit; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import com.springsource.petclinic.domain.VisitBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/visits") @Controller @RooWebScaffold(path = "visits", formBackingObject = Visit.class) @RooWebFinder
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Visit.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord(sequenceName = "VISIT_SEQ", finders = { "findVisitsByDescriptionAndVisitDate", "findVisitsByVisitDateBetween", "findVisitsByDescriptionLike" }) // @GvNIXJpaAudit // public class Visit { // // /** // */ // @Size(max = 255) // private String description; // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Date visitDate; // // /** // */ // @NotNull // @ManyToOne // private Pet pet; // // /** // */ // @ManyToOne // private Vet vet; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/VisitBatchService.java // @Service // @GvNIXJpaBatch(entity = Visit.class) // @MonitoredWithSpring // public class VisitBatchService { // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VisitController.java import com.springsource.petclinic.domain.Visit; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.roo.addon.web.mvc.controller.finder.RooWebFinder; import com.springsource.petclinic.domain.VisitBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/visits") @Controller @RooWebScaffold(path = "visits", formBackingObject = Visit.class) @RooWebFinder
@GvNIXWebJpaBatch(service = VisitBatchService.class)
DISID/gvnix-samples
quickstart-repository-app/src/main/java/com/springsource/petclinic/web/VisitController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Visit.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord(sequenceName = "VISIT_SEQ", finders = { "findVisitsByDescriptionAndVisitDate", "findVisitsByVisitDateBetween", "findVisitsByDescriptionLike" }) // @GvNIXJpaAudit // public class Visit { // // /** // */ // @Size(max = 255) // private String description; // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Date visitDate; // // /** // */ // @NotNull // @ManyToOne // private Pet pet; // // /** // */ // @ManyToOne // private Vet vet; // }
import com.springsource.petclinic.domain.Visit; import org.springframework.roo.addon.web.mvc.controller.annotations.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController;
package com.springsource.petclinic.web; @RequestMapping("/visits") @Controller
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Visit.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord(sequenceName = "VISIT_SEQ", finders = { "findVisitsByDescriptionAndVisitDate", "findVisitsByVisitDateBetween", "findVisitsByDescriptionLike" }) // @GvNIXJpaAudit // public class Visit { // // /** // */ // @Size(max = 255) // private String description; // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Date visitDate; // // /** // */ // @NotNull // @ManyToOne // private Pet pet; // // /** // */ // @ManyToOne // private Vet vet; // } // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/web/VisitController.java import com.springsource.petclinic.domain.Visit; import org.springframework.roo.addon.web.mvc.controller.annotations.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.addon.loupefield.annotations.GvNIXLoupeController; package com.springsource.petclinic.web; @RequestMapping("/visits") @Controller
@RooWebScaffold(path = "visits", formBackingObject = Visit.class)
DISID/gvnix-samples
quickstart-app/src/main/java/com/springsource/petclinic/web/OwnerController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/OwnerBatchService.java // @Service // @GvNIXJpaBatch(entity = Owner.class) // @MonitoredWithSpring // public class OwnerBatchService { // }
import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.OwnerBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.web.report.roo.addon.annotations.GvNIXReports; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/OwnerBatchService.java // @Service // @GvNIXJpaBatch(entity = Owner.class) // @MonitoredWithSpring // public class OwnerBatchService { // } // Path: quickstart-app/src/main/java/com/springsource/petclinic/web/OwnerController.java import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.OwnerBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.web.report.roo.addon.annotations.GvNIXReports; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller
@RooWebScaffold(path = "owners", formBackingObject = Owner.class)
DISID/gvnix-samples
quickstart-app/src/main/java/com/springsource/petclinic/web/OwnerController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/OwnerBatchService.java // @Service // @GvNIXJpaBatch(entity = Owner.class) // @MonitoredWithSpring // public class OwnerBatchService { // }
import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.OwnerBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.web.report.roo.addon.annotations.GvNIXReports; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller @RooWebScaffold(path = "owners", formBackingObject = Owner.class)
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Owner.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // @GvNIXEntityMapLayer // public class Owner extends AbstractPerson { // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Pet> pets = new HashSet<Pet>(); // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "owner") // private Set<Vet> vets = new HashSet<Vet>(); // // @Type(type = "org.hibernate.spatial.GeometryType") // private Point location; // // @Type(type = "org.hibernate.spatial.GeometryType") // private LineString distance; // // @Type(type = "org.hibernate.spatial.GeometryType") // private Polygon area; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/OwnerBatchService.java // @Service // @GvNIXJpaBatch(entity = Owner.class) // @MonitoredWithSpring // public class OwnerBatchService { // } // Path: quickstart-app/src/main/java/com/springsource/petclinic/web/OwnerController.java import com.springsource.petclinic.domain.Owner; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.OwnerBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import org.gvnix.web.report.roo.addon.annotations.GvNIXReports; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/owners") @Controller @RooWebScaffold(path = "owners", formBackingObject = Owner.class)
@GvNIXWebJpaBatch(service = OwnerBatchService.class)
DISID/gvnix-samples
quickstart-repository-app/src/main/java/com/springsource/petclinic/web/VetController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // }
import com.springsource.petclinic.domain.Vet; import org.springframework.roo.addon.web.mvc.controller.annotations.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables;
package com.springsource.petclinic.web; @RequestMapping("/vets") @Controller
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // Path: quickstart-repository-app/src/main/java/com/springsource/petclinic/web/VetController.java import com.springsource.petclinic.domain.Vet; import org.springframework.roo.addon.web.mvc.controller.annotations.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; package com.springsource.petclinic.web; @RequestMapping("/vets") @Controller
@RooWebScaffold(path = "vets", formBackingObject = Vet.class)
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VetListController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/VetBatchService.java // @Service // @GvNIXJpaBatch(entity = Vet.class) // @MonitoredWithSpring // public class VetBatchService { // }
import com.springsource.petclinic.domain.Vet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.VetBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/vetlist") @Controller
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/VetBatchService.java // @Service // @GvNIXJpaBatch(entity = Vet.class) // @MonitoredWithSpring // public class VetBatchService { // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VetListController.java import com.springsource.petclinic.domain.Vet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.VetBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/vetlist") @Controller
@RooWebScaffold(path = "vetlist", formBackingObject = Vet.class)
DISID/gvnix-samples
quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VetListController.java
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/VetBatchService.java // @Service // @GvNIXJpaBatch(entity = Vet.class) // @MonitoredWithSpring // public class VetBatchService { // }
import com.springsource.petclinic.domain.Vet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.VetBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import net.bull.javamelody.MonitoredWithSpring;
package com.springsource.petclinic.web; @RequestMapping("/vetlist") @Controller @RooWebScaffold(path = "vetlist", formBackingObject = Vet.class)
// Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/Vet.java // @RooJavaBean // @RooToString // @RooJpaActiveRecord // @GvNIXJpaAudit // public class Vet extends AbstractPerson { // // /** // */ // @NotNull // @Past // @Temporal(TemporalType.TIMESTAMP) // @DateTimeFormat(style = "M-") // private Calendar employedSince; // // /** // */ // @Enumerated // private Specialty specialty; // // /** // */ // @OneToMany(cascade = CascadeType.ALL, mappedBy = "vet") // private Set<Visit> visits = new HashSet<Visit>(); // // /** // */ // @ManyToOne // private Owner owner; // } // // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/domain/VetBatchService.java // @Service // @GvNIXJpaBatch(entity = Vet.class) // @MonitoredWithSpring // public class VetBatchService { // } // Path: quickstart-geo-app/src/main/java/com/springsource/petclinic/web/VetListController.java import com.springsource.petclinic.domain.Vet; import org.springframework.roo.addon.web.mvc.controller.scaffold.RooWebScaffold; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import com.springsource.petclinic.domain.VetBatchService; import org.gvnix.addon.web.mvc.annotations.batch.GvNIXWebJpaBatch; import org.gvnix.addon.web.mvc.annotations.jquery.GvNIXWebJQuery; import org.gvnix.addon.datatables.annotations.GvNIXDatatables; import net.bull.javamelody.MonitoredWithSpring; package com.springsource.petclinic.web; @RequestMapping("/vetlist") @Controller @RooWebScaffold(path = "vetlist", formBackingObject = Vet.class)
@GvNIXWebJpaBatch(service = VetBatchService.class)
Sch3lp/ProductivityWithShortcuts
src/main/java/be/swsb/productivity/chapter2/mud/ui/BallScreen.java
// Path: src/main/java/be/swsb/productivity/chapter2/mud/service/BallService.java // public interface BallService { // BallTO findBall(String id); // } // // Path: src/main/java/be/swsb/productivity/chapter2/mud/service/BallTO.java // public class BallTO { // private String id; // private int size; // // public BallTO() { // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public int getSize() { // return size; // } // // public void setSize(int size) { // this.size = size; // } // }
import be.swsb.productivity.chapter2.mud.service.BallService; import be.swsb.productivity.chapter2.mud.service.BallTO;
package be.swsb.productivity.chapter2.mud.ui; public class BallScreen { private BallService ballService; public BallScreen(BallService ballService) { this.ballService = ballService; } public void render(){
// Path: src/main/java/be/swsb/productivity/chapter2/mud/service/BallService.java // public interface BallService { // BallTO findBall(String id); // } // // Path: src/main/java/be/swsb/productivity/chapter2/mud/service/BallTO.java // public class BallTO { // private String id; // private int size; // // public BallTO() { // } // // public String getId() { // return id; // } // // public void setId(String id) { // this.id = id; // } // // public int getSize() { // return size; // } // // public void setSize(int size) { // this.size = size; // } // } // Path: src/main/java/be/swsb/productivity/chapter2/mud/ui/BallScreen.java import be.swsb.productivity.chapter2.mud.service.BallService; import be.swsb.productivity.chapter2.mud.service.BallTO; package be.swsb.productivity.chapter2.mud.ui; public class BallScreen { private BallService ballService; public BallScreen(BallService ballService) { this.ballService = ballService; } public void render(){
BallTO ballTO = ballService.findBall("one");
Sch3lp/ProductivityWithShortcuts
src/main/java/be/swsb/productivity/chapter1/indentation/FuglyToo.java
// Path: src/main/java/be/swsb/productivity/common/FaceTestBuilder.java // public static FaceTestBuilder face(){ // return new FaceTestBuilder(); // } // // Path: src/main/java/be/swsb/productivity/common/FuglyTestBuilder.java // public static FuglyTestBuilder fugly(){ // return new FuglyTestBuilder(); // }
import static be.swsb.productivity.common.FaceTestBuilder.face; import static be.swsb.productivity.common.FuglyTestBuilder.fugly;
package be.swsb.productivity.chapter1.indentation; public class FuglyToo { public static void indentMeProperlyPlease() {
// Path: src/main/java/be/swsb/productivity/common/FaceTestBuilder.java // public static FaceTestBuilder face(){ // return new FaceTestBuilder(); // } // // Path: src/main/java/be/swsb/productivity/common/FuglyTestBuilder.java // public static FuglyTestBuilder fugly(){ // return new FuglyTestBuilder(); // } // Path: src/main/java/be/swsb/productivity/chapter1/indentation/FuglyToo.java import static be.swsb.productivity.common.FaceTestBuilder.face; import static be.swsb.productivity.common.FuglyTestBuilder.fugly; package be.swsb.productivity.chapter1.indentation; public class FuglyToo { public static void indentMeProperlyPlease() {
System.out.println(fugly()
Sch3lp/ProductivityWithShortcuts
src/main/java/be/swsb/productivity/chapter1/indentation/FuglyToo.java
// Path: src/main/java/be/swsb/productivity/common/FaceTestBuilder.java // public static FaceTestBuilder face(){ // return new FaceTestBuilder(); // } // // Path: src/main/java/be/swsb/productivity/common/FuglyTestBuilder.java // public static FuglyTestBuilder fugly(){ // return new FuglyTestBuilder(); // }
import static be.swsb.productivity.common.FaceTestBuilder.face; import static be.swsb.productivity.common.FuglyTestBuilder.fugly;
package be.swsb.productivity.chapter1.indentation; public class FuglyToo { public static void indentMeProperlyPlease() { System.out.println(fugly() .withEff("f") .withYew("u") .withGee("g") .withEll("l") .withYew("y")
// Path: src/main/java/be/swsb/productivity/common/FaceTestBuilder.java // public static FaceTestBuilder face(){ // return new FaceTestBuilder(); // } // // Path: src/main/java/be/swsb/productivity/common/FuglyTestBuilder.java // public static FuglyTestBuilder fugly(){ // return new FuglyTestBuilder(); // } // Path: src/main/java/be/swsb/productivity/chapter1/indentation/FuglyToo.java import static be.swsb.productivity.common.FaceTestBuilder.face; import static be.swsb.productivity.common.FuglyTestBuilder.fugly; package be.swsb.productivity.chapter1.indentation; public class FuglyToo { public static void indentMeProperlyPlease() { System.out.println(fugly() .withEff("f") .withYew("u") .withGee("g") .withEll("l") .withYew("y")
.withFace(face()
Sch3lp/ProductivityWithShortcuts
src/main/java/be/swsb/productivity/chapter6/Transformers.java
// Path: src/main/java/be/swsb/productivity/chapter6/transformers/Autobot.java // public class Autobot { // // private AutobotEnum type; // // public Autobot(AutobotEnum type) { // this.type = type; // } // // public static AutobotEnum optimusEnum(){ // return AutobotEnum.CAR; // } // // public String catchPhrase(String prefix) { // return String.format("%s Rollout!", prefix); // } // } // // Path: src/main/java/be/swsb/productivity/chapter6/transformers/Decepticon.java // public class Decepticon { // private DecepticonEnum type; // // public Decepticon(DecepticonEnum type) { // this.type = type; // } // // public static DecepticonEnum megatronEnum(){ // return DecepticonEnum.GUN; // } // // public static Decepticon StarScream(String name, String evilTrait, int numberOfLegs, int numberOfArms, double pctEvil, DecepticonEnum type) { // return new StarScream(name, evilTrait, numberOfLegs, numberOfLegs, pctEvil, type); // } // // public static Decepticon StarScream(String name, DecepticonEnum type) { // return new StarScream(name, "backstabber", 2, 2, 99.99, type); // } // // private static class StarScream extends Decepticon { // private String name; // private String evilTrait; // private int numberOfLegs; // private int numberOfArms; // private double pctEvil; // private int numberOfLegs1; // // private StarScream(String name, String evilTrait, int numberOfLegs, int numberOfArms, double pctEvil, DecepticonEnum type) { // super(type); // this.name = name; // this.evilTrait = evilTrait; // this.numberOfLegs = numberOfLegs; // this.numberOfArms = numberOfArms; // this.pctEvil = pctEvil; // } // // } // }
import be.swsb.productivity.chapter6.transformers.Autobot; import be.swsb.productivity.chapter6.transformers.Decepticon;
package be.swsb.productivity.chapter6; public class Transformers { public void disguise() {
// Path: src/main/java/be/swsb/productivity/chapter6/transformers/Autobot.java // public class Autobot { // // private AutobotEnum type; // // public Autobot(AutobotEnum type) { // this.type = type; // } // // public static AutobotEnum optimusEnum(){ // return AutobotEnum.CAR; // } // // public String catchPhrase(String prefix) { // return String.format("%s Rollout!", prefix); // } // } // // Path: src/main/java/be/swsb/productivity/chapter6/transformers/Decepticon.java // public class Decepticon { // private DecepticonEnum type; // // public Decepticon(DecepticonEnum type) { // this.type = type; // } // // public static DecepticonEnum megatronEnum(){ // return DecepticonEnum.GUN; // } // // public static Decepticon StarScream(String name, String evilTrait, int numberOfLegs, int numberOfArms, double pctEvil, DecepticonEnum type) { // return new StarScream(name, evilTrait, numberOfLegs, numberOfLegs, pctEvil, type); // } // // public static Decepticon StarScream(String name, DecepticonEnum type) { // return new StarScream(name, "backstabber", 2, 2, 99.99, type); // } // // private static class StarScream extends Decepticon { // private String name; // private String evilTrait; // private int numberOfLegs; // private int numberOfArms; // private double pctEvil; // private int numberOfLegs1; // // private StarScream(String name, String evilTrait, int numberOfLegs, int numberOfArms, double pctEvil, DecepticonEnum type) { // super(type); // this.name = name; // this.evilTrait = evilTrait; // this.numberOfLegs = numberOfLegs; // this.numberOfArms = numberOfArms; // this.pctEvil = pctEvil; // } // // } // } // Path: src/main/java/be/swsb/productivity/chapter6/Transformers.java import be.swsb.productivity.chapter6.transformers.Autobot; import be.swsb.productivity.chapter6.transformers.Decepticon; package be.swsb.productivity.chapter6; public class Transformers { public void disguise() {
Autobot optimus = new Autobot();
Sch3lp/ProductivityWithShortcuts
src/main/java/be/swsb/productivity/chapter6/Transformers.java
// Path: src/main/java/be/swsb/productivity/chapter6/transformers/Autobot.java // public class Autobot { // // private AutobotEnum type; // // public Autobot(AutobotEnum type) { // this.type = type; // } // // public static AutobotEnum optimusEnum(){ // return AutobotEnum.CAR; // } // // public String catchPhrase(String prefix) { // return String.format("%s Rollout!", prefix); // } // } // // Path: src/main/java/be/swsb/productivity/chapter6/transformers/Decepticon.java // public class Decepticon { // private DecepticonEnum type; // // public Decepticon(DecepticonEnum type) { // this.type = type; // } // // public static DecepticonEnum megatronEnum(){ // return DecepticonEnum.GUN; // } // // public static Decepticon StarScream(String name, String evilTrait, int numberOfLegs, int numberOfArms, double pctEvil, DecepticonEnum type) { // return new StarScream(name, evilTrait, numberOfLegs, numberOfLegs, pctEvil, type); // } // // public static Decepticon StarScream(String name, DecepticonEnum type) { // return new StarScream(name, "backstabber", 2, 2, 99.99, type); // } // // private static class StarScream extends Decepticon { // private String name; // private String evilTrait; // private int numberOfLegs; // private int numberOfArms; // private double pctEvil; // private int numberOfLegs1; // // private StarScream(String name, String evilTrait, int numberOfLegs, int numberOfArms, double pctEvil, DecepticonEnum type) { // super(type); // this.name = name; // this.evilTrait = evilTrait; // this.numberOfLegs = numberOfLegs; // this.numberOfArms = numberOfArms; // this.pctEvil = pctEvil; // } // // } // }
import be.swsb.productivity.chapter6.transformers.Autobot; import be.swsb.productivity.chapter6.transformers.Decepticon;
package be.swsb.productivity.chapter6; public class Transformers { public void disguise() { Autobot optimus = new Autobot();
// Path: src/main/java/be/swsb/productivity/chapter6/transformers/Autobot.java // public class Autobot { // // private AutobotEnum type; // // public Autobot(AutobotEnum type) { // this.type = type; // } // // public static AutobotEnum optimusEnum(){ // return AutobotEnum.CAR; // } // // public String catchPhrase(String prefix) { // return String.format("%s Rollout!", prefix); // } // } // // Path: src/main/java/be/swsb/productivity/chapter6/transformers/Decepticon.java // public class Decepticon { // private DecepticonEnum type; // // public Decepticon(DecepticonEnum type) { // this.type = type; // } // // public static DecepticonEnum megatronEnum(){ // return DecepticonEnum.GUN; // } // // public static Decepticon StarScream(String name, String evilTrait, int numberOfLegs, int numberOfArms, double pctEvil, DecepticonEnum type) { // return new StarScream(name, evilTrait, numberOfLegs, numberOfLegs, pctEvil, type); // } // // public static Decepticon StarScream(String name, DecepticonEnum type) { // return new StarScream(name, "backstabber", 2, 2, 99.99, type); // } // // private static class StarScream extends Decepticon { // private String name; // private String evilTrait; // private int numberOfLegs; // private int numberOfArms; // private double pctEvil; // private int numberOfLegs1; // // private StarScream(String name, String evilTrait, int numberOfLegs, int numberOfArms, double pctEvil, DecepticonEnum type) { // super(type); // this.name = name; // this.evilTrait = evilTrait; // this.numberOfLegs = numberOfLegs; // this.numberOfArms = numberOfArms; // this.pctEvil = pctEvil; // } // // } // } // Path: src/main/java/be/swsb/productivity/chapter6/Transformers.java import be.swsb.productivity.chapter6.transformers.Autobot; import be.swsb.productivity.chapter6.transformers.Decepticon; package be.swsb.productivity.chapter6; public class Transformers { public void disguise() { Autobot optimus = new Autobot();
Decepticon megatron = new Decepticon();
Sch3lp/ProductivityWithShortcuts
src/main/java/be/swsb/productivity/chapter5/Chapter5.java
// Path: src/main/java/be/swsb/productivity/chapter5/beans/MaragoBeans.java // public class MaragoBeans extends CoffeeBeans { // // private String maragoScent = "marago"; // // @Override // public String scent() { // return maragoScent; // } // } // // Path: src/main/java/be/swsb/productivity/chapter5/beans/YrgacheffeBeans.java // public class YrgacheffeBeans extends CoffeeBeans { // private String yrgacheffeScent = "yrgacheffe"; // // @Override // public String scent() { // return yrgacheffeScent; // } // }
import be.swsb.productivity.chapter5.beans.MaragoBeans; import be.swsb.productivity.chapter5.beans.YrgacheffeBeans;
package be.swsb.productivity.chapter5; public class Chapter5 { public String smellBeans() {
// Path: src/main/java/be/swsb/productivity/chapter5/beans/MaragoBeans.java // public class MaragoBeans extends CoffeeBeans { // // private String maragoScent = "marago"; // // @Override // public String scent() { // return maragoScent; // } // } // // Path: src/main/java/be/swsb/productivity/chapter5/beans/YrgacheffeBeans.java // public class YrgacheffeBeans extends CoffeeBeans { // private String yrgacheffeScent = "yrgacheffe"; // // @Override // public String scent() { // return yrgacheffeScent; // } // } // Path: src/main/java/be/swsb/productivity/chapter5/Chapter5.java import be.swsb.productivity.chapter5.beans.MaragoBeans; import be.swsb.productivity.chapter5.beans.YrgacheffeBeans; package be.swsb.productivity.chapter5; public class Chapter5 { public String smellBeans() {
return new CoffeeSmeller().smell(new MaragoBeans(), new YrgacheffeBeans(), new MaragoBeans());
Sch3lp/ProductivityWithShortcuts
src/main/java/be/swsb/productivity/chapter5/Chapter5.java
// Path: src/main/java/be/swsb/productivity/chapter5/beans/MaragoBeans.java // public class MaragoBeans extends CoffeeBeans { // // private String maragoScent = "marago"; // // @Override // public String scent() { // return maragoScent; // } // } // // Path: src/main/java/be/swsb/productivity/chapter5/beans/YrgacheffeBeans.java // public class YrgacheffeBeans extends CoffeeBeans { // private String yrgacheffeScent = "yrgacheffe"; // // @Override // public String scent() { // return yrgacheffeScent; // } // }
import be.swsb.productivity.chapter5.beans.MaragoBeans; import be.swsb.productivity.chapter5.beans.YrgacheffeBeans;
package be.swsb.productivity.chapter5; public class Chapter5 { public String smellBeans() {
// Path: src/main/java/be/swsb/productivity/chapter5/beans/MaragoBeans.java // public class MaragoBeans extends CoffeeBeans { // // private String maragoScent = "marago"; // // @Override // public String scent() { // return maragoScent; // } // } // // Path: src/main/java/be/swsb/productivity/chapter5/beans/YrgacheffeBeans.java // public class YrgacheffeBeans extends CoffeeBeans { // private String yrgacheffeScent = "yrgacheffe"; // // @Override // public String scent() { // return yrgacheffeScent; // } // } // Path: src/main/java/be/swsb/productivity/chapter5/Chapter5.java import be.swsb.productivity.chapter5.beans.MaragoBeans; import be.swsb.productivity.chapter5.beans.YrgacheffeBeans; package be.swsb.productivity.chapter5; public class Chapter5 { public String smellBeans() {
return new CoffeeSmeller().smell(new MaragoBeans(), new YrgacheffeBeans(), new MaragoBeans());