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
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/provider/hibernate/HibernateProviderAccessSpiImpl.java
// Path: src/main/java/com/eclecticlogic/pedal/provider/Consumer.java // public interface Consumer<T> { // // // void accept(T value); // // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/Function.java // public interface Function<T, R> { // // R apply(T value); // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/ProviderAccessSpi.java // public interface ProviderAccessSpi extends ProviderAccess { // // /** // * @param entityMangager JPA entity manager reference. // * @param work Execute the work passing in the underlying JDBC connection object. // */ // public void run(EntityManager entityManager, Consumer<Connection> work); // // // /** // * @param entityManager JPA entity manager reference. // * @param work Work to execute passing in the underlying JDBC connection object. // * @return the output of the work. // */ // public <R> R exec(EntityManager entityManager, Function<Connection, R> work); // }
import org.hibernate.persister.entity.SingleTableEntityPersister; import com.eclecticlogic.pedal.provider.Consumer; import com.eclecticlogic.pedal.provider.Function; import com.eclecticlogic.pedal.provider.ProviderAccessSpi; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.jdbc.ReturningWork; import org.hibernate.jdbc.Work; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.metadata.ClassMetadata;
/** * Copyright (c) 2014-2015 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.eclecticlogic.pedal.provider.hibernate; /** * Get provider specific information. * @author kabram. * */ public class HibernateProviderAccessSpiImpl implements ProviderAccessSpi { private EntityManagerFactory emf; public void setEntityManagerFactory(EntityManagerFactory emf) { this.emf = emf; } @Override public String getSchemaName() { SessionFactory sf = emf.unwrap(HibernateEntityManagerFactory.class).getSessionFactory(); SessionFactoryImplementor sfi = (SessionFactoryImplementor) sf; String schema = sfi.getSettings().getDefaultSchemaName(); return schema == null ? "" : schema; } /** * @param entityClass Entity class for which the table name is required. * @return Table name if the entity class is a single table. */ @Override public String getTableName(Class<? extends Serializable> entityClass) { SessionFactory sf = emf.unwrap(HibernateEntityManagerFactory.class).getSessionFactory(); ClassMetadata metadata = sf.getClassMetadata(entityClass); if (metadata instanceof SingleTableEntityPersister) { SingleTableEntityPersister step = (SingleTableEntityPersister) metadata; return step.getTableName(); } else { return null; } } @Override
// Path: src/main/java/com/eclecticlogic/pedal/provider/Consumer.java // public interface Consumer<T> { // // // void accept(T value); // // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/Function.java // public interface Function<T, R> { // // R apply(T value); // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/ProviderAccessSpi.java // public interface ProviderAccessSpi extends ProviderAccess { // // /** // * @param entityMangager JPA entity manager reference. // * @param work Execute the work passing in the underlying JDBC connection object. // */ // public void run(EntityManager entityManager, Consumer<Connection> work); // // // /** // * @param entityManager JPA entity manager reference. // * @param work Work to execute passing in the underlying JDBC connection object. // * @return the output of the work. // */ // public <R> R exec(EntityManager entityManager, Function<Connection, R> work); // } // Path: src/main/java/com/eclecticlogic/pedal/provider/hibernate/HibernateProviderAccessSpiImpl.java import org.hibernate.persister.entity.SingleTableEntityPersister; import com.eclecticlogic.pedal.provider.Consumer; import com.eclecticlogic.pedal.provider.Function; import com.eclecticlogic.pedal.provider.ProviderAccessSpi; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.jdbc.ReturningWork; import org.hibernate.jdbc.Work; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.metadata.ClassMetadata; /** * Copyright (c) 2014-2015 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * */ package com.eclecticlogic.pedal.provider.hibernate; /** * Get provider specific information. * @author kabram. * */ public class HibernateProviderAccessSpiImpl implements ProviderAccessSpi { private EntityManagerFactory emf; public void setEntityManagerFactory(EntityManagerFactory emf) { this.emf = emf; } @Override public String getSchemaName() { SessionFactory sf = emf.unwrap(HibernateEntityManagerFactory.class).getSessionFactory(); SessionFactoryImplementor sfi = (SessionFactoryImplementor) sf; String schema = sfi.getSettings().getDefaultSchemaName(); return schema == null ? "" : schema; } /** * @param entityClass Entity class for which the table name is required. * @return Table name if the entity class is a single table. */ @Override public String getTableName(Class<? extends Serializable> entityClass) { SessionFactory sf = emf.unwrap(HibernateEntityManagerFactory.class).getSessionFactory(); ClassMetadata metadata = sf.getClassMetadata(entityClass); if (metadata instanceof SingleTableEntityPersister) { SingleTableEntityPersister step = (SingleTableEntityPersister) metadata; return step.getTableName(); } else { return null; } } @Override
public void run(EntityManager entityManager, final Consumer<Connection> work) {
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/provider/hibernate/HibernateProviderAccessSpiImpl.java
// Path: src/main/java/com/eclecticlogic/pedal/provider/Consumer.java // public interface Consumer<T> { // // // void accept(T value); // // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/Function.java // public interface Function<T, R> { // // R apply(T value); // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/ProviderAccessSpi.java // public interface ProviderAccessSpi extends ProviderAccess { // // /** // * @param entityMangager JPA entity manager reference. // * @param work Execute the work passing in the underlying JDBC connection object. // */ // public void run(EntityManager entityManager, Consumer<Connection> work); // // // /** // * @param entityManager JPA entity manager reference. // * @param work Work to execute passing in the underlying JDBC connection object. // * @return the output of the work. // */ // public <R> R exec(EntityManager entityManager, Function<Connection, R> work); // }
import org.hibernate.persister.entity.SingleTableEntityPersister; import com.eclecticlogic.pedal.provider.Consumer; import com.eclecticlogic.pedal.provider.Function; import com.eclecticlogic.pedal.provider.ProviderAccessSpi; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.jdbc.ReturningWork; import org.hibernate.jdbc.Work; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.metadata.ClassMetadata;
* @param entityClass Entity class for which the table name is required. * @return Table name if the entity class is a single table. */ @Override public String getTableName(Class<? extends Serializable> entityClass) { SessionFactory sf = emf.unwrap(HibernateEntityManagerFactory.class).getSessionFactory(); ClassMetadata metadata = sf.getClassMetadata(entityClass); if (metadata instanceof SingleTableEntityPersister) { SingleTableEntityPersister step = (SingleTableEntityPersister) metadata; return step.getTableName(); } else { return null; } } @Override public void run(EntityManager entityManager, final Consumer<Connection> work) { Session session = entityManager.unwrap(Session.class); session.doWork(new Work() { @Override public void execute(Connection connection) throws SQLException { work.accept(connection); } }); } @Override
// Path: src/main/java/com/eclecticlogic/pedal/provider/Consumer.java // public interface Consumer<T> { // // // void accept(T value); // // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/Function.java // public interface Function<T, R> { // // R apply(T value); // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/ProviderAccessSpi.java // public interface ProviderAccessSpi extends ProviderAccess { // // /** // * @param entityMangager JPA entity manager reference. // * @param work Execute the work passing in the underlying JDBC connection object. // */ // public void run(EntityManager entityManager, Consumer<Connection> work); // // // /** // * @param entityManager JPA entity manager reference. // * @param work Work to execute passing in the underlying JDBC connection object. // * @return the output of the work. // */ // public <R> R exec(EntityManager entityManager, Function<Connection, R> work); // } // Path: src/main/java/com/eclecticlogic/pedal/provider/hibernate/HibernateProviderAccessSpiImpl.java import org.hibernate.persister.entity.SingleTableEntityPersister; import com.eclecticlogic.pedal.provider.Consumer; import com.eclecticlogic.pedal.provider.Function; import com.eclecticlogic.pedal.provider.ProviderAccessSpi; import java.io.Serializable; import java.sql.Connection; import java.sql.SQLException; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.jdbc.ReturningWork; import org.hibernate.jdbc.Work; import org.hibernate.jpa.HibernateEntityManagerFactory; import org.hibernate.metadata.ClassMetadata; * @param entityClass Entity class for which the table name is required. * @return Table name if the entity class is a single table. */ @Override public String getTableName(Class<? extends Serializable> entityClass) { SessionFactory sf = emf.unwrap(HibernateEntityManagerFactory.class).getSessionFactory(); ClassMetadata metadata = sf.getClassMetadata(entityClass); if (metadata instanceof SingleTableEntityPersister) { SingleTableEntityPersister step = (SingleTableEntityPersister) metadata; return step.getTableName(); } else { return null; } } @Override public void run(EntityManager entityManager, final Consumer<Connection> work) { Session session = entityManager.unwrap(Session.class); session.doWork(new Work() { @Override public void execute(Connection connection) throws SQLException { work.accept(connection); } }); } @Override
public <R> R exec(EntityManager entityManager, final Function<Connection, R> work) {
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/AbstractCopyCommandImpl.java
// Path: src/main/java/com/eclecticlogic/pedal/connection/ConnectionAccessor.java // public interface ConnectionAccessor { // // /** // * @param providerConnection Connection accessible via JPA provider // * @return Underlying database connection. // */ // Connection getRawConnection(Connection providerConnection); // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/ProviderAccessSpi.java // public interface ProviderAccessSpi extends ProviderAccess { // // /** // * @param entityMangager JPA entity manager reference. // * @param work Execute the work passing in the underlying JDBC connection object. // */ // public void run(EntityManager entityManager, Consumer<Connection> work); // // // /** // * @param entityManager JPA entity manager reference. // * @param work Work to execute passing in the underlying JDBC connection object. // * @return the output of the work. // */ // public <R> R exec(EntityManager entityManager, Function<Connection, R> work); // }
import com.eclecticlogic.pedal.connection.ConnectionAccessor; import com.eclecticlogic.pedal.provider.ProviderAccessSpi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable;
/* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql; /** * Created by kabram. */ public abstract class AbstractCopyCommandImpl implements CopyCommand { protected ConnectionAccessor connectionAccessor;
// Path: src/main/java/com/eclecticlogic/pedal/connection/ConnectionAccessor.java // public interface ConnectionAccessor { // // /** // * @param providerConnection Connection accessible via JPA provider // * @return Underlying database connection. // */ // Connection getRawConnection(Connection providerConnection); // } // // Path: src/main/java/com/eclecticlogic/pedal/provider/ProviderAccessSpi.java // public interface ProviderAccessSpi extends ProviderAccess { // // /** // * @param entityMangager JPA entity manager reference. // * @param work Execute the work passing in the underlying JDBC connection object. // */ // public void run(EntityManager entityManager, Consumer<Connection> work); // // // /** // * @param entityManager JPA entity manager reference. // * @param work Work to execute passing in the underlying JDBC connection object. // * @return the output of the work. // */ // public <R> R exec(EntityManager entityManager, Function<Connection, R> work); // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/AbstractCopyCommandImpl.java import com.eclecticlogic.pedal.connection.ConnectionAccessor; import com.eclecticlogic.pedal.provider.ProviderAccessSpi; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.Serializable; /* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql; /** * Created by kabram. */ public abstract class AbstractCopyCommandImpl implements CopyCommand { protected ConnectionAccessor connectionAccessor;
protected ProviderAccessSpi providerAccessSpi;
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/SimpleColumnEvaluator.java
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // }
import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import javax.persistence.Column; import java.lang.reflect.Method;
/* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public class SimpleColumnEvaluator extends AbstractMethodEvaluator { @Override public void evaluate(Method method, EvaluatorChain chain) { if (method.isAnnotationPresent(Column.class) && method.getAnnotation(Column.class).insertable()) {
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/SimpleColumnEvaluator.java import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import javax.persistence.Column; import java.lang.reflect.Method; /* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public class SimpleColumnEvaluator extends AbstractMethodEvaluator { @Override public void evaluate(Method method, EvaluatorChain chain) { if (method.isAnnotationPresent(Column.class) && method.getAnnotation(Column.class).insertable()) {
CopyAttribute attribute = new CopyAttribute();
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/JoinColumnEvaluator.java
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // }
import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import javax.persistence.JoinColumn; import java.lang.reflect.Method;
/* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public class JoinColumnEvaluator extends AbstractMethodEvaluator { @Override public void evaluate(Method method, EvaluatorChain chain) { if (method.isAnnotationPresent(JoinColumn.class) && method.getAnnotation(JoinColumn.class).insertable()) {
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/JoinColumnEvaluator.java import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import javax.persistence.JoinColumn; import java.lang.reflect.Method; /* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public class JoinColumnEvaluator extends AbstractMethodEvaluator { @Override public void evaluate(Method method, EvaluatorChain chain) { if (method.isAnnotationPresent(JoinColumn.class) && method.getAnnotation(JoinColumn.class).insertable()) {
CopyAttribute attribute = new CopyAttribute();
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyCommandImpl.java
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EvaluatorChain.java // public interface EvaluatorChain { // // Class<?> getEntityClass(); // // // /** // * Add attribute to evaluated attributes list. // * @param attribute // */ // void add(CopyAttribute attribute); // // // /** // * Call the next method evaluator. // */ // void doNext(); // } // // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/MethodEvaluator.java // public interface MethodEvaluator { // // void evaluate(Method method, EvaluatorChain chain); // // // default void evaluate(Method method, Class<?> clz, List<CopyAttribute> attributes) { // List<MethodEvaluator> evaluators = new ArrayList<>(); // evaluators.add(new IdentityIdEvaluator()); // evaluators.add(new SimpleColumnEvaluator()); // evaluators.add(new JoinColumnEvaluator()); // evaluators.add(new EmbeddedIdColumnEvaluator()); // evaluators.add(new EmbeddedColumnEvaluator()); // // EvaluatorChain chain = new EvaluatorChain() { // int index = 0; // // // @Override // public Class<?> getEntityClass() { // return clz; // } // // // @Override // public void add(CopyAttribute attribute) { // attributes.add(attribute); // } // // // @Override // public void doNext() { // index++; // if (index < evaluators.size()) { // evaluators.get(index).evaluate(method, this); // } // } // }; // // evaluators.get(0).evaluate(method, chain); // } // }
import com.eclecticlogic.pedal.dialect.postgresql.eval.EvaluatorChain; import com.eclecticlogic.pedal.dialect.postgresql.eval.MethodEvaluator; import com.google.common.base.Stopwatch; import javassist.*; import org.postgresql.copy.CopyIn; import org.postgresql.copy.CopyManager; import org.postgresql.core.BaseConnection; import org.postgresql.core.Encoding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.stringtemplate.v4.ST; import org.stringtemplate.v4.STGroup; import org.stringtemplate.v4.STGroupFile; import javax.persistence.EntityManager; import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import static java.util.stream.Collectors.toList;
try { for (E e : entityList) { byte[] buf = encoding.encode(extractor.getValueList(e)); cp.writeToCopy(buf, 0, buf.length); } records = cp.endCopy(); } finally { if (cp.isActive()) { cp.cancelCopy(); } } assert records == entityList.size(); logger.info("Wrote {} inserts in {}", records, timer.stop());// auto-selects units } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }); } protected List<CopyAttribute> getAttributesOfInterest(Class<? extends Serializable> clz) { List<CopyAttribute> attributes = new ArrayList<>(); for (Method method : Arrays.stream(clz.getMethods()).filter(it -> it.getParameterCount() == 0).collect(toList())) { getMethodEvaluator().evaluate(method, clz, attributes); } return attributes; }
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EvaluatorChain.java // public interface EvaluatorChain { // // Class<?> getEntityClass(); // // // /** // * Add attribute to evaluated attributes list. // * @param attribute // */ // void add(CopyAttribute attribute); // // // /** // * Call the next method evaluator. // */ // void doNext(); // } // // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/MethodEvaluator.java // public interface MethodEvaluator { // // void evaluate(Method method, EvaluatorChain chain); // // // default void evaluate(Method method, Class<?> clz, List<CopyAttribute> attributes) { // List<MethodEvaluator> evaluators = new ArrayList<>(); // evaluators.add(new IdentityIdEvaluator()); // evaluators.add(new SimpleColumnEvaluator()); // evaluators.add(new JoinColumnEvaluator()); // evaluators.add(new EmbeddedIdColumnEvaluator()); // evaluators.add(new EmbeddedColumnEvaluator()); // // EvaluatorChain chain = new EvaluatorChain() { // int index = 0; // // // @Override // public Class<?> getEntityClass() { // return clz; // } // // // @Override // public void add(CopyAttribute attribute) { // attributes.add(attribute); // } // // // @Override // public void doNext() { // index++; // if (index < evaluators.size()) { // evaluators.get(index).evaluate(method, this); // } // } // }; // // evaluators.get(0).evaluate(method, chain); // } // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyCommandImpl.java import com.eclecticlogic.pedal.dialect.postgresql.eval.EvaluatorChain; import com.eclecticlogic.pedal.dialect.postgresql.eval.MethodEvaluator; import com.google.common.base.Stopwatch; import javassist.*; import org.postgresql.copy.CopyIn; import org.postgresql.copy.CopyManager; import org.postgresql.core.BaseConnection; import org.postgresql.core.Encoding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.stringtemplate.v4.ST; import org.stringtemplate.v4.STGroup; import org.stringtemplate.v4.STGroupFile; import javax.persistence.EntityManager; import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import static java.util.stream.Collectors.toList; try { for (E e : entityList) { byte[] buf = encoding.encode(extractor.getValueList(e)); cp.writeToCopy(buf, 0, buf.length); } records = cp.endCopy(); } finally { if (cp.isActive()) { cp.cancelCopy(); } } assert records == entityList.size(); logger.info("Wrote {} inserts in {}", records, timer.stop());// auto-selects units } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }); } protected List<CopyAttribute> getAttributesOfInterest(Class<? extends Serializable> clz) { List<CopyAttribute> attributes = new ArrayList<>(); for (Method method : Arrays.stream(clz.getMethods()).filter(it -> it.getParameterCount() == 0).collect(toList())) { getMethodEvaluator().evaluate(method, clz, attributes); } return attributes; }
protected MethodEvaluator getMethodEvaluator() {
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyCommandImpl.java
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EvaluatorChain.java // public interface EvaluatorChain { // // Class<?> getEntityClass(); // // // /** // * Add attribute to evaluated attributes list. // * @param attribute // */ // void add(CopyAttribute attribute); // // // /** // * Call the next method evaluator. // */ // void doNext(); // } // // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/MethodEvaluator.java // public interface MethodEvaluator { // // void evaluate(Method method, EvaluatorChain chain); // // // default void evaluate(Method method, Class<?> clz, List<CopyAttribute> attributes) { // List<MethodEvaluator> evaluators = new ArrayList<>(); // evaluators.add(new IdentityIdEvaluator()); // evaluators.add(new SimpleColumnEvaluator()); // evaluators.add(new JoinColumnEvaluator()); // evaluators.add(new EmbeddedIdColumnEvaluator()); // evaluators.add(new EmbeddedColumnEvaluator()); // // EvaluatorChain chain = new EvaluatorChain() { // int index = 0; // // // @Override // public Class<?> getEntityClass() { // return clz; // } // // // @Override // public void add(CopyAttribute attribute) { // attributes.add(attribute); // } // // // @Override // public void doNext() { // index++; // if (index < evaluators.size()) { // evaluators.get(index).evaluate(method, this); // } // } // }; // // evaluators.get(0).evaluate(method, chain); // } // }
import com.eclecticlogic.pedal.dialect.postgresql.eval.EvaluatorChain; import com.eclecticlogic.pedal.dialect.postgresql.eval.MethodEvaluator; import com.google.common.base.Stopwatch; import javassist.*; import org.postgresql.copy.CopyIn; import org.postgresql.copy.CopyManager; import org.postgresql.core.BaseConnection; import org.postgresql.core.Encoding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.stringtemplate.v4.ST; import org.stringtemplate.v4.STGroup; import org.stringtemplate.v4.STGroupFile; import javax.persistence.EntityManager; import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import static java.util.stream.Collectors.toList;
cp.writeToCopy(buf, 0, buf.length); } records = cp.endCopy(); } finally { if (cp.isActive()) { cp.cancelCopy(); } } assert records == entityList.size(); logger.info("Wrote {} inserts in {}", records, timer.stop());// auto-selects units } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }); } protected List<CopyAttribute> getAttributesOfInterest(Class<? extends Serializable> clz) { List<CopyAttribute> attributes = new ArrayList<>(); for (Method method : Arrays.stream(clz.getMethods()).filter(it -> it.getParameterCount() == 0).collect(toList())) { getMethodEvaluator().evaluate(method, clz, attributes); } return attributes; } protected MethodEvaluator getMethodEvaluator() { return new MethodEvaluator() { @Override
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EvaluatorChain.java // public interface EvaluatorChain { // // Class<?> getEntityClass(); // // // /** // * Add attribute to evaluated attributes list. // * @param attribute // */ // void add(CopyAttribute attribute); // // // /** // * Call the next method evaluator. // */ // void doNext(); // } // // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/MethodEvaluator.java // public interface MethodEvaluator { // // void evaluate(Method method, EvaluatorChain chain); // // // default void evaluate(Method method, Class<?> clz, List<CopyAttribute> attributes) { // List<MethodEvaluator> evaluators = new ArrayList<>(); // evaluators.add(new IdentityIdEvaluator()); // evaluators.add(new SimpleColumnEvaluator()); // evaluators.add(new JoinColumnEvaluator()); // evaluators.add(new EmbeddedIdColumnEvaluator()); // evaluators.add(new EmbeddedColumnEvaluator()); // // EvaluatorChain chain = new EvaluatorChain() { // int index = 0; // // // @Override // public Class<?> getEntityClass() { // return clz; // } // // // @Override // public void add(CopyAttribute attribute) { // attributes.add(attribute); // } // // // @Override // public void doNext() { // index++; // if (index < evaluators.size()) { // evaluators.get(index).evaluate(method, this); // } // } // }; // // evaluators.get(0).evaluate(method, chain); // } // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyCommandImpl.java import com.eclecticlogic.pedal.dialect.postgresql.eval.EvaluatorChain; import com.eclecticlogic.pedal.dialect.postgresql.eval.MethodEvaluator; import com.google.common.base.Stopwatch; import javassist.*; import org.postgresql.copy.CopyIn; import org.postgresql.copy.CopyManager; import org.postgresql.core.BaseConnection; import org.postgresql.core.Encoding; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.stringtemplate.v4.ST; import org.stringtemplate.v4.STGroup; import org.stringtemplate.v4.STGroupFile; import javax.persistence.EntityManager; import java.io.Serializable; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; import static java.util.stream.Collectors.toList; cp.writeToCopy(buf, 0, buf.length); } records = cp.endCopy(); } finally { if (cp.isActive()) { cp.cancelCopy(); } } assert records == entityList.size(); logger.info("Wrote {} inserts in {}", records, timer.stop());// auto-selects units } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }); } protected List<CopyAttribute> getAttributesOfInterest(Class<? extends Serializable> clz) { List<CopyAttribute> attributes = new ArrayList<>(); for (Method method : Arrays.stream(clz.getMethods()).filter(it -> it.getParameterCount() == 0).collect(toList())) { getMethodEvaluator().evaluate(method, clz, attributes); } return attributes; } protected MethodEvaluator getMethodEvaluator() { return new MethodEvaluator() { @Override
public void evaluate(Method method, EvaluatorChain chain) {
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EmbeddedIdColumnEvaluator.java
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // }
import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import javax.persistence.AttributeOverride; import javax.persistence.EmbeddedId; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.util.Map;
/* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public class EmbeddedIdColumnEvaluator extends AbstractMethodEvaluator { @Override public void evaluate(Method method, EvaluatorChain chain) { if (method.isAnnotationPresent(EmbeddedId.class)) { Map<String, AttributeOverride> overrides = getAttributeOverrides(method); Class<?> embeddedClz = method.getReturnType(); BeanInfo info = null; try { info = Introspector.getBeanInfo(embeddedClz); } catch (IntrospectionException e) { throw new RuntimeException(e); } for (String propertyName : overrides.keySet()) { for (PropertyDescriptor propDesc : info.getPropertyDescriptors()) { if (propDesc.getName().equals(propertyName)) {
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EmbeddedIdColumnEvaluator.java import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import javax.persistence.AttributeOverride; import javax.persistence.EmbeddedId; import java.beans.BeanInfo; import java.beans.IntrospectionException; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.lang.reflect.Method; import java.util.Map; /* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public class EmbeddedIdColumnEvaluator extends AbstractMethodEvaluator { @Override public void evaluate(Method method, EvaluatorChain chain) { if (method.isAnnotationPresent(EmbeddedId.class)) { Map<String, AttributeOverride> overrides = getAttributeOverrides(method); Class<?> embeddedClz = method.getReturnType(); BeanInfo info = null; try { info = Introspector.getBeanInfo(embeddedClz); } catch (IntrospectionException e) { throw new RuntimeException(e); } for (String propertyName : overrides.keySet()) { for (PropertyDescriptor propDesc : info.getPropertyDescriptors()) { if (propDesc.getName().equals(propertyName)) {
CopyAttribute attribute = new CopyAttribute();
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/MethodEvaluator.java
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // }
import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List;
/* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public interface MethodEvaluator { void evaluate(Method method, EvaluatorChain chain);
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/MethodEvaluator.java import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; /* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public interface MethodEvaluator { void evaluate(Method method, EvaluatorChain chain);
default void evaluate(Method method, Class<?> clz, List<CopyAttribute> attributes) {
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EmbeddedColumnEvaluator.java
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // }
import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import javax.persistence.AttributeOverride; import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.EmbeddedId; import javax.persistence.Transient; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Map; import static java.util.stream.Collectors.*;
/* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public class EmbeddedColumnEvaluator extends AbstractMethodEvaluator { @Override public void evaluate(Method method, EvaluatorChain chain) { if (method.getReturnType().isAnnotationPresent(Embeddable.class) && !method.isAnnotationPresent(Transient.class)) { Map<String, AttributeOverride> overrides = getAttributeOverrides(method); Class<?> embeddedClz = method.getReturnType(); for (Method embeddedMethod : Arrays.stream(embeddedClz.getMethods()) // .filter(it -> it.isAnnotationPresent(Column.class)) // .collect(toList())) { String name = getPropertyName(embeddedMethod); String columnName = null; if (overrides.containsKey(name)) { columnName = overrides.get(name).column().name(); } else { columnName = embeddedMethod.getAnnotation(Column.class).name(); }
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EmbeddedColumnEvaluator.java import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; import javax.persistence.AttributeOverride; import javax.persistence.Column; import javax.persistence.Embeddable; import javax.persistence.EmbeddedId; import javax.persistence.Transient; import java.lang.reflect.Method; import java.util.Arrays; import java.util.Map; import static java.util.stream.Collectors.*; /* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public class EmbeddedColumnEvaluator extends AbstractMethodEvaluator { @Override public void evaluate(Method method, EvaluatorChain chain) { if (method.getReturnType().isAnnotationPresent(Embeddable.class) && !method.isAnnotationPresent(Transient.class)) { Map<String, AttributeOverride> overrides = getAttributeOverrides(method); Class<?> embeddedClz = method.getReturnType(); for (Method embeddedMethod : Arrays.stream(embeddedClz.getMethods()) // .filter(it -> it.isAnnotationPresent(Column.class)) // .collect(toList())) { String name = getPropertyName(embeddedMethod); String columnName = null; if (overrides.containsKey(name)) { columnName = overrides.get(name).column().name(); } else { columnName = embeddedMethod.getAnnotation(Column.class).name(); }
CopyAttribute attribute = new CopyAttribute();
eclecticlogic/pedal-dialect
src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EvaluatorChain.java
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // }
import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute;
/* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public interface EvaluatorChain { Class<?> getEntityClass(); /** * Add attribute to evaluated attributes list. * @param attribute */
// Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/CopyAttribute.java // public class CopyAttribute { // // private final List<Method> methods = new ArrayList<>(); // private AtomicLong variableCounter = new AtomicLong(); // private ThreadLocal<String> currentVariable = new ThreadLocal<>(); // private String columnName; // Name of db column. // // // public List<Method> getMethods() { // return methods; // } // // // public Method getEntityMethod() { // return methods.get(0); // } // // // public String getColumnName() { // return columnName; // } // // // public void setColumnName(String columnName) { // this.columnName = columnName; // } // // // public String getNewVariable() { // currentVariable.set("v" + variableCounter.getAndIncrement()); // return getVariable(); // } // // // public String getVariable() { // return currentVariable.get(); // } // // // public boolean isCopyConverter() { // return getEntityMethod().isAnnotationPresent(CopyConverter.class); // } // // // public Class<?> getCopyConverterClass() { // return getEntityMethod().getAnnotation(CopyConverter.class).value(); // } // // // public boolean isCopyAsBitString() { // return getEntityMethod().isAnnotationPresent(CopyAsBitString.class); // } // // // public int getColumnLength() { // return getEntityMethod().getAnnotation(Column.class).length(); // } // // // public boolean isJpaConverter() { // return getEntityMethod().isAnnotationPresent(Convert.class); // } // // // public Class<? extends Converter> getJpaConverterClass() { // return getEntityMethod().getAnnotation(Convert.class).converter(); // } // // // public boolean isCollection() { // return Collection.class.isAssignableFrom(getEntityMethod().getReturnType()); // } // // // public boolean isCopyEmptyAsNull() { // return getEntityMethod().isAnnotationPresent(CopyEmptyAsNull.class); // } // // // public boolean isJoinColumn() { // return getEntityMethod().isAnnotationPresent(JoinColumn.class); // } // // // public Method getJoinColumnIdMethod() { // return Arrays.stream(getEntityMethod().getReturnType().getMethods()) // // .filter(it -> it.isAnnotationPresent(Id.class)).findFirst().get(); // } // } // Path: src/main/java/com/eclecticlogic/pedal/dialect/postgresql/eval/EvaluatorChain.java import com.eclecticlogic.pedal.dialect.postgresql.CopyAttribute; /* * Copyright (c) 2017 Eclectic Logic LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.eclecticlogic.pedal.dialect.postgresql.eval; /** * Created by kabram on 4/6/17. */ public interface EvaluatorChain { Class<?> getEntityClass(); /** * Add attribute to evaluated attributes list. * @param attribute */
void add(CopyAttribute attribute);
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/datasource/sparql/SparqlBasedRequestProcessorForTPFs.java
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // }
import java.net.URI; import java.net.URISyntaxException; import org.apache.http.client.utils.URIBuilder; import org.apache.jena.query.ParameterizedSparqlString; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryExecutionFactory; import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.query.ResultSet; import org.apache.jena.query.Syntax; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.RDFNode; import org.linkeddatafragments.datasource.AbstractRequestProcessorForTriplePatterns; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest;
package org.linkeddatafragments.datasource.sparql; /** * Implementation of {@link IFragmentRequestProcessor} that processes * {@link ITriplePatternFragmentRequest}s over data stored behind a SPARQL-Query endpoint. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public class SparqlBasedRequestProcessorForTPFs extends AbstractRequestProcessorForTriplePatterns<RDFNode,String,String> { private final URI endpointURI; private final String username; private final String password; private final String sparql = "CONSTRUCT WHERE { ?s ?p ?o } "; private final String count = "SELECT (COUNT(?s) AS ?count) WHERE { ?s ?p ?o }"; private final Query query = QueryFactory.create(sparql, Syntax.syntaxSPARQL_11); private final Query countQuery = QueryFactory.create(count, Syntax.syntaxSPARQL_11); /** * * @param request * @return * @throws IllegalArgumentException */ @Override protected Worker getTPFSpecificWorker( final ITriplePatternFragmentRequest<RDFNode,String,String> request ) throws IllegalArgumentException { return new Worker( request ); } /** * */ protected class Worker extends AbstractRequestProcessorForTriplePatterns.Worker<RDFNode,String,String> { /** * * @param req */ public Worker( final ITriplePatternFragmentRequest<RDFNode,String,String> req ) { super( req ); } /** * * @param subject * @param predicate * @param object * @param offset * @param limit * @return */ @Override
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // Path: src/main/java/org/linkeddatafragments/datasource/sparql/SparqlBasedRequestProcessorForTPFs.java import java.net.URI; import java.net.URISyntaxException; import org.apache.http.client.utils.URIBuilder; import org.apache.jena.query.ParameterizedSparqlString; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryExecutionFactory; import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.query.ResultSet; import org.apache.jena.query.Syntax; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.RDFNode; import org.linkeddatafragments.datasource.AbstractRequestProcessorForTriplePatterns; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; package org.linkeddatafragments.datasource.sparql; /** * Implementation of {@link IFragmentRequestProcessor} that processes * {@link ITriplePatternFragmentRequest}s over data stored behind a SPARQL-Query endpoint. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public class SparqlBasedRequestProcessorForTPFs extends AbstractRequestProcessorForTriplePatterns<RDFNode,String,String> { private final URI endpointURI; private final String username; private final String password; private final String sparql = "CONSTRUCT WHERE { ?s ?p ?o } "; private final String count = "SELECT (COUNT(?s) AS ?count) WHERE { ?s ?p ?o }"; private final Query query = QueryFactory.create(sparql, Syntax.syntaxSPARQL_11); private final Query countQuery = QueryFactory.create(count, Syntax.syntaxSPARQL_11); /** * * @param request * @return * @throws IllegalArgumentException */ @Override protected Worker getTPFSpecificWorker( final ITriplePatternFragmentRequest<RDFNode,String,String> request ) throws IllegalArgumentException { return new Worker( request ); } /** * */ protected class Worker extends AbstractRequestProcessorForTriplePatterns.Worker<RDFNode,String,String> { /** * * @param req */ public Worker( final ITriplePatternFragmentRequest<RDFNode,String,String> req ) { super( req ); } /** * * @param subject * @param predicate * @param object * @param offset * @param limit * @return */ @Override
protected ILinkedDataFragment createFragment(
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/datasource/tdb/JenaTDBDataSource.java
// Path: src/main/java/org/linkeddatafragments/datasource/DataSourceBase.java // public abstract class DataSourceBase implements IDataSource { // // /** // * Get the datasource title // */ // protected String title; // // /** // * Get the datasource description // */ // protected String description; // // /** // * Create a base for a {@link IDataSource} // * // * @param title the datasource title // * @param description the datasource description // */ // public DataSourceBase(String title, String description) { // this.title = title; // this.description = description; // } // // /** // * Get the datasource description // * // * @return // */ // @Override // public String getDescription() { // return this.description; // }; // // /** // * Get the datasource title // * // * @return // */ // @Override // public String getTitle() { // return this.title; // }; // // @Override // public void close() {} // } // // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/IFragmentRequestParser.java // public interface IFragmentRequestParser // { // /** // * Parses the given HTTP request into a specific // * {@link ILinkedDataFragmentRequest}. // * // * @param httpRequest // * @param config // * @return // * @throws IllegalArgumentException // * If the given HTTP request cannot be interpreted (perhaps due to // * missing request parameters). // */ // ILinkedDataFragmentRequest parseIntoFragmentRequest( // final HttpServletRequest httpRequest, // final ConfigReader config ) // throws IllegalArgumentException; // }
import java.io.File; import org.linkeddatafragments.datasource.DataSourceBase; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.IFragmentRequestParser; import org.linkeddatafragments.fragments.tpf.TPFRequestParserForJenaBackends;
package org.linkeddatafragments.datasource.tdb; /** * Experimental Jena TDB-backed data source of Basic Linked Data Fragments. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public class JenaTDBDataSource extends DataSourceBase { /** * The request processor * */ protected final JenaTDBBasedRequestProcessorForTPFs requestProcessor; @Override
// Path: src/main/java/org/linkeddatafragments/datasource/DataSourceBase.java // public abstract class DataSourceBase implements IDataSource { // // /** // * Get the datasource title // */ // protected String title; // // /** // * Get the datasource description // */ // protected String description; // // /** // * Create a base for a {@link IDataSource} // * // * @param title the datasource title // * @param description the datasource description // */ // public DataSourceBase(String title, String description) { // this.title = title; // this.description = description; // } // // /** // * Get the datasource description // * // * @return // */ // @Override // public String getDescription() { // return this.description; // }; // // /** // * Get the datasource title // * // * @return // */ // @Override // public String getTitle() { // return this.title; // }; // // @Override // public void close() {} // } // // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/IFragmentRequestParser.java // public interface IFragmentRequestParser // { // /** // * Parses the given HTTP request into a specific // * {@link ILinkedDataFragmentRequest}. // * // * @param httpRequest // * @param config // * @return // * @throws IllegalArgumentException // * If the given HTTP request cannot be interpreted (perhaps due to // * missing request parameters). // */ // ILinkedDataFragmentRequest parseIntoFragmentRequest( // final HttpServletRequest httpRequest, // final ConfigReader config ) // throws IllegalArgumentException; // } // Path: src/main/java/org/linkeddatafragments/datasource/tdb/JenaTDBDataSource.java import java.io.File; import org.linkeddatafragments.datasource.DataSourceBase; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.IFragmentRequestParser; import org.linkeddatafragments.fragments.tpf.TPFRequestParserForJenaBackends; package org.linkeddatafragments.datasource.tdb; /** * Experimental Jena TDB-backed data source of Basic Linked Data Fragments. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public class JenaTDBDataSource extends DataSourceBase { /** * The request processor * */ protected final JenaTDBBasedRequestProcessorForTPFs requestProcessor; @Override
public IFragmentRequestParser getRequestParser()
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/datasource/tdb/JenaTDBDataSource.java
// Path: src/main/java/org/linkeddatafragments/datasource/DataSourceBase.java // public abstract class DataSourceBase implements IDataSource { // // /** // * Get the datasource title // */ // protected String title; // // /** // * Get the datasource description // */ // protected String description; // // /** // * Create a base for a {@link IDataSource} // * // * @param title the datasource title // * @param description the datasource description // */ // public DataSourceBase(String title, String description) { // this.title = title; // this.description = description; // } // // /** // * Get the datasource description // * // * @return // */ // @Override // public String getDescription() { // return this.description; // }; // // /** // * Get the datasource title // * // * @return // */ // @Override // public String getTitle() { // return this.title; // }; // // @Override // public void close() {} // } // // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/IFragmentRequestParser.java // public interface IFragmentRequestParser // { // /** // * Parses the given HTTP request into a specific // * {@link ILinkedDataFragmentRequest}. // * // * @param httpRequest // * @param config // * @return // * @throws IllegalArgumentException // * If the given HTTP request cannot be interpreted (perhaps due to // * missing request parameters). // */ // ILinkedDataFragmentRequest parseIntoFragmentRequest( // final HttpServletRequest httpRequest, // final ConfigReader config ) // throws IllegalArgumentException; // }
import java.io.File; import org.linkeddatafragments.datasource.DataSourceBase; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.IFragmentRequestParser; import org.linkeddatafragments.fragments.tpf.TPFRequestParserForJenaBackends;
package org.linkeddatafragments.datasource.tdb; /** * Experimental Jena TDB-backed data source of Basic Linked Data Fragments. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public class JenaTDBDataSource extends DataSourceBase { /** * The request processor * */ protected final JenaTDBBasedRequestProcessorForTPFs requestProcessor; @Override public IFragmentRequestParser getRequestParser() { return TPFRequestParserForJenaBackends.getInstance(); } @Override
// Path: src/main/java/org/linkeddatafragments/datasource/DataSourceBase.java // public abstract class DataSourceBase implements IDataSource { // // /** // * Get the datasource title // */ // protected String title; // // /** // * Get the datasource description // */ // protected String description; // // /** // * Create a base for a {@link IDataSource} // * // * @param title the datasource title // * @param description the datasource description // */ // public DataSourceBase(String title, String description) { // this.title = title; // this.description = description; // } // // /** // * Get the datasource description // * // * @return // */ // @Override // public String getDescription() { // return this.description; // }; // // /** // * Get the datasource title // * // * @return // */ // @Override // public String getTitle() { // return this.title; // }; // // @Override // public void close() {} // } // // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/IFragmentRequestParser.java // public interface IFragmentRequestParser // { // /** // * Parses the given HTTP request into a specific // * {@link ILinkedDataFragmentRequest}. // * // * @param httpRequest // * @param config // * @return // * @throws IllegalArgumentException // * If the given HTTP request cannot be interpreted (perhaps due to // * missing request parameters). // */ // ILinkedDataFragmentRequest parseIntoFragmentRequest( // final HttpServletRequest httpRequest, // final ConfigReader config ) // throws IllegalArgumentException; // } // Path: src/main/java/org/linkeddatafragments/datasource/tdb/JenaTDBDataSource.java import java.io.File; import org.linkeddatafragments.datasource.DataSourceBase; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.IFragmentRequestParser; import org.linkeddatafragments.fragments.tpf.TPFRequestParserForJenaBackends; package org.linkeddatafragments.datasource.tdb; /** * Experimental Jena TDB-backed data source of Basic Linked Data Fragments. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public class JenaTDBDataSource extends DataSourceBase { /** * The request processor * */ protected final JenaTDBBasedRequestProcessorForTPFs requestProcessor; @Override public IFragmentRequestParser getRequestParser() { return TPFRequestParserForJenaBackends.getInstance(); } @Override
public IFragmentRequestProcessor getRequestProcessor()
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/datasource/tdb/JenaTDBBasedRequestProcessorForTPFs.java
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // }
import java.io.File; import org.apache.jena.query.Dataset; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryExecutionFactory; import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.query.ResultSet; import org.apache.jena.query.Syntax; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.tdb.TDBFactory; import org.linkeddatafragments.datasource.AbstractRequestProcessorForTriplePatterns; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest;
package org.linkeddatafragments.datasource.tdb; /** * Implementation of {@link IFragmentRequestProcessor} that processes * {@link ITriplePatternFragmentRequest}s over data stored in Jena TDB. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public class JenaTDBBasedRequestProcessorForTPFs extends AbstractRequestProcessorForTriplePatterns<RDFNode,String,String> { private final Dataset tdb; private final String defaultGraph; private final String sparql = "CONSTRUCT WHERE { ?s ?p ?o } " + "ORDER BY ?s ?p ?o"; private final String count = "SELECT (COUNT(?s) AS ?count) WHERE { ?s ?p ?o }"; private final Query query = QueryFactory.create(sparql, Syntax.syntaxSPARQL_11); private final Query countQuery = QueryFactory.create(count, Syntax.syntaxSPARQL_11); /** * * @param request * @return * @throws IllegalArgumentException */ @Override protected Worker getTPFSpecificWorker( final ITriplePatternFragmentRequest<RDFNode,String,String> request ) throws IllegalArgumentException { return new Worker( request ); } /** * */ protected class Worker extends AbstractRequestProcessorForTriplePatterns.Worker<RDFNode,String,String> { /** * * @param req */ public Worker( final ITriplePatternFragmentRequest<RDFNode,String,String> req ) { super( req ); } /** * * @param subject * @param predicate * @param object * @param offset * @param limit * @return */ @Override
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // Path: src/main/java/org/linkeddatafragments/datasource/tdb/JenaTDBBasedRequestProcessorForTPFs.java import java.io.File; import org.apache.jena.query.Dataset; import org.apache.jena.query.Query; import org.apache.jena.query.QueryExecution; import org.apache.jena.query.QueryExecutionFactory; import org.apache.jena.query.QueryFactory; import org.apache.jena.query.QuerySolution; import org.apache.jena.query.QuerySolutionMap; import org.apache.jena.query.ResultSet; import org.apache.jena.query.Syntax; import org.apache.jena.rdf.model.Literal; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.tdb.TDBFactory; import org.linkeddatafragments.datasource.AbstractRequestProcessorForTriplePatterns; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; package org.linkeddatafragments.datasource.tdb; /** * Implementation of {@link IFragmentRequestProcessor} that processes * {@link ITriplePatternFragmentRequest}s over data stored in Jena TDB. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public class JenaTDBBasedRequestProcessorForTPFs extends AbstractRequestProcessorForTriplePatterns<RDFNode,String,String> { private final Dataset tdb; private final String defaultGraph; private final String sparql = "CONSTRUCT WHERE { ?s ?p ?o } " + "ORDER BY ?s ?p ?o"; private final String count = "SELECT (COUNT(?s) AS ?count) WHERE { ?s ?p ?o }"; private final Query query = QueryFactory.create(sparql, Syntax.syntaxSPARQL_11); private final Query countQuery = QueryFactory.create(count, Syntax.syntaxSPARQL_11); /** * * @param request * @return * @throws IllegalArgumentException */ @Override protected Worker getTPFSpecificWorker( final ITriplePatternFragmentRequest<RDFNode,String,String> request ) throws IllegalArgumentException { return new Worker( request ); } /** * */ protected class Worker extends AbstractRequestProcessorForTriplePatterns.Worker<RDFNode,String,String> { /** * * @param req */ public Worker( final ITriplePatternFragmentRequest<RDFNode,String,String> req ) { super( req ); } /** * * @param subject * @param predicate * @param object * @param offset * @param limit * @return */ @Override
protected ILinkedDataFragment createFragment(
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/views/RdfWriterImpl.java
// Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // }
import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import org.apache.jena.query.ARQ; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFDataMgr; import org.apache.jena.riot.RDFLanguages; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.ILinkedDataFragmentRequest;
package org.linkeddatafragments.views; /** * Serializes an {@link ILinkedDataFragment} to an RDF format * * @author Miel Vander Sande */ class RdfWriterImpl extends LinkedDataFragmentWriterBase implements ILinkedDataFragmentWriter { private final Lang contentType; public RdfWriterImpl(Map<String, String> prefixes, HashMap<String, IDataSource> datasources, String mimeType) { super(prefixes, datasources); this.contentType = RDFLanguages.contentTypeToLang(mimeType); ARQ.init(); } @Override public void writeNotFound(ServletOutputStream outputStream, HttpServletRequest request) throws IOException { outputStream.println(request.getRequestURL().toString() + " not found!"); outputStream.close(); } @Override public void writeError(ServletOutputStream outputStream, Exception ex) throws IOException { outputStream.println(ex.getMessage()); outputStream.close(); } @Override
// Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // Path: src/main/java/org/linkeddatafragments/views/RdfWriterImpl.java import java.io.IOException; import java.util.HashMap; import java.util.Map; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import org.apache.jena.query.ARQ; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.riot.Lang; import org.apache.jena.riot.RDFDataMgr; import org.apache.jena.riot.RDFLanguages; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.ILinkedDataFragmentRequest; package org.linkeddatafragments.views; /** * Serializes an {@link ILinkedDataFragment} to an RDF format * * @author Miel Vander Sande */ class RdfWriterImpl extends LinkedDataFragmentWriterBase implements ILinkedDataFragmentWriter { private final Lang contentType; public RdfWriterImpl(Map<String, String> prefixes, HashMap<String, IDataSource> datasources, String mimeType) { super(prefixes, datasources); this.contentType = RDFLanguages.contentTypeToLang(mimeType); ARQ.init(); } @Override public void writeNotFound(ServletOutputStream outputStream, HttpServletRequest request) throws IOException { outputStream.println(request.getRequestURL().toString() + " not found!"); outputStream.close(); } @Override public void writeError(ServletOutputStream outputStream, Exception ex) throws IOException { outputStream.println(ex.getMessage()); outputStream.close(); } @Override
public void writeFragment(ServletOutputStream outputStream, IDataSource datasource, ILinkedDataFragment fragment, ILinkedDataFragmentRequest ldfRequest) throws Exception {
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java
// Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // }
import java.io.Closeable; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.ILinkedDataFragmentRequest; import org.linkeddatafragments.fragments.ILinkedDataFragmentRequest;
package org.linkeddatafragments.datasource; /** * Processes {@link ILinkedDataFragmentRequest}s and returns * the requested {@link ILinkedDataFragment}s. * * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public interface IFragmentRequestProcessor extends Closeable { /** * * @param request * @return * @throws IllegalArgumentException */
// Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java import java.io.Closeable; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.ILinkedDataFragmentRequest; import org.linkeddatafragments.fragments.ILinkedDataFragmentRequest; package org.linkeddatafragments.datasource; /** * Processes {@link ILinkedDataFragmentRequest}s and returns * the requested {@link ILinkedDataFragment}s. * * @author <a href="http://olafhartig.de">Olaf Hartig</a> */ public interface IFragmentRequestProcessor extends Closeable { /** * * @param request * @return * @throws IllegalArgumentException */
ILinkedDataFragment createRequestedFragment(
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/datasource/index/IndexRequestProcessorForTPFs.java
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // }
import java.util.HashMap; import java.util.Map; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.rdf.model.StmtIterator; import org.apache.jena.rdf.model.impl.PropertyImpl; import org.apache.jena.rdf.model.impl.ResourceImpl; import org.linkeddatafragments.datasource.AbstractRequestProcessorForTriplePatterns; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest;
} /** * Worker for the index */ protected class Worker extends AbstractRequestProcessorForTriplePatterns.Worker<RDFNode,String,String> { /** * Creates a Worker for the datasource index * * @param req */ public Worker( final ITriplePatternFragmentRequest<RDFNode,String,String> req ) { super( req ); } /** * * @param s * @param p * @param o * @param offset * @param limit * @return */ @Override
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // Path: src/main/java/org/linkeddatafragments/datasource/index/IndexRequestProcessorForTPFs.java import java.util.HashMap; import java.util.Map; import org.apache.jena.rdf.model.Model; import org.apache.jena.rdf.model.ModelFactory; import org.apache.jena.rdf.model.Property; import org.apache.jena.rdf.model.RDFNode; import org.apache.jena.rdf.model.Resource; import org.apache.jena.rdf.model.ResourceFactory; import org.apache.jena.rdf.model.StmtIterator; import org.apache.jena.rdf.model.impl.PropertyImpl; import org.apache.jena.rdf.model.impl.ResourceImpl; import org.linkeddatafragments.datasource.AbstractRequestProcessorForTriplePatterns; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; } /** * Worker for the index */ protected class Worker extends AbstractRequestProcessorForTriplePatterns.Worker<RDFNode,String,String> { /** * Creates a Worker for the datasource index * * @param req */ public Worker( final ITriplePatternFragmentRequest<RDFNode,String,String> req ) { super( req ); } /** * * @param s * @param p * @param o * @param offset * @param limit * @return */ @Override
protected ILinkedDataFragment createFragment(
LinkedDataFragments/Server.Java
src/test/java/org/linkeddatafragments/test/datasource/DataSourceTest.java
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // // Path: src/main/java/org/linkeddatafragments/fragments/tpf/ITriplePatternFragment.java // public interface ITriplePatternFragment extends ILinkedDataFragment { // /** // * Gets the total number of triples in the fragment (can be an estimate). // * @return the total number of triples // */ // public long getTotalSize(); // }
import com.google.gson.JsonObject; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import org.junit.Assert; import org.junit.Test; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequestImpl; import org.linkeddatafragments.util.TriplePatternElementParser;
*/ public static JsonObject createConfig(String title, String desc, String type) { JsonObject config = new JsonObject(); config.addProperty("title", title); config.addProperty("description", desc); config.addProperty("type", type); return config; } /** * Test total size of empty TPF * */ @Test public void testEmpty() { final TriplePatternElementParser<ConstantTermType,NamedVarType,AnonVarType> tpeParser = getTriplePatternElementParser(); final ITriplePatternFragmentRequest<ConstantTermType,NamedVarType,AnonVarType> request = new TriplePatternFragmentRequestImpl<ConstantTermType,NamedVarType,AnonVarType>( "http://example.org/f", // fragmentURL "http://example.org/", // datasetURL, true, // pageNumberWasRequested, 1L, //pageNumber, tpeParser.parseIntoTriplePatternElement("http://nothing.ldf.org"), // subject, tpeParser.parseIntoTriplePatternElement(null), // predicate, tpeParser.parseIntoTriplePatternElement(null) ); //object
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // // Path: src/main/java/org/linkeddatafragments/fragments/tpf/ITriplePatternFragment.java // public interface ITriplePatternFragment extends ILinkedDataFragment { // /** // * Gets the total number of triples in the fragment (can be an estimate). // * @return the total number of triples // */ // public long getTotalSize(); // } // Path: src/test/java/org/linkeddatafragments/test/datasource/DataSourceTest.java import com.google.gson.JsonObject; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import org.junit.Assert; import org.junit.Test; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequestImpl; import org.linkeddatafragments.util.TriplePatternElementParser; */ public static JsonObject createConfig(String title, String desc, String type) { JsonObject config = new JsonObject(); config.addProperty("title", title); config.addProperty("description", desc); config.addProperty("type", type); return config; } /** * Test total size of empty TPF * */ @Test public void testEmpty() { final TriplePatternElementParser<ConstantTermType,NamedVarType,AnonVarType> tpeParser = getTriplePatternElementParser(); final ITriplePatternFragmentRequest<ConstantTermType,NamedVarType,AnonVarType> request = new TriplePatternFragmentRequestImpl<ConstantTermType,NamedVarType,AnonVarType>( "http://example.org/f", // fragmentURL "http://example.org/", // datasetURL, true, // pageNumberWasRequested, 1L, //pageNumber, tpeParser.parseIntoTriplePatternElement("http://nothing.ldf.org"), // subject, tpeParser.parseIntoTriplePatternElement(null), // predicate, tpeParser.parseIntoTriplePatternElement(null) ); //object
final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor();
LinkedDataFragments/Server.Java
src/test/java/org/linkeddatafragments/test/datasource/DataSourceTest.java
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // // Path: src/main/java/org/linkeddatafragments/fragments/tpf/ITriplePatternFragment.java // public interface ITriplePatternFragment extends ILinkedDataFragment { // /** // * Gets the total number of triples in the fragment (can be an estimate). // * @return the total number of triples // */ // public long getTotalSize(); // }
import com.google.gson.JsonObject; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import org.junit.Assert; import org.junit.Test; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequestImpl; import org.linkeddatafragments.util.TriplePatternElementParser;
public static JsonObject createConfig(String title, String desc, String type) { JsonObject config = new JsonObject(); config.addProperty("title", title); config.addProperty("description", desc); config.addProperty("type", type); return config; } /** * Test total size of empty TPF * */ @Test public void testEmpty() { final TriplePatternElementParser<ConstantTermType,NamedVarType,AnonVarType> tpeParser = getTriplePatternElementParser(); final ITriplePatternFragmentRequest<ConstantTermType,NamedVarType,AnonVarType> request = new TriplePatternFragmentRequestImpl<ConstantTermType,NamedVarType,AnonVarType>( "http://example.org/f", // fragmentURL "http://example.org/", // datasetURL, true, // pageNumberWasRequested, 1L, //pageNumber, tpeParser.parseIntoTriplePatternElement("http://nothing.ldf.org"), // subject, tpeParser.parseIntoTriplePatternElement(null), // predicate, tpeParser.parseIntoTriplePatternElement(null) ); //object final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor();
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // // Path: src/main/java/org/linkeddatafragments/fragments/tpf/ITriplePatternFragment.java // public interface ITriplePatternFragment extends ILinkedDataFragment { // /** // * Gets the total number of triples in the fragment (can be an estimate). // * @return the total number of triples // */ // public long getTotalSize(); // } // Path: src/test/java/org/linkeddatafragments/test/datasource/DataSourceTest.java import com.google.gson.JsonObject; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import org.junit.Assert; import org.junit.Test; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequestImpl; import org.linkeddatafragments.util.TriplePatternElementParser; public static JsonObject createConfig(String title, String desc, String type) { JsonObject config = new JsonObject(); config.addProperty("title", title); config.addProperty("description", desc); config.addProperty("type", type); return config; } /** * Test total size of empty TPF * */ @Test public void testEmpty() { final TriplePatternElementParser<ConstantTermType,NamedVarType,AnonVarType> tpeParser = getTriplePatternElementParser(); final ITriplePatternFragmentRequest<ConstantTermType,NamedVarType,AnonVarType> request = new TriplePatternFragmentRequestImpl<ConstantTermType,NamedVarType,AnonVarType>( "http://example.org/f", // fragmentURL "http://example.org/", // datasetURL, true, // pageNumberWasRequested, 1L, //pageNumber, tpeParser.parseIntoTriplePatternElement("http://nothing.ldf.org"), // subject, tpeParser.parseIntoTriplePatternElement(null), // predicate, tpeParser.parseIntoTriplePatternElement(null) ); //object final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor();
final ILinkedDataFragment ldf = proc.createRequestedFragment( request );
LinkedDataFragments/Server.Java
src/test/java/org/linkeddatafragments/test/datasource/DataSourceTest.java
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // // Path: src/main/java/org/linkeddatafragments/fragments/tpf/ITriplePatternFragment.java // public interface ITriplePatternFragment extends ILinkedDataFragment { // /** // * Gets the total number of triples in the fragment (can be an estimate). // * @return the total number of triples // */ // public long getTotalSize(); // }
import com.google.gson.JsonObject; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import org.junit.Assert; import org.junit.Test; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequestImpl; import org.linkeddatafragments.util.TriplePatternElementParser;
JsonObject config = new JsonObject(); config.addProperty("title", title); config.addProperty("description", desc); config.addProperty("type", type); return config; } /** * Test total size of empty TPF * */ @Test public void testEmpty() { final TriplePatternElementParser<ConstantTermType,NamedVarType,AnonVarType> tpeParser = getTriplePatternElementParser(); final ITriplePatternFragmentRequest<ConstantTermType,NamedVarType,AnonVarType> request = new TriplePatternFragmentRequestImpl<ConstantTermType,NamedVarType,AnonVarType>( "http://example.org/f", // fragmentURL "http://example.org/", // datasetURL, true, // pageNumberWasRequested, 1L, //pageNumber, tpeParser.parseIntoTriplePatternElement("http://nothing.ldf.org"), // subject, tpeParser.parseIntoTriplePatternElement(null), // predicate, tpeParser.parseIntoTriplePatternElement(null) ); //object final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor(); final ILinkedDataFragment ldf = proc.createRequestedFragment( request );
// Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/ILinkedDataFragment.java // public interface ILinkedDataFragment extends Closeable // { // /** // * Returns an iterator over the RDF data of this fragment (possibly only // * partial if the data is paged, as indicated by {@link #isPageOnly()}). // * @return // */ // StmtIterator getTriples(); // // /** // * Returns true if {@link #getTriples()} returns a page of data only. // * In this case, {@link #getPageNumber()} can be used to obtain the // * corresponding page number. // * @return // */ // boolean isPageOnly(); // // /** // * Returns the number of the page of data returned by {@link #getTriples()} // * if the data is paged (that is, if {@link #isPageOnly()} returns true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getPageNumber() throws UnsupportedOperationException; // // /** // * Returns true if {@link #getTriples()} returns a page of data only and // * this is the last page of the fragment. // * // * If the data is not paged (i.e., if {@link #isPageOnly()} returns false), // * this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // boolean isLastPage() throws UnsupportedOperationException; // // /** // * Returns the maximum number of triples per page if {@link #getTriples()} // * returns a page of data only (that is, if {@link #isPageOnly()} returns // * true). // * // * If the data is not paged, this method throws an exception. // * // * @return // * @throws UnsupportedOperationException // * If the data of this fragment is not paged. // */ // long getMaxPageSize() throws UnsupportedOperationException; // // /** // * Returns an iterator over the metadata of this fragment. // * @return // */ // StmtIterator getMetadata(); // // /** // * Returns an iterator over an RDF description of the controls associated // * with this fragment. // * @return // */ // StmtIterator getControls(); // } // // Path: src/main/java/org/linkeddatafragments/fragments/tpf/ITriplePatternFragment.java // public interface ITriplePatternFragment extends ILinkedDataFragment { // /** // * Gets the total number of triples in the fragment (can be an estimate). // * @return the total number of triples // */ // public long getTotalSize(); // } // Path: src/test/java/org/linkeddatafragments/test/datasource/DataSourceTest.java import com.google.gson.JsonObject; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.StandardCopyOption; import org.junit.Assert; import org.junit.Test; import org.linkeddatafragments.datasource.IDataSource; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.ILinkedDataFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternElement; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragment; import org.linkeddatafragments.fragments.tpf.ITriplePatternFragmentRequest; import org.linkeddatafragments.fragments.tpf.TriplePatternFragmentRequestImpl; import org.linkeddatafragments.util.TriplePatternElementParser; JsonObject config = new JsonObject(); config.addProperty("title", title); config.addProperty("description", desc); config.addProperty("type", type); return config; } /** * Test total size of empty TPF * */ @Test public void testEmpty() { final TriplePatternElementParser<ConstantTermType,NamedVarType,AnonVarType> tpeParser = getTriplePatternElementParser(); final ITriplePatternFragmentRequest<ConstantTermType,NamedVarType,AnonVarType> request = new TriplePatternFragmentRequestImpl<ConstantTermType,NamedVarType,AnonVarType>( "http://example.org/f", // fragmentURL "http://example.org/", // datasetURL, true, // pageNumberWasRequested, 1L, //pageNumber, tpeParser.parseIntoTriplePatternElement("http://nothing.ldf.org"), // subject, tpeParser.parseIntoTriplePatternElement(null), // predicate, tpeParser.parseIntoTriplePatternElement(null) ); //object final IFragmentRequestProcessor proc = getDatasource().getRequestProcessor(); final ILinkedDataFragment ldf = proc.createRequestedFragment( request );
final ITriplePatternFragment tpf = (ITriplePatternFragment) ldf;
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/datasource/sparql/SparqlDataSource.java
// Path: src/main/java/org/linkeddatafragments/datasource/DataSourceBase.java // public abstract class DataSourceBase implements IDataSource { // // /** // * Get the datasource title // */ // protected String title; // // /** // * Get the datasource description // */ // protected String description; // // /** // * Create a base for a {@link IDataSource} // * // * @param title the datasource title // * @param description the datasource description // */ // public DataSourceBase(String title, String description) { // this.title = title; // this.description = description; // } // // /** // * Get the datasource description // * // * @return // */ // @Override // public String getDescription() { // return this.description; // }; // // /** // * Get the datasource title // * // * @return // */ // @Override // public String getTitle() { // return this.title; // }; // // @Override // public void close() {} // } // // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/IFragmentRequestParser.java // public interface IFragmentRequestParser // { // /** // * Parses the given HTTP request into a specific // * {@link ILinkedDataFragmentRequest}. // * // * @param httpRequest // * @param config // * @return // * @throws IllegalArgumentException // * If the given HTTP request cannot be interpreted (perhaps due to // * missing request parameters). // */ // ILinkedDataFragmentRequest parseIntoFragmentRequest( // final HttpServletRequest httpRequest, // final ConfigReader config ) // throws IllegalArgumentException; // }
import java.io.File; import java.net.URI; import org.linkeddatafragments.datasource.DataSourceBase; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.IFragmentRequestParser; import org.linkeddatafragments.fragments.tpf.TPFRequestParserForJenaBackends;
package org.linkeddatafragments.datasource.sparql; /** * Experimental SPARQL-endpoint-backed data source of Basic Linked Data Fragments. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> * @author <a href="https://awoods.io">Andrew Woods</a> */ public class SparqlDataSource extends DataSourceBase { /** * The request processor * */ protected final SparqlBasedRequestProcessorForTPFs requestProcessor; @Override
// Path: src/main/java/org/linkeddatafragments/datasource/DataSourceBase.java // public abstract class DataSourceBase implements IDataSource { // // /** // * Get the datasource title // */ // protected String title; // // /** // * Get the datasource description // */ // protected String description; // // /** // * Create a base for a {@link IDataSource} // * // * @param title the datasource title // * @param description the datasource description // */ // public DataSourceBase(String title, String description) { // this.title = title; // this.description = description; // } // // /** // * Get the datasource description // * // * @return // */ // @Override // public String getDescription() { // return this.description; // }; // // /** // * Get the datasource title // * // * @return // */ // @Override // public String getTitle() { // return this.title; // }; // // @Override // public void close() {} // } // // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/IFragmentRequestParser.java // public interface IFragmentRequestParser // { // /** // * Parses the given HTTP request into a specific // * {@link ILinkedDataFragmentRequest}. // * // * @param httpRequest // * @param config // * @return // * @throws IllegalArgumentException // * If the given HTTP request cannot be interpreted (perhaps due to // * missing request parameters). // */ // ILinkedDataFragmentRequest parseIntoFragmentRequest( // final HttpServletRequest httpRequest, // final ConfigReader config ) // throws IllegalArgumentException; // } // Path: src/main/java/org/linkeddatafragments/datasource/sparql/SparqlDataSource.java import java.io.File; import java.net.URI; import org.linkeddatafragments.datasource.DataSourceBase; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.IFragmentRequestParser; import org.linkeddatafragments.fragments.tpf.TPFRequestParserForJenaBackends; package org.linkeddatafragments.datasource.sparql; /** * Experimental SPARQL-endpoint-backed data source of Basic Linked Data Fragments. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> * @author <a href="https://awoods.io">Andrew Woods</a> */ public class SparqlDataSource extends DataSourceBase { /** * The request processor * */ protected final SparqlBasedRequestProcessorForTPFs requestProcessor; @Override
public IFragmentRequestParser getRequestParser()
LinkedDataFragments/Server.Java
src/main/java/org/linkeddatafragments/datasource/sparql/SparqlDataSource.java
// Path: src/main/java/org/linkeddatafragments/datasource/DataSourceBase.java // public abstract class DataSourceBase implements IDataSource { // // /** // * Get the datasource title // */ // protected String title; // // /** // * Get the datasource description // */ // protected String description; // // /** // * Create a base for a {@link IDataSource} // * // * @param title the datasource title // * @param description the datasource description // */ // public DataSourceBase(String title, String description) { // this.title = title; // this.description = description; // } // // /** // * Get the datasource description // * // * @return // */ // @Override // public String getDescription() { // return this.description; // }; // // /** // * Get the datasource title // * // * @return // */ // @Override // public String getTitle() { // return this.title; // }; // // @Override // public void close() {} // } // // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/IFragmentRequestParser.java // public interface IFragmentRequestParser // { // /** // * Parses the given HTTP request into a specific // * {@link ILinkedDataFragmentRequest}. // * // * @param httpRequest // * @param config // * @return // * @throws IllegalArgumentException // * If the given HTTP request cannot be interpreted (perhaps due to // * missing request parameters). // */ // ILinkedDataFragmentRequest parseIntoFragmentRequest( // final HttpServletRequest httpRequest, // final ConfigReader config ) // throws IllegalArgumentException; // }
import java.io.File; import java.net.URI; import org.linkeddatafragments.datasource.DataSourceBase; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.IFragmentRequestParser; import org.linkeddatafragments.fragments.tpf.TPFRequestParserForJenaBackends;
package org.linkeddatafragments.datasource.sparql; /** * Experimental SPARQL-endpoint-backed data source of Basic Linked Data Fragments. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> * @author <a href="https://awoods.io">Andrew Woods</a> */ public class SparqlDataSource extends DataSourceBase { /** * The request processor * */ protected final SparqlBasedRequestProcessorForTPFs requestProcessor; @Override public IFragmentRequestParser getRequestParser() { return TPFRequestParserForJenaBackends.getInstance(); } @Override
// Path: src/main/java/org/linkeddatafragments/datasource/DataSourceBase.java // public abstract class DataSourceBase implements IDataSource { // // /** // * Get the datasource title // */ // protected String title; // // /** // * Get the datasource description // */ // protected String description; // // /** // * Create a base for a {@link IDataSource} // * // * @param title the datasource title // * @param description the datasource description // */ // public DataSourceBase(String title, String description) { // this.title = title; // this.description = description; // } // // /** // * Get the datasource description // * // * @return // */ // @Override // public String getDescription() { // return this.description; // }; // // /** // * Get the datasource title // * // * @return // */ // @Override // public String getTitle() { // return this.title; // }; // // @Override // public void close() {} // } // // Path: src/main/java/org/linkeddatafragments/datasource/IFragmentRequestProcessor.java // public interface IFragmentRequestProcessor extends Closeable // { // // /** // * // * @param request // * @return // * @throws IllegalArgumentException // */ // ILinkedDataFragment createRequestedFragment( // final ILinkedDataFragmentRequest request ) // throws IllegalArgumentException; // } // // Path: src/main/java/org/linkeddatafragments/fragments/IFragmentRequestParser.java // public interface IFragmentRequestParser // { // /** // * Parses the given HTTP request into a specific // * {@link ILinkedDataFragmentRequest}. // * // * @param httpRequest // * @param config // * @return // * @throws IllegalArgumentException // * If the given HTTP request cannot be interpreted (perhaps due to // * missing request parameters). // */ // ILinkedDataFragmentRequest parseIntoFragmentRequest( // final HttpServletRequest httpRequest, // final ConfigReader config ) // throws IllegalArgumentException; // } // Path: src/main/java/org/linkeddatafragments/datasource/sparql/SparqlDataSource.java import java.io.File; import java.net.URI; import org.linkeddatafragments.datasource.DataSourceBase; import org.linkeddatafragments.datasource.IFragmentRequestProcessor; import org.linkeddatafragments.fragments.IFragmentRequestParser; import org.linkeddatafragments.fragments.tpf.TPFRequestParserForJenaBackends; package org.linkeddatafragments.datasource.sparql; /** * Experimental SPARQL-endpoint-backed data source of Basic Linked Data Fragments. * * @author <a href="mailto:[email protected]">Bart Hanssens</a> * @author <a href="http://olafhartig.de">Olaf Hartig</a> * @author <a href="https://awoods.io">Andrew Woods</a> */ public class SparqlDataSource extends DataSourceBase { /** * The request processor * */ protected final SparqlBasedRequestProcessorForTPFs requestProcessor; @Override public IFragmentRequestParser getRequestParser() { return TPFRequestParserForJenaBackends.getInstance(); } @Override
public IFragmentRequestProcessor getRequestProcessor()
luoyuan800/IPMIUtil4J
src/test/util/ReadFileAsInput.java
// Path: src/main/java/command/OutputResult.java // public class OutputResult extends LinkedList<String>{ // /** // * // */ // private static final long serialVersionUID = 10L; // // @Override // public String toString(){ // StringBuilder sb= new StringBuilder(); // for(String s : this){ // sb.append(s).append("\n"); // } // return sb.toString(); // } // // public boolean isNotEmpty() { // return !isEmpty(); // } // }
import command.OutputResult; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader;
package util;/* * util.ReadFileAsInput.java * Date: 7/15/2015 * Time: 12:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ public class ReadFileAsInput {
// Path: src/main/java/command/OutputResult.java // public class OutputResult extends LinkedList<String>{ // /** // * // */ // private static final long serialVersionUID = 10L; // // @Override // public String toString(){ // StringBuilder sb= new StringBuilder(); // for(String s : this){ // sb.append(s).append("\n"); // } // return sb.toString(); // } // // public boolean isNotEmpty() { // return !isEmpty(); // } // } // Path: src/test/util/ReadFileAsInput.java import command.OutputResult; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; package util;/* * util.ReadFileAsInput.java * Date: 7/15/2015 * Time: 12:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ public class ReadFileAsInput {
public static OutputResult readFile(String path) throws IOException {
luoyuan800/IPMIUtil4J
src/test/request/testFru.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException {
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/testFru.java import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException {
Command command = mock(Command.class);
luoyuan800/IPMIUtil4J
src/test/request/testFru.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil fru"))).thenReturn(readFile("../data/fru-output"));
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/testFru.java import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil fru"))).thenReturn(readFile("../data/fru-output"));
LocalIPMIClient client = new LocalIPMIClient(Platform.Win64);
luoyuan800/IPMIUtil4J
src/test/request/testFru.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil fru"))).thenReturn(readFile("../data/fru-output"));
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/testFru.java import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil fru"))).thenReturn(readFile("../data/fru-output"));
LocalIPMIClient client = new LocalIPMIClient(Platform.Win64);
luoyuan800/IPMIUtil4J
src/test/request/testFru.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil fru"))).thenReturn(readFile("../data/fru-output")); LocalIPMIClient client = new LocalIPMIClient(Platform.Win64); FruRequest request = new FruRequest(); request.setCommand(command);
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/testFru.java import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil fru"))).thenReturn(readFile("../data/fru-output")); LocalIPMIClient client = new LocalIPMIClient(Platform.Win64); FruRequest request = new FruRequest(); request.setCommand(command);
FruRespond respond = request.sendTo(client);
luoyuan800/IPMIUtil4J
src/test/request/testFru.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil fru"))).thenReturn(readFile("../data/fru-output")); LocalIPMIClient client = new LocalIPMIClient(Platform.Win64); FruRequest request = new FruRequest(); request.setCommand(command); FruRespond respond = request.sendTo(client); Assert.assertTrue(respond.hasRespond());
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/model/ComponentFru.java // public class ComponentFru extends Fru { // // public ComponentFru(String name) { // super(name); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/FruRespond.java // public class FruRespond implements IPMIRespond{ // private List<Fru> frus; // private boolean isSuccess; // public synchronized void addFru(Fru fru){ // if(frus == null){ // frus = new ArrayList<Fru>(); // } // frus.add(fru); // } // @Override // public boolean hasRespond() { // return isSuccess; // } // // public void setSuccess(boolean isSuccess) { // this.isSuccess = isSuccess; // } // // public <T> List<T> getFrus(Class clazz){ // if(frus == null){ // return Collections.emptyList(); // } // List<T> rs = new ArrayList<T>(frus.size()); // for(Fru fru : frus){ // if(fru.getClass().equals(clazz)){ // rs.add((T)fru); // } // } // return rs; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/testFru.java import client.LocalIPMIClient; import command.Command; import model.ComponentFru; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.FruRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * testFru.java * Date: 7/14/2015 * Time: 5:24 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestFru { @Test public void testFruRequest() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil fru"))).thenReturn(readFile("../data/fru-output")); LocalIPMIClient client = new LocalIPMIClient(Platform.Win64); FruRequest request = new FruRequest(); request.setCommand(command); FruRespond respond = request.sendTo(client); Assert.assertTrue(respond.hasRespond());
Assert.assertSame(respond.getFrus(ComponentFru.class).size(), 3);
luoyuan800/IPMIUtil4J
src/test/request/TestSensor.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/SensorRespond.java // public class SensorRespond implements IPMIRespond { // private List<Sensor> sensors; // private boolean success; // @Override // public boolean hasRespond() { // return success; // } // // public synchronized void addSensor(Sensor sensor){ // if(sensors==null){ // sensors = new ArrayList<Sensor>(); // } // sensors.add(sensor); // } // // public void setSuccess(boolean success) { // this.success = success; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.SensorRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * TestSensor.java * Date: 7/15/2015 * Time: 12:22 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestSensor { @Test public void testSensor() throws IOException {
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/SensorRespond.java // public class SensorRespond implements IPMIRespond { // private List<Sensor> sensors; // private boolean success; // @Override // public boolean hasRespond() { // return success; // } // // public synchronized void addSensor(Sensor sensor){ // if(sensors==null){ // sensors = new ArrayList<Sensor>(); // } // sensors.add(sensor); // } // // public void setSuccess(boolean success) { // this.success = success; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/TestSensor.java import client.LocalIPMIClient; import command.Command; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.SensorRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * TestSensor.java * Date: 7/15/2015 * Time: 12:22 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestSensor { @Test public void testSensor() throws IOException {
Command command = mock(Command.class);
luoyuan800/IPMIUtil4J
src/test/request/TestSensor.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/SensorRespond.java // public class SensorRespond implements IPMIRespond { // private List<Sensor> sensors; // private boolean success; // @Override // public boolean hasRespond() { // return success; // } // // public synchronized void addSensor(Sensor sensor){ // if(sensors==null){ // sensors = new ArrayList<Sensor>(); // } // sensors.add(sensor); // } // // public void setSuccess(boolean success) { // this.success = success; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.SensorRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * TestSensor.java * Date: 7/15/2015 * Time: 12:22 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestSensor { @Test public void testSensor() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil sensor"))).thenReturn(readFile("../data/sensor-output"));
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/SensorRespond.java // public class SensorRespond implements IPMIRespond { // private List<Sensor> sensors; // private boolean success; // @Override // public boolean hasRespond() { // return success; // } // // public synchronized void addSensor(Sensor sensor){ // if(sensors==null){ // sensors = new ArrayList<Sensor>(); // } // sensors.add(sensor); // } // // public void setSuccess(boolean success) { // this.success = success; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/TestSensor.java import client.LocalIPMIClient; import command.Command; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.SensorRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * TestSensor.java * Date: 7/15/2015 * Time: 12:22 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestSensor { @Test public void testSensor() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil sensor"))).thenReturn(readFile("../data/sensor-output"));
LocalIPMIClient client = new LocalIPMIClient(Platform.Win64);
luoyuan800/IPMIUtil4J
src/test/request/TestSensor.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/SensorRespond.java // public class SensorRespond implements IPMIRespond { // private List<Sensor> sensors; // private boolean success; // @Override // public boolean hasRespond() { // return success; // } // // public synchronized void addSensor(Sensor sensor){ // if(sensors==null){ // sensors = new ArrayList<Sensor>(); // } // sensors.add(sensor); // } // // public void setSuccess(boolean success) { // this.success = success; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.SensorRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * TestSensor.java * Date: 7/15/2015 * Time: 12:22 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestSensor { @Test public void testSensor() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil sensor"))).thenReturn(readFile("../data/sensor-output"));
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/SensorRespond.java // public class SensorRespond implements IPMIRespond { // private List<Sensor> sensors; // private boolean success; // @Override // public boolean hasRespond() { // return success; // } // // public synchronized void addSensor(Sensor sensor){ // if(sensors==null){ // sensors = new ArrayList<Sensor>(); // } // sensors.add(sensor); // } // // public void setSuccess(boolean success) { // this.success = success; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/TestSensor.java import client.LocalIPMIClient; import command.Command; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.SensorRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * TestSensor.java * Date: 7/15/2015 * Time: 12:22 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestSensor { @Test public void testSensor() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil sensor"))).thenReturn(readFile("../data/sensor-output"));
LocalIPMIClient client = new LocalIPMIClient(Platform.Win64);
luoyuan800/IPMIUtil4J
src/test/request/TestSensor.java
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/SensorRespond.java // public class SensorRespond implements IPMIRespond { // private List<Sensor> sensors; // private boolean success; // @Override // public boolean hasRespond() { // return success; // } // // public synchronized void addSensor(Sensor sensor){ // if(sensors==null){ // sensors = new ArrayList<Sensor>(); // } // sensors.add(sensor); // } // // public void setSuccess(boolean success) { // this.success = success; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // }
import client.LocalIPMIClient; import command.Command; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.SensorRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*;
/* * TestSensor.java * Date: 7/15/2015 * Time: 12:22 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestSensor { @Test public void testSensor() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil sensor"))).thenReturn(readFile("../data/sensor-output")); LocalIPMIClient client = new LocalIPMIClient(Platform.Win64); SensorRequest request = new SensorRequest(); request.setCommand(command);
// Path: src/main/java/client/LocalIPMIClient.java // public class LocalIPMIClient extends IPMIClient { // // public LocalIPMIClient(Platform platform) { // super("127.0.0.1","", "", null, platform); // } // // } // // Path: src/main/java/command/Command.java // public class Command { // public OutputResult exeCmd(String commandStr) { // BufferedReader br = null; // OutputResult out = new OutputResult(); // try { // Process p = Runtime.getRuntime().exec(commandStr); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // public OutputResult exeCmdOnLinux(String cmd){ // String[] command = {"/bin/sh", "-c", cmd}; // OutputResult out = new OutputResult(); // BufferedReader br = null; // try { // Process p = Runtime.getRuntime().exec(command); // br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line; // while ((line = br.readLine()) != null) { // out.add(line.trim()); // } // } catch (Exception e) { // e.printStackTrace(); // } finally{ // if (br != null) // { // try { // br.close(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // return out; // } // // public static void main(String[] args) throws IOException { // Runtime runtime = Runtime.getRuntime(); // Process p = runtime.exec("ipmiutil-2.9.6-win64/ipmiutil fru -N 10.4.33.146 -U Administrator -P rdis2fun! -J 3"); // BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream())); // String line = null; // StringBuilder sb = new StringBuilder(); // while ((line = br.readLine()) != null) { // sb.append(line + "\n"); // } // System.out.println(sb.toString()); // } // } // // Path: src/main/java/param/Platform.java // public enum Platform { // TIGPT1U(""), // NSC2U(""), // Ubuntu("/bin/sh -c ipmiutil"), // Linux("/bin/sh -c ipmiutil"), // Win32("cmd.exe /C ipmiutil-win32/ipmiutil"), // Win64("cmd.exe /C ipmiutil-win64/ipmiutil"); // // private String IPMI_META_COMMAND; // private Platform(String command){ // IPMI_META_COMMAND = command; // } // // public String getIPMI_META_COMMAND() { // return IPMI_META_COMMAND; // } // } // // Path: src/main/java/respond/SensorRespond.java // public class SensorRespond implements IPMIRespond { // private List<Sensor> sensors; // private boolean success; // @Override // public boolean hasRespond() { // return success; // } // // public synchronized void addSensor(Sensor sensor){ // if(sensors==null){ // sensors = new ArrayList<Sensor>(); // } // sensors.add(sensor); // } // // public void setSuccess(boolean success) { // this.success = success; // } // } // // Path: src/test/util/ReadFileAsInput.java // public class ReadFileAsInput { // public static OutputResult readFile(String path) throws IOException { // OutputResult or = new OutputResult(); // BufferedReader br = new BufferedReader((new InputStreamReader(ReadFileAsInput.class.getResourceAsStream(path)))); // String line; // while ((line = br.readLine()) != null) { // or.add(line); // } // return or; // } // } // Path: src/test/request/TestSensor.java import client.LocalIPMIClient; import command.Command; import org.junit.Assert; import org.junit.Test; import param.Platform; import respond.SensorRespond; import java.io.IOException; import static org.mockito.Matchers.contains; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import static util.ReadFileAsInput.*; /* * TestSensor.java * Date: 7/15/2015 * Time: 12:22 PM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package request; public class TestSensor { @Test public void testSensor() throws IOException { Command command = mock(Command.class); when(command.exeCmd(contains("ipmiutil sensor"))).thenReturn(readFile("../data/sensor-output")); LocalIPMIClient client = new LocalIPMIClient(Platform.Win64); SensorRequest request = new SensorRequest(); request.setCommand(command);
SensorRespond respond = request.sendTo(client);
luoyuan800/IPMIUtil4J
src/main/java/model/Sensor.java
// Path: src/main/java/param/SDRType.java // public enum SDRType { // Full, Comp, FRU, IPMB, OEM; // }
import param.SDRType;
/* * Sensor.java * Date: 7/15/2015 * Time: 10:53 AM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package model; public class Sensor { private String description; private Double reading; private String unit;
// Path: src/main/java/param/SDRType.java // public enum SDRType { // Full, Comp, FRU, IPMB, OEM; // } // Path: src/main/java/model/Sensor.java import param.SDRType; /* * Sensor.java * Date: 7/15/2015 * Time: 10:53 AM * * Copyright 2015 luoyuan. * ALL RIGHTS RESERVED. */ package model; public class Sensor { private String description; private Double reading; private String unit;
private SDRType type;
junkdog/ecs-matrix
matrix/src/main/java/net/onedaybeard/ecs/util/MatrixStringUtil.java
// Path: matrix/src/main/java/net/onedaybeard/ecs/model/RowTypeMapping.java // public final class RowTypeMapping { // // public static enum EcsRowType { // PACKAGE_NAME(null), // SYSTEM("gear"), // MANAGER("gears"), // FACTORY("user-plus"), // POJO("coffee"); // not used, yet // // public final String symbol; // // EcsRowType(String symbol) { // this.symbol = symbol; // } // // } // // public final EcsRowType rowType; // public String symbol; // // public final Type ecsType; // public final ComponentReference[] componentIndices; // public final String name; // public final String[] refSystems; // public final String[] refManagers; // public final String[] refFactories; // // // FIXMEmeh, dirty... fix sometime. // public ComponentReference[] managerIndices; // public ComponentReference[] systemIndices; // public ComponentReference[] factoryIndices; // // public final boolean isPackage; // // public RowTypeMapping(String packageName) { // name = packageName; // ecsType = null; // refSystems = null; // refManagers = null; // refFactories = null; // componentIndices = null; // symbol = null; // // rowType = EcsRowType.PACKAGE_NAME; // isPackage = true; // } // // private RowTypeMapping(EcsTypeData typeData, ConfigurationResolver resolver, ComponentReference[] componentIndices) { // this.ecsType = typeData.current; // this.componentIndices = componentIndices; // // name = MatrixStringUtil.shortName(this.ecsType); // // refManagers = createNameIndices(typeData.managers); // refSystems = createNameIndices(typeData.systems); // refFactories = createNameIndices(typeData.factories); // // if (resolver.systems.contains(this.ecsType)) { // rowType = EcsRowType.SYSTEM; // } else if (resolver.managers.contains(this.ecsType)) { // rowType = EcsRowType.MANAGER; // } else if (resolver.factories.contains(this.ecsType)) { // rowType = EcsRowType.FACTORY; // } else { // throw new RuntimeException(); // } // symbol = rowType.symbol; // isPackage = false; // } // // private static String[] createNameIndices(Set<Type> types) { // String[] typeNames = new String[types.size()]; // int index = 0; // for (Type type : types) // typeNames[index++] = MatrixStringUtil.shortName(type); // // return typeNames; // } // // private static void filterComponentMappings(EcsTypeData typeData) { // typeData.optional.removeAll(typeData.requires); // typeData.optional.removeAll(typeData.requiresOne); // typeData.optional.removeAll(typeData.exclude); // } // // public static RowTypeMapping from(EcsTypeData typeData, ConfigurationResolver resolver, // Map<Type, Integer> componentIndices) { // // filterComponentMappings(typeData); // // ComponentReference[] components = new ComponentReference[componentIndices.size()]; // Arrays.fill(components, ComponentReference.NOT_REFERENCED); // // typeData.cleanSelfTypeReferences(); // mapComponents(typeData.requires, ComponentReference.REQUIRED, componentIndices, components); // mapComponents(typeData.requiresOne, ComponentReference.ANY, componentIndices, components); // mapComponents(typeData.optional, ComponentReference.OPTIONAL, componentIndices, components); // mapComponents(typeData.exclude, ComponentReference.EXCLUDED, componentIndices, components); // // return new RowTypeMapping(typeData, resolver, components); // } // // public void setMatrixData(MatrixData mapping) { // managerIndices = typeIndices(mapping.managerIndexMap, refManagers); // systemIndices = typeIndices(mapping.systemIndexMap, refSystems); // factoryIndices = typeIndices(mapping.factoryIndexMap, refFactories); // } // // private static ComponentReference[] typeIndices(Map<String, Integer> indexMapping, String[] referenced) { // ComponentReference[] indices = new ComponentReference[indexMapping.size()]; // Arrays.fill(indices, ComponentReference.NOT_REFERENCED); // for (String ref : referenced) { // indices[indexMapping.get(ref)] = ComponentReference.OPTIONAL; // } // // return indices; // } // // public String getName() { // return MatrixStringUtil.shortName(ecsType); // } // // private static void mapComponents(Collection<Type> references, ComponentReference referenceType, Map<Type,Integer> componentIndices, // ComponentReference[] components) { // for (Type component : references) // components[componentIndices.get(component)] = referenceType; // } // // @Override // public String toString() { // StringBuilder sb = new StringBuilder(); // sb.append("[ "); // sb.append('"').append(getName()).append('"'); // for (ComponentReference ref : componentIndices) { // sb.append(", \"").append(ref.symbol).append('"'); // } // sb.append(" ]"); // // return sb.toString(); // } // }
import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Map.Entry; import org.objectweb.asm.Type; import net.onedaybeard.ecs.model.RowTypeMapping;
package net.onedaybeard.ecs.util; public final class MatrixStringUtil { private MatrixStringUtil() {}
// Path: matrix/src/main/java/net/onedaybeard/ecs/model/RowTypeMapping.java // public final class RowTypeMapping { // // public static enum EcsRowType { // PACKAGE_NAME(null), // SYSTEM("gear"), // MANAGER("gears"), // FACTORY("user-plus"), // POJO("coffee"); // not used, yet // // public final String symbol; // // EcsRowType(String symbol) { // this.symbol = symbol; // } // // } // // public final EcsRowType rowType; // public String symbol; // // public final Type ecsType; // public final ComponentReference[] componentIndices; // public final String name; // public final String[] refSystems; // public final String[] refManagers; // public final String[] refFactories; // // // FIXMEmeh, dirty... fix sometime. // public ComponentReference[] managerIndices; // public ComponentReference[] systemIndices; // public ComponentReference[] factoryIndices; // // public final boolean isPackage; // // public RowTypeMapping(String packageName) { // name = packageName; // ecsType = null; // refSystems = null; // refManagers = null; // refFactories = null; // componentIndices = null; // symbol = null; // // rowType = EcsRowType.PACKAGE_NAME; // isPackage = true; // } // // private RowTypeMapping(EcsTypeData typeData, ConfigurationResolver resolver, ComponentReference[] componentIndices) { // this.ecsType = typeData.current; // this.componentIndices = componentIndices; // // name = MatrixStringUtil.shortName(this.ecsType); // // refManagers = createNameIndices(typeData.managers); // refSystems = createNameIndices(typeData.systems); // refFactories = createNameIndices(typeData.factories); // // if (resolver.systems.contains(this.ecsType)) { // rowType = EcsRowType.SYSTEM; // } else if (resolver.managers.contains(this.ecsType)) { // rowType = EcsRowType.MANAGER; // } else if (resolver.factories.contains(this.ecsType)) { // rowType = EcsRowType.FACTORY; // } else { // throw new RuntimeException(); // } // symbol = rowType.symbol; // isPackage = false; // } // // private static String[] createNameIndices(Set<Type> types) { // String[] typeNames = new String[types.size()]; // int index = 0; // for (Type type : types) // typeNames[index++] = MatrixStringUtil.shortName(type); // // return typeNames; // } // // private static void filterComponentMappings(EcsTypeData typeData) { // typeData.optional.removeAll(typeData.requires); // typeData.optional.removeAll(typeData.requiresOne); // typeData.optional.removeAll(typeData.exclude); // } // // public static RowTypeMapping from(EcsTypeData typeData, ConfigurationResolver resolver, // Map<Type, Integer> componentIndices) { // // filterComponentMappings(typeData); // // ComponentReference[] components = new ComponentReference[componentIndices.size()]; // Arrays.fill(components, ComponentReference.NOT_REFERENCED); // // typeData.cleanSelfTypeReferences(); // mapComponents(typeData.requires, ComponentReference.REQUIRED, componentIndices, components); // mapComponents(typeData.requiresOne, ComponentReference.ANY, componentIndices, components); // mapComponents(typeData.optional, ComponentReference.OPTIONAL, componentIndices, components); // mapComponents(typeData.exclude, ComponentReference.EXCLUDED, componentIndices, components); // // return new RowTypeMapping(typeData, resolver, components); // } // // public void setMatrixData(MatrixData mapping) { // managerIndices = typeIndices(mapping.managerIndexMap, refManagers); // systemIndices = typeIndices(mapping.systemIndexMap, refSystems); // factoryIndices = typeIndices(mapping.factoryIndexMap, refFactories); // } // // private static ComponentReference[] typeIndices(Map<String, Integer> indexMapping, String[] referenced) { // ComponentReference[] indices = new ComponentReference[indexMapping.size()]; // Arrays.fill(indices, ComponentReference.NOT_REFERENCED); // for (String ref : referenced) { // indices[indexMapping.get(ref)] = ComponentReference.OPTIONAL; // } // // return indices; // } // // public String getName() { // return MatrixStringUtil.shortName(ecsType); // } // // private static void mapComponents(Collection<Type> references, ComponentReference referenceType, Map<Type,Integer> componentIndices, // ComponentReference[] components) { // for (Type component : references) // components[componentIndices.get(component)] = referenceType; // } // // @Override // public String toString() { // StringBuilder sb = new StringBuilder(); // sb.append("[ "); // sb.append('"').append(getName()).append('"'); // for (ComponentReference ref : componentIndices) { // sb.append(", \"").append(ref.symbol).append('"'); // } // sb.append(" ]"); // // return sb.toString(); // } // } // Path: matrix/src/main/java/net/onedaybeard/ecs/util/MatrixStringUtil.java import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.Map.Entry; import org.objectweb.asm.Type; import net.onedaybeard.ecs.model.RowTypeMapping; package net.onedaybeard.ecs.util; public final class MatrixStringUtil { private MatrixStringUtil() {}
public static String findLongestClassName(Map<String, List<RowTypeMapping>> mappings) {
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // }
import com.artemis.Manager; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.system.SomeSystem;
package net.onedaybeard.ecs.manager; public class SomeManager extends Manager { private FactoryA factory;
// Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java import com.artemis.Manager; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.system.SomeSystem; package net.onedaybeard.ecs.manager; public class SomeManager extends Manager { private FactoryA factory;
private SomeSystem someSystem;
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // }
import com.artemis.Aspect; import com.artemis.Entity; import com.artemis.annotations.Wire; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import com.artemis.systems.EntityProcessingSystem;
package net.onedaybeard.ecs.system; @Wire public class AnotherSystem extends EntityProcessingSystem { private ExtSomeSystem someSystem; public AnotherSystem() {
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java import com.artemis.Aspect; import com.artemis.Entity; import com.artemis.annotations.Wire; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import com.artemis.systems.EntityProcessingSystem; package net.onedaybeard.ecs.system; @Wire public class AnotherSystem extends EntityProcessingSystem { private ExtSomeSystem someSystem; public AnotherSystem() {
super(Aspect.getAspectForAll(Position.class).one( Velocity.class));
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // }
import com.artemis.Aspect; import com.artemis.Entity; import com.artemis.annotations.Wire; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import com.artemis.systems.EntityProcessingSystem;
package net.onedaybeard.ecs.system; @Wire public class AnotherSystem extends EntityProcessingSystem { private ExtSomeSystem someSystem; public AnotherSystem() {
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java import com.artemis.Aspect; import com.artemis.Entity; import com.artemis.annotations.Wire; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import com.artemis.systems.EntityProcessingSystem; package net.onedaybeard.ecs.system; @Wire public class AnotherSystem extends EntityProcessingSystem { private ExtSomeSystem someSystem; public AnotherSystem() {
super(Aspect.getAspectForAll(Position.class).one( Velocity.class));
junkdog/ecs-matrix
matrix-cli/src/main/java/com/artemis/cli/MatrixCommand.java
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FileOutputConverter.java // public class FileOutputConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File file = new File(value); // if (file.isDirectory()) // file = new File(file, "matrix.html"); // // return file; // } // // } // // Path: matrix-cli/src/main/java/com/artemis/cli/converter/FolderConverter.java // public class FolderConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File folder = new File(value); // if (!folder.isDirectory()) // throw new RuntimeException(value + " is not a folder."); // return folder; // } // // } // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java // public class ComponentDependencyMatrix implements Opcodes { // private final List<URI> files; // private final File output; // private final String projectName; // // public ComponentDependencyMatrix(String projectName, List<URI> files, File output) { // this.projectName = projectName; // this.files = files; // this.output = output; // } // // public String detectAndProcess() { // EcsTypeInspector typeInspector; // // // TODO: get classpath and/or deps // for (String ecs : asList("artemis", "ashley")) { // typeInspector = new EcsTypeInspector(files, "/" + ecs); // if (typeInspector.foundEcsClasses()) { // process(typeInspector); // return "Found ECS framework: " + ecs; // } // } // // return "Failed finding any ECS related classes."; // } // // public void process() { // process(""); // } // // public void process(String resourcePrefix) { // process(new EcsTypeInspector(files, resourcePrefix)); // } // // private void process(EcsTypeInspector typeInspector) { // write(typeInspector.getTypeMap(), typeInspector.getMatrixData()); // } // // private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) { // Theme theme = new Theme(); // Chunk chunk = theme.makeChunk("matrix"); // // List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>(); // for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) { // rows.add(new RowTypeMapping(entry.getKey())); // rows.addAll(entry.getValue()); // } // // chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______"); // // chunk.set("rows", rows); // // chunk.set("headersComponents", matrix.componentColumns); // chunk.set("componentCount", matrix.componentColumns.size()); // // chunk.set("headersManagers", matrix.managerColumns); // chunk.set("managerCount", matrix.managerColumns.size()); // // chunk.set("headersSystems", matrix.systemColumns); // chunk.set("systemCount", matrix.systemColumns.size()); // // chunk.set("factoryCount", matrix.factoryColumns.size()); // chunk.set("headersFactories", matrix.factoryColumns); // // chunk.set("project", projectName); // // BufferedWriter out = null; // try { // out = new BufferedWriter(new FileWriter(output)); // chunk.render(out); // } catch (IOException e) { // e.printStackTrace(); // } finally { // if (out != null) try { // out.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // }
import java.io.File; import java.util.Arrays; import com.artemis.cli.converter.FileOutputConverter; import com.artemis.cli.converter.FolderConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import net.onedaybeard.ecs.model.ComponentDependencyMatrix;
package com.artemis.cli; @Parameters( commandDescription="Generate the Component Dependency Matrix from existing classes") public class MatrixCommand { static final String COMMAND = "matrix"; @Parameter( names = {"-h", "--help"}, description= "Displays this help message.", help = true) boolean help; @Parameter( names = {"-l", "--label"}, description = "Project name, used as page title", required = false) private String projectName = "Unnamed project"; @Parameter( names = {"-c", "--class-folder"}, description = "Root class folder",
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FileOutputConverter.java // public class FileOutputConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File file = new File(value); // if (file.isDirectory()) // file = new File(file, "matrix.html"); // // return file; // } // // } // // Path: matrix-cli/src/main/java/com/artemis/cli/converter/FolderConverter.java // public class FolderConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File folder = new File(value); // if (!folder.isDirectory()) // throw new RuntimeException(value + " is not a folder."); // return folder; // } // // } // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java // public class ComponentDependencyMatrix implements Opcodes { // private final List<URI> files; // private final File output; // private final String projectName; // // public ComponentDependencyMatrix(String projectName, List<URI> files, File output) { // this.projectName = projectName; // this.files = files; // this.output = output; // } // // public String detectAndProcess() { // EcsTypeInspector typeInspector; // // // TODO: get classpath and/or deps // for (String ecs : asList("artemis", "ashley")) { // typeInspector = new EcsTypeInspector(files, "/" + ecs); // if (typeInspector.foundEcsClasses()) { // process(typeInspector); // return "Found ECS framework: " + ecs; // } // } // // return "Failed finding any ECS related classes."; // } // // public void process() { // process(""); // } // // public void process(String resourcePrefix) { // process(new EcsTypeInspector(files, resourcePrefix)); // } // // private void process(EcsTypeInspector typeInspector) { // write(typeInspector.getTypeMap(), typeInspector.getMatrixData()); // } // // private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) { // Theme theme = new Theme(); // Chunk chunk = theme.makeChunk("matrix"); // // List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>(); // for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) { // rows.add(new RowTypeMapping(entry.getKey())); // rows.addAll(entry.getValue()); // } // // chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______"); // // chunk.set("rows", rows); // // chunk.set("headersComponents", matrix.componentColumns); // chunk.set("componentCount", matrix.componentColumns.size()); // // chunk.set("headersManagers", matrix.managerColumns); // chunk.set("managerCount", matrix.managerColumns.size()); // // chunk.set("headersSystems", matrix.systemColumns); // chunk.set("systemCount", matrix.systemColumns.size()); // // chunk.set("factoryCount", matrix.factoryColumns.size()); // chunk.set("headersFactories", matrix.factoryColumns); // // chunk.set("project", projectName); // // BufferedWriter out = null; // try { // out = new BufferedWriter(new FileWriter(output)); // chunk.render(out); // } catch (IOException e) { // e.printStackTrace(); // } finally { // if (out != null) try { // out.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // } // Path: matrix-cli/src/main/java/com/artemis/cli/MatrixCommand.java import java.io.File; import java.util.Arrays; import com.artemis.cli.converter.FileOutputConverter; import com.artemis.cli.converter.FolderConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import net.onedaybeard.ecs.model.ComponentDependencyMatrix; package com.artemis.cli; @Parameters( commandDescription="Generate the Component Dependency Matrix from existing classes") public class MatrixCommand { static final String COMMAND = "matrix"; @Parameter( names = {"-h", "--help"}, description= "Displays this help message.", help = true) boolean help; @Parameter( names = {"-l", "--label"}, description = "Project name, used as page title", required = false) private String projectName = "Unnamed project"; @Parameter( names = {"-c", "--class-folder"}, description = "Root class folder",
converter = FolderConverter.class,
junkdog/ecs-matrix
matrix-cli/src/main/java/com/artemis/cli/MatrixCommand.java
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FileOutputConverter.java // public class FileOutputConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File file = new File(value); // if (file.isDirectory()) // file = new File(file, "matrix.html"); // // return file; // } // // } // // Path: matrix-cli/src/main/java/com/artemis/cli/converter/FolderConverter.java // public class FolderConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File folder = new File(value); // if (!folder.isDirectory()) // throw new RuntimeException(value + " is not a folder."); // return folder; // } // // } // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java // public class ComponentDependencyMatrix implements Opcodes { // private final List<URI> files; // private final File output; // private final String projectName; // // public ComponentDependencyMatrix(String projectName, List<URI> files, File output) { // this.projectName = projectName; // this.files = files; // this.output = output; // } // // public String detectAndProcess() { // EcsTypeInspector typeInspector; // // // TODO: get classpath and/or deps // for (String ecs : asList("artemis", "ashley")) { // typeInspector = new EcsTypeInspector(files, "/" + ecs); // if (typeInspector.foundEcsClasses()) { // process(typeInspector); // return "Found ECS framework: " + ecs; // } // } // // return "Failed finding any ECS related classes."; // } // // public void process() { // process(""); // } // // public void process(String resourcePrefix) { // process(new EcsTypeInspector(files, resourcePrefix)); // } // // private void process(EcsTypeInspector typeInspector) { // write(typeInspector.getTypeMap(), typeInspector.getMatrixData()); // } // // private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) { // Theme theme = new Theme(); // Chunk chunk = theme.makeChunk("matrix"); // // List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>(); // for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) { // rows.add(new RowTypeMapping(entry.getKey())); // rows.addAll(entry.getValue()); // } // // chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______"); // // chunk.set("rows", rows); // // chunk.set("headersComponents", matrix.componentColumns); // chunk.set("componentCount", matrix.componentColumns.size()); // // chunk.set("headersManagers", matrix.managerColumns); // chunk.set("managerCount", matrix.managerColumns.size()); // // chunk.set("headersSystems", matrix.systemColumns); // chunk.set("systemCount", matrix.systemColumns.size()); // // chunk.set("factoryCount", matrix.factoryColumns.size()); // chunk.set("headersFactories", matrix.factoryColumns); // // chunk.set("project", projectName); // // BufferedWriter out = null; // try { // out = new BufferedWriter(new FileWriter(output)); // chunk.render(out); // } catch (IOException e) { // e.printStackTrace(); // } finally { // if (out != null) try { // out.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // }
import java.io.File; import java.util.Arrays; import com.artemis.cli.converter.FileOutputConverter; import com.artemis.cli.converter.FolderConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import net.onedaybeard.ecs.model.ComponentDependencyMatrix;
package com.artemis.cli; @Parameters( commandDescription="Generate the Component Dependency Matrix from existing classes") public class MatrixCommand { static final String COMMAND = "matrix"; @Parameter( names = {"-h", "--help"}, description= "Displays this help message.", help = true) boolean help; @Parameter( names = {"-l", "--label"}, description = "Project name, used as page title", required = false) private String projectName = "Unnamed project"; @Parameter( names = {"-c", "--class-folder"}, description = "Root class folder", converter = FolderConverter.class, required = true) private File classRoot; @Parameter( names = {"-o", "--output"}, description = "Save to file, destination may be given as a folder path",
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FileOutputConverter.java // public class FileOutputConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File file = new File(value); // if (file.isDirectory()) // file = new File(file, "matrix.html"); // // return file; // } // // } // // Path: matrix-cli/src/main/java/com/artemis/cli/converter/FolderConverter.java // public class FolderConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File folder = new File(value); // if (!folder.isDirectory()) // throw new RuntimeException(value + " is not a folder."); // return folder; // } // // } // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java // public class ComponentDependencyMatrix implements Opcodes { // private final List<URI> files; // private final File output; // private final String projectName; // // public ComponentDependencyMatrix(String projectName, List<URI> files, File output) { // this.projectName = projectName; // this.files = files; // this.output = output; // } // // public String detectAndProcess() { // EcsTypeInspector typeInspector; // // // TODO: get classpath and/or deps // for (String ecs : asList("artemis", "ashley")) { // typeInspector = new EcsTypeInspector(files, "/" + ecs); // if (typeInspector.foundEcsClasses()) { // process(typeInspector); // return "Found ECS framework: " + ecs; // } // } // // return "Failed finding any ECS related classes."; // } // // public void process() { // process(""); // } // // public void process(String resourcePrefix) { // process(new EcsTypeInspector(files, resourcePrefix)); // } // // private void process(EcsTypeInspector typeInspector) { // write(typeInspector.getTypeMap(), typeInspector.getMatrixData()); // } // // private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) { // Theme theme = new Theme(); // Chunk chunk = theme.makeChunk("matrix"); // // List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>(); // for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) { // rows.add(new RowTypeMapping(entry.getKey())); // rows.addAll(entry.getValue()); // } // // chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______"); // // chunk.set("rows", rows); // // chunk.set("headersComponents", matrix.componentColumns); // chunk.set("componentCount", matrix.componentColumns.size()); // // chunk.set("headersManagers", matrix.managerColumns); // chunk.set("managerCount", matrix.managerColumns.size()); // // chunk.set("headersSystems", matrix.systemColumns); // chunk.set("systemCount", matrix.systemColumns.size()); // // chunk.set("factoryCount", matrix.factoryColumns.size()); // chunk.set("headersFactories", matrix.factoryColumns); // // chunk.set("project", projectName); // // BufferedWriter out = null; // try { // out = new BufferedWriter(new FileWriter(output)); // chunk.render(out); // } catch (IOException e) { // e.printStackTrace(); // } finally { // if (out != null) try { // out.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // } // Path: matrix-cli/src/main/java/com/artemis/cli/MatrixCommand.java import java.io.File; import java.util.Arrays; import com.artemis.cli.converter.FileOutputConverter; import com.artemis.cli.converter.FolderConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import net.onedaybeard.ecs.model.ComponentDependencyMatrix; package com.artemis.cli; @Parameters( commandDescription="Generate the Component Dependency Matrix from existing classes") public class MatrixCommand { static final String COMMAND = "matrix"; @Parameter( names = {"-h", "--help"}, description= "Displays this help message.", help = true) boolean help; @Parameter( names = {"-l", "--label"}, description = "Project name, used as page title", required = false) private String projectName = "Unnamed project"; @Parameter( names = {"-c", "--class-folder"}, description = "Root class folder", converter = FolderConverter.class, required = true) private File classRoot; @Parameter( names = {"-o", "--output"}, description = "Save to file, destination may be given as a folder path",
converter = FileOutputConverter.class,
junkdog/ecs-matrix
matrix-cli/src/main/java/com/artemis/cli/MatrixCommand.java
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FileOutputConverter.java // public class FileOutputConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File file = new File(value); // if (file.isDirectory()) // file = new File(file, "matrix.html"); // // return file; // } // // } // // Path: matrix-cli/src/main/java/com/artemis/cli/converter/FolderConverter.java // public class FolderConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File folder = new File(value); // if (!folder.isDirectory()) // throw new RuntimeException(value + " is not a folder."); // return folder; // } // // } // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java // public class ComponentDependencyMatrix implements Opcodes { // private final List<URI> files; // private final File output; // private final String projectName; // // public ComponentDependencyMatrix(String projectName, List<URI> files, File output) { // this.projectName = projectName; // this.files = files; // this.output = output; // } // // public String detectAndProcess() { // EcsTypeInspector typeInspector; // // // TODO: get classpath and/or deps // for (String ecs : asList("artemis", "ashley")) { // typeInspector = new EcsTypeInspector(files, "/" + ecs); // if (typeInspector.foundEcsClasses()) { // process(typeInspector); // return "Found ECS framework: " + ecs; // } // } // // return "Failed finding any ECS related classes."; // } // // public void process() { // process(""); // } // // public void process(String resourcePrefix) { // process(new EcsTypeInspector(files, resourcePrefix)); // } // // private void process(EcsTypeInspector typeInspector) { // write(typeInspector.getTypeMap(), typeInspector.getMatrixData()); // } // // private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) { // Theme theme = new Theme(); // Chunk chunk = theme.makeChunk("matrix"); // // List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>(); // for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) { // rows.add(new RowTypeMapping(entry.getKey())); // rows.addAll(entry.getValue()); // } // // chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______"); // // chunk.set("rows", rows); // // chunk.set("headersComponents", matrix.componentColumns); // chunk.set("componentCount", matrix.componentColumns.size()); // // chunk.set("headersManagers", matrix.managerColumns); // chunk.set("managerCount", matrix.managerColumns.size()); // // chunk.set("headersSystems", matrix.systemColumns); // chunk.set("systemCount", matrix.systemColumns.size()); // // chunk.set("factoryCount", matrix.factoryColumns.size()); // chunk.set("headersFactories", matrix.factoryColumns); // // chunk.set("project", projectName); // // BufferedWriter out = null; // try { // out = new BufferedWriter(new FileWriter(output)); // chunk.render(out); // } catch (IOException e) { // e.printStackTrace(); // } finally { // if (out != null) try { // out.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // }
import java.io.File; import java.util.Arrays; import com.artemis.cli.converter.FileOutputConverter; import com.artemis.cli.converter.FolderConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import net.onedaybeard.ecs.model.ComponentDependencyMatrix;
package com.artemis.cli; @Parameters( commandDescription="Generate the Component Dependency Matrix from existing classes") public class MatrixCommand { static final String COMMAND = "matrix"; @Parameter( names = {"-h", "--help"}, description= "Displays this help message.", help = true) boolean help; @Parameter( names = {"-l", "--label"}, description = "Project name, used as page title", required = false) private String projectName = "Unnamed project"; @Parameter( names = {"-c", "--class-folder"}, description = "Root class folder", converter = FolderConverter.class, required = true) private File classRoot; @Parameter( names = {"-o", "--output"}, description = "Save to file, destination may be given as a folder path", converter = FileOutputConverter.class, required = false) private File output = new File("matrix.html"); void execute() {
// Path: matrix-cli/src/main/java/com/artemis/cli/converter/FileOutputConverter.java // public class FileOutputConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File file = new File(value); // if (file.isDirectory()) // file = new File(file, "matrix.html"); // // return file; // } // // } // // Path: matrix-cli/src/main/java/com/artemis/cli/converter/FolderConverter.java // public class FolderConverter implements IStringConverter<File> { // // @Override // public File convert(String value) { // File folder = new File(value); // if (!folder.isDirectory()) // throw new RuntimeException(value + " is not a folder."); // return folder; // } // // } // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java // public class ComponentDependencyMatrix implements Opcodes { // private final List<URI> files; // private final File output; // private final String projectName; // // public ComponentDependencyMatrix(String projectName, List<URI> files, File output) { // this.projectName = projectName; // this.files = files; // this.output = output; // } // // public String detectAndProcess() { // EcsTypeInspector typeInspector; // // // TODO: get classpath and/or deps // for (String ecs : asList("artemis", "ashley")) { // typeInspector = new EcsTypeInspector(files, "/" + ecs); // if (typeInspector.foundEcsClasses()) { // process(typeInspector); // return "Found ECS framework: " + ecs; // } // } // // return "Failed finding any ECS related classes."; // } // // public void process() { // process(""); // } // // public void process(String resourcePrefix) { // process(new EcsTypeInspector(files, resourcePrefix)); // } // // private void process(EcsTypeInspector typeInspector) { // write(typeInspector.getTypeMap(), typeInspector.getMatrixData()); // } // // private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) { // Theme theme = new Theme(); // Chunk chunk = theme.makeChunk("matrix"); // // List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>(); // for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) { // rows.add(new RowTypeMapping(entry.getKey())); // rows.addAll(entry.getValue()); // } // // chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______"); // // chunk.set("rows", rows); // // chunk.set("headersComponents", matrix.componentColumns); // chunk.set("componentCount", matrix.componentColumns.size()); // // chunk.set("headersManagers", matrix.managerColumns); // chunk.set("managerCount", matrix.managerColumns.size()); // // chunk.set("headersSystems", matrix.systemColumns); // chunk.set("systemCount", matrix.systemColumns.size()); // // chunk.set("factoryCount", matrix.factoryColumns.size()); // chunk.set("headersFactories", matrix.factoryColumns); // // chunk.set("project", projectName); // // BufferedWriter out = null; // try { // out = new BufferedWriter(new FileWriter(output)); // chunk.render(out); // } catch (IOException e) { // e.printStackTrace(); // } finally { // if (out != null) try { // out.close(); // } catch (IOException e) { // throw new RuntimeException(e); // } // } // } // } // Path: matrix-cli/src/main/java/com/artemis/cli/MatrixCommand.java import java.io.File; import java.util.Arrays; import com.artemis.cli.converter.FileOutputConverter; import com.artemis.cli.converter.FolderConverter; import com.beust.jcommander.Parameter; import com.beust.jcommander.Parameters; import net.onedaybeard.ecs.model.ComponentDependencyMatrix; package com.artemis.cli; @Parameters( commandDescription="Generate the Component Dependency Matrix from existing classes") public class MatrixCommand { static final String COMMAND = "matrix"; @Parameter( names = {"-h", "--help"}, description= "Displays this help message.", help = true) boolean help; @Parameter( names = {"-l", "--label"}, description = "Project name, used as page title", required = false) private String projectName = "Unnamed project"; @Parameter( names = {"-c", "--class-folder"}, description = "Root class folder", converter = FolderConverter.class, required = true) private File classRoot; @Parameter( names = {"-o", "--output"}, description = "Save to file, destination may be given as a folder path", converter = FileOutputConverter.class, required = false) private File output = new File("matrix.html"); void execute() {
ComponentDependencyMatrix cdm =
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // }
import com.artemis.Aspect; import com.artemis.Entity; import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.manager.SomeManager; import com.artemis.systems.EntityProcessingSystem;
package net.onedaybeard.ecs.system; public class SomeSystem extends EntityProcessingSystem { private SomeManager someManager; private AnotherSystem anotherSystem; public SomeSystem() {
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java import com.artemis.Aspect; import com.artemis.Entity; import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.manager.SomeManager; import com.artemis.systems.EntityProcessingSystem; package net.onedaybeard.ecs.system; public class SomeSystem extends EntityProcessingSystem { private SomeManager someManager; private AnotherSystem anotherSystem; public SomeSystem() {
super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class));
junkdog/ecs-matrix
matrix/src/main/java/net/onedaybeard/ecs/model/scan/ParentChainFinder.java
// Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type;
package net.onedaybeard.ecs.model.scan; /** * Builds relationship pairs of parent-child classes - different children may overwrite * the previous parent, but it's sufficient to detect if it's an ECS class or not. */ public class ParentChainFinder extends ClassVisitor { private Map<Type,Set<Type>> parentChildrenMap; public ParentChainFinder(Map<Type,Set<Type>> parentChildrenMap) { super(Opcodes.ASM4); this.parentChildrenMap = parentChildrenMap; } @Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { if (superName != null) {
// Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/ParentChainFinder.java import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; package net.onedaybeard.ecs.model.scan; /** * Builds relationship pairs of parent-child classes - different children may overwrite * the previous parent, but it's sufficient to detect if it's an ECS class or not. */ public class ParentChainFinder extends ClassVisitor { private Map<Type,Set<Type>> parentChildrenMap; public ParentChainFinder(Map<Type,Set<Type>> parentChildrenMap) { super(Opcodes.ASM4); this.parentChildrenMap = parentChildrenMap; } @Override public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { if (superName != null) {
Type visited = type(name);
junkdog/ecs-matrix
matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java
// Path: matrix/src/main/java/net/onedaybeard/ecs/util/MatrixStringUtil.java // public final class MatrixStringUtil { // private MatrixStringUtil() {} // // public static String findLongestClassName(Map<String, List<RowTypeMapping>> mappings) { // return findLongestString(mappings, new LongestClassName()); // } // // public static String findLongestManagerList(Map<String, List<RowTypeMapping>> mappings) { // return findLongestString(mappings, new LongestManagers()); // } // // public static String findLongestSystemList(Map<String, List<RowTypeMapping>> mappings) { // return findLongestString(mappings, new LongestSystems()); // } // // private static String findLongestString(Map<String, List<RowTypeMapping>> mappings, LongestMapper longestStrategy) { // String longest = ""; // for (Entry<String, List<RowTypeMapping>> entry : mappings.entrySet()) { // if (entry.getKey().length() > longest.length()) longest = entry.getKey(); // for (RowTypeMapping mapping : entry.getValue()) { // longest = longestStrategy.getMaxLength(mapping, longest); // } // } // return longest; // } // // private static interface LongestMapper { // String getMaxLength(RowTypeMapping mapping, String previousLongest); // } // // private static class LongestClassName implements LongestMapper { // @Override // public String getMaxLength(RowTypeMapping mapping, String longest) { // return (mapping.name.length() > longest.length()) // ? mapping.name // : longest; // } // } // // private static class LongestManagers implements LongestMapper { // @Override // public String getMaxLength(RowTypeMapping mapping, String longest) { // return (Arrays.toString(mapping.refManagers).length() > longest.length()) // ? Arrays.toString(mapping.refManagers) // : longest; // } // } // // private static class LongestSystems implements LongestMapper { // @Override // public String getMaxLength(RowTypeMapping mapping, String longest) { // return (Arrays.toString(mapping.refSystems).length() > longest.length()) // ? Arrays.toString(mapping.refSystems) // : longest; // } // } // // public static String shortName(String s) { // String name = s; // return name.substring(name.lastIndexOf('.') + 1); // } // // public static String shortName(Type type) { // String name = type.getClassName(); // return name.substring(name.lastIndexOf('.') + 1); // } // }
import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; import java.util.SortedMap; import net.onedaybeard.ecs.util.MatrixStringUtil; import org.objectweb.asm.Opcodes; import com.x5.template.Chunk; import com.x5.template.Theme; import static java.util.Arrays.asList;
process(typeInspector); return "Found ECS framework: " + ecs; } } return "Failed finding any ECS related classes."; } public void process() { process(""); } public void process(String resourcePrefix) { process(new EcsTypeInspector(files, resourcePrefix)); } private void process(EcsTypeInspector typeInspector) { write(typeInspector.getTypeMap(), typeInspector.getMatrixData()); } private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) { Theme theme = new Theme(); Chunk chunk = theme.makeChunk("matrix"); List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>(); for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) { rows.add(new RowTypeMapping(entry.getKey())); rows.addAll(entry.getValue()); }
// Path: matrix/src/main/java/net/onedaybeard/ecs/util/MatrixStringUtil.java // public final class MatrixStringUtil { // private MatrixStringUtil() {} // // public static String findLongestClassName(Map<String, List<RowTypeMapping>> mappings) { // return findLongestString(mappings, new LongestClassName()); // } // // public static String findLongestManagerList(Map<String, List<RowTypeMapping>> mappings) { // return findLongestString(mappings, new LongestManagers()); // } // // public static String findLongestSystemList(Map<String, List<RowTypeMapping>> mappings) { // return findLongestString(mappings, new LongestSystems()); // } // // private static String findLongestString(Map<String, List<RowTypeMapping>> mappings, LongestMapper longestStrategy) { // String longest = ""; // for (Entry<String, List<RowTypeMapping>> entry : mappings.entrySet()) { // if (entry.getKey().length() > longest.length()) longest = entry.getKey(); // for (RowTypeMapping mapping : entry.getValue()) { // longest = longestStrategy.getMaxLength(mapping, longest); // } // } // return longest; // } // // private static interface LongestMapper { // String getMaxLength(RowTypeMapping mapping, String previousLongest); // } // // private static class LongestClassName implements LongestMapper { // @Override // public String getMaxLength(RowTypeMapping mapping, String longest) { // return (mapping.name.length() > longest.length()) // ? mapping.name // : longest; // } // } // // private static class LongestManagers implements LongestMapper { // @Override // public String getMaxLength(RowTypeMapping mapping, String longest) { // return (Arrays.toString(mapping.refManagers).length() > longest.length()) // ? Arrays.toString(mapping.refManagers) // : longest; // } // } // // private static class LongestSystems implements LongestMapper { // @Override // public String getMaxLength(RowTypeMapping mapping, String longest) { // return (Arrays.toString(mapping.refSystems).length() > longest.length()) // ? Arrays.toString(mapping.refSystems) // : longest; // } // } // // public static String shortName(String s) { // String name = s; // return name.substring(name.lastIndexOf('.') + 1); // } // // public static String shortName(Type type) { // String name = type.getClassName(); // return name.substring(name.lastIndexOf('.') + 1); // } // } // Path: matrix/src/main/java/net/onedaybeard/ecs/model/ComponentDependencyMatrix.java import java.io.BufferedWriter; import java.io.File; import java.io.FileWriter; import java.io.IOException; import java.net.URI; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; import java.util.SortedMap; import net.onedaybeard.ecs.util.MatrixStringUtil; import org.objectweb.asm.Opcodes; import com.x5.template.Chunk; import com.x5.template.Theme; import static java.util.Arrays.asList; process(typeInspector); return "Found ECS framework: " + ecs; } } return "Failed finding any ECS related classes."; } public void process() { process(""); } public void process(String resourcePrefix) { process(new EcsTypeInspector(files, resourcePrefix)); } private void process(EcsTypeInspector typeInspector) { write(typeInspector.getTypeMap(), typeInspector.getMatrixData()); } private void write(SortedMap<String, List<RowTypeMapping>> mappedSystems, MatrixData matrix) { Theme theme = new Theme(); Chunk chunk = theme.makeChunk("matrix"); List<RowTypeMapping> rows = new ArrayList<RowTypeMapping>(); for (Entry<String,List<RowTypeMapping>> entry : mappedSystems.entrySet()) { rows.add(new RowTypeMapping(entry.getKey())); rows.addAll(entry.getValue()); }
chunk.set("longestName", MatrixStringUtil.findLongestClassName(mappedSystems).replaceAll(".", "_") + "______");
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() {
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() {
resolver = new ConfigurationResolver(TestHelper.classRootPath(), "");
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes(
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes(
types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class),
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes(
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes(
types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class),
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes(
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes(
types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class),
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes(
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes(
types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class),
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() {
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() {
assertTypes(types(SomeManager.class), resolver.managers);
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() { assertTypes(types(SomeManager.class), resolver.managers); } @Test public void componentIntrospectionTest() {
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() { assertTypes(types(SomeManager.class), resolver.managers); } @Test public void componentIntrospectionTest() {
assertTypes(types(ExtPosition.class, Position.class, Velocity.class), resolver.components);
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() { assertTypes(types(SomeManager.class), resolver.managers); } @Test public void componentIntrospectionTest() {
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() { assertTypes(types(SomeManager.class), resolver.managers); } @Test public void componentIntrospectionTest() {
assertTypes(types(ExtPosition.class, Position.class, Velocity.class), resolver.components);
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() { assertTypes(types(SomeManager.class), resolver.managers); } @Test public void componentIntrospectionTest() { assertTypes(types(ExtPosition.class, Position.class, Velocity.class), resolver.components); } @Test public void factoryIntrospectionTest() {
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; package net.onedaybeard.ecs.model.scan; public final class ConfigurationResolverTest { private static ConfigurationResolver resolver; @BeforeClass public static void setup() { resolver = new ConfigurationResolver(TestHelper.classRootPath(), ""); resolver.clearDefaultTypes(); } @Test public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() { assertTypes(types(SomeManager.class), resolver.managers); } @Test public void componentIntrospectionTest() { assertTypes(types(ExtPosition.class, Position.class, Velocity.class), resolver.components); } @Test public void factoryIntrospectionTest() {
assertTypes(types((FactoryA.class)), resolver.factories);
junkdog/ecs-matrix
matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // }
import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals;
public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() { assertTypes(types(SomeManager.class), resolver.managers); } @Test public void componentIntrospectionTest() { assertTypes(types(ExtPosition.class, Position.class, Velocity.class), resolver.components); } @Test public void factoryIntrospectionTest() { assertTypes(types((FactoryA.class)), resolver.factories); } private static void assertTypes(Set<Type> expectedTypes, Set<Type> actualTypes) { String message = actualTypes.toString(); assertEquals(message, expectedTypes.size(), actualTypes.size()); assertEquals(message, expectedTypes, actualTypes); } private static Set<Type> types(Class<?>... klazzes) { Set<Type> expectedTypes = new HashSet<Type>(); for (Class<?> klazz : klazzes)
// Path: matrix/src/test/java/net/onedaybeard/ecs/component/Position.java // public class Position extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/component/Velocity.java // public class Velocity extends Component { // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/factory/FactoryA.java // @Bind({Position.class, Velocity.class}) // public interface FactoryA extends EntityFactory<FactoryA> { // @Bind(ExtPosition.class) FactoryA extPos(); // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/manager/SomeManager.java // public class SomeManager extends Manager { // private FactoryA factory; // private SomeSystem someSystem; // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/model/TestHelper.java // public class TestHelper { // private TestHelper() {} // // public static File classRootPath() { // return new File("target/test-classes").getAbsoluteFile(); // } // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/AnotherSystem.java // @Wire // public class AnotherSystem extends EntityProcessingSystem { // // private ExtSomeSystem someSystem; // // public AnotherSystem() { // super(Aspect.getAspectForAll(Position.class).one( Velocity.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/EmptySystem.java // public class EmptySystem extends VoidEntitySystem { // @Override // protected void processSystem() {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/SomeSystem.java // public class SomeSystem extends EntityProcessingSystem { // private SomeManager someManager; // private AnotherSystem anotherSystem; // // public SomeSystem() { // super(Aspect.getAspectForAll(ExtPosition.class).exclude(Position.class)); // } // // @Override // protected void process(Entity e) {} // } // // Path: matrix/src/test/java/net/onedaybeard/ecs/system/ExtSomeSystem.java // public class ExtSomeSystem extends SomeSystem {} // // Path: matrix/src/main/java/net/onedaybeard/ecs/model/scan/TypeConfiguration.java // static Type type(Class<?> klazz) { // return type(klazz.getName()); // } // Path: matrix/src/test/java/net/onedaybeard/ecs/model/scan/ConfigurationResolverTest.java import net.onedaybeard.ecs.component.ExtPosition; import net.onedaybeard.ecs.component.Position; import net.onedaybeard.ecs.component.Velocity; import net.onedaybeard.ecs.factory.FactoryA; import net.onedaybeard.ecs.manager.SomeManager; import net.onedaybeard.ecs.model.TestHelper; import net.onedaybeard.ecs.system.AnotherSystem; import net.onedaybeard.ecs.system.EmptySystem; import net.onedaybeard.ecs.system.SomeSystem; import net.onedaybeard.ecs.system.ExtSomeSystem; import org.junit.BeforeClass; import org.junit.Test; import org.objectweb.asm.Type; import java.util.*; import static net.onedaybeard.ecs.model.scan.TypeConfiguration.type; import static org.junit.Assert.assertEquals; public void systemIntrospectionTest() { assertTypes( types(EmptySystem.class, ExtSomeSystem.class, SomeSystem.class, AnotherSystem.class), resolver.systems); } @Test public void managerIntrospectionTest() { assertTypes(types(SomeManager.class), resolver.managers); } @Test public void componentIntrospectionTest() { assertTypes(types(ExtPosition.class, Position.class, Velocity.class), resolver.components); } @Test public void factoryIntrospectionTest() { assertTypes(types((FactoryA.class)), resolver.factories); } private static void assertTypes(Set<Type> expectedTypes, Set<Type> actualTypes) { String message = actualTypes.toString(); assertEquals(message, expectedTypes.size(), actualTypes.size()); assertEquals(message, expectedTypes, actualTypes); } private static Set<Type> types(Class<?>... klazzes) { Set<Type> expectedTypes = new HashSet<Type>(); for (Class<?> klazz : klazzes)
expectedTypes.add(type(klazz));
dgraziotin/openpomo
src/it/unibz/pomodroid/CleanDatabase.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * This class allows us to manipulate the content of the object oriented database db4o. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedActivity * @see android.view.View.OnClickListener * @see http://www.db4o.com */ public class CleanDatabase extends SharedActivity implements OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cleandatabase); Button abDeleteActivitiesEvents = (Button) findViewById(R.id.abDeleteActivitiesEvents); abDeleteActivitiesEvents.setOnClickListener((OnClickListener) this); Button abDeleteDatabase = (Button) findViewById(R.id.abDeleteDatabase); abDeleteDatabase.setOnClickListener((OnClickListener) this); Button abDefragmentDatabase = (Button) findViewById(R.id.abDefragmentDatabase); abDefragmentDatabase.setOnClickListener((OnClickListener) this); } /** * Default listener for clicks. * Regarding to the button that has been clicked, the related action is * called. * * @see android.view.View.OnClickListener#onClick(android.view.View) */ @Override public void onClick(View v) { try { switch (v.getId()) { case R.id.abDeleteActivitiesEvents: Activity.deleteAll(super.getDbHelper()); Event.deleteAll(super.getDbHelper());
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/CleanDatabase.java import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * This class allows us to manipulate the content of the object oriented database db4o. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedActivity * @see android.view.View.OnClickListener * @see http://www.db4o.com */ public class CleanDatabase extends SharedActivity implements OnClickListener { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.cleandatabase); Button abDeleteActivitiesEvents = (Button) findViewById(R.id.abDeleteActivitiesEvents); abDeleteActivitiesEvents.setOnClickListener((OnClickListener) this); Button abDeleteDatabase = (Button) findViewById(R.id.abDeleteDatabase); abDeleteDatabase.setOnClickListener((OnClickListener) this); Button abDefragmentDatabase = (Button) findViewById(R.id.abDefragmentDatabase); abDefragmentDatabase.setOnClickListener((OnClickListener) this); } /** * Default listener for clicks. * Regarding to the button that has been clicked, the related action is * called. * * @see android.view.View.OnClickListener#onClick(android.view.View) */ @Override public void onClick(View v) { try { switch (v.getId()) { case R.id.abDeleteActivitiesEvents: Activity.deleteAll(super.getDbHelper()); Event.deleteAll(super.getDbHelper());
throw new PomodroidException(
dgraziotin/openpomo
src/it/unibz/pomodroid/Preferences.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * This class implements the user preferences. As soon as the user clicks the * button "save" some tests will check the correctness of the data. The user can * also manipulate the DB and launch the tests. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedActivity */ public class Preferences extends SharedActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.preferences); TextView atvPreferences = (TextView) findViewById(R.id.atvPreferences); atvPreferences.setText(getString(R.string.preferences_intro)); fillEditTexts(super.getUser()); } /** * Tests if all the data is correctly filled by user * * @throws PomodroidException */
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/Preferences.java import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.CheckBox; import android.widget.EditText; import android.widget.TextView; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * This class implements the user preferences. As soon as the user clicks the * button "save" some tests will check the correctness of the data. The user can * also manipulate the DB and launch the tests. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedActivity */ public class Preferences extends SharedActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.preferences); TextView atvPreferences = (TextView) findViewById(R.id.atvPreferences); atvPreferences.setText(getString(R.string.preferences_intro)); fillEditTexts(super.getUser()); } /** * Tests if all the data is correctly filled by user * * @throws PomodroidException */
private void checkUserInput() throws PomodroidException {
dgraziotin/openpomo
src/it/unibz/pomodroid/models/Event.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import com.db4o.ObjectSet; import com.db4o.query.Predicate; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import java.util.Date; import java.util.List;
/** * @param activity the activity to set */ public void setActivity(Activity activity) { this.activity = activity; } /** * @return number of pomodoro */ public long getAtPomodoroValue() { return atPomodoroValue; } /** * The number of pomodoro to set * * @param atPomodoroValue */ public void setAtPomodoroValue(long atPomodoroValue) { this.atPomodoroValue = atPomodoroValue; } /** * Save an event into the DB * * @param dbHelper * @throws it.unibz.pomodroid.exceptions.PomodroidException * */
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/models/Event.java import com.db4o.ObjectSet; import com.db4o.query.Predicate; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import java.util.Date; import java.util.List; /** * @param activity the activity to set */ public void setActivity(Activity activity) { this.activity = activity; } /** * @return number of pomodoro */ public long getAtPomodoroValue() { return atPomodoroValue; } /** * The number of pomodoro to set * * @param atPomodoroValue */ public void setAtPomodoroValue(long atPomodoroValue) { this.atPomodoroValue = atPomodoroValue; } /** * Save an event into the DB * * @param dbHelper * @throws it.unibz.pomodroid.exceptions.PomodroidException * */
public void save(DBHelper dbHelper) throws PomodroidException {
dgraziotin/openpomo
src/it/unibz/pomodroid/models/DBHelper.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import android.content.Context; import android.util.Log; import com.db4o.Db4o; import com.db4o.ObjectContainer; import com.db4o.config.Configuration; import com.db4o.defragment.Defragment; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import java.io.File;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid.models; /** * This class manages the open source object database db40 * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> */ public class DBHelper { private static ObjectContainer database; private Context context; /** * Setting database parameters * * @param context */ public DBHelper(Context context) { DBHelper.database = null; this.context = context; } /** * Setting the class attribute * * @param database */ public void setDatabase(ObjectContainer database) { DBHelper.database = database; } /** * Getting the database * * @return an object container * @throws it.unibz.pomodroid.exceptions.PomodroidException * */ @SuppressWarnings("deprecation")
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/models/DBHelper.java import android.content.Context; import android.util.Log; import com.db4o.Db4o; import com.db4o.ObjectContainer; import com.db4o.config.Configuration; import com.db4o.defragment.Defragment; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import java.io.File; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid.models; /** * This class manages the open source object database db40 * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> */ public class DBHelper { private static ObjectContainer database; private Context context; /** * Setting database parameters * * @param context */ public DBHelper(Context context) { DBHelper.database = null; this.context = context; } /** * Setting the class attribute * * @param database */ public void setDatabase(ObjectContainer database) { DBHelper.database = database; } /** * Getting the database * * @return an object container * @throws it.unibz.pomodroid.exceptions.PomodroidException * */ @SuppressWarnings("deprecation")
public ObjectContainer getDatabase() throws PomodroidException {
dgraziotin/openpomo
src/it/unibz/pomodroid/EditActivity.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.DatePicker; import android.widget.EditText;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * This class shows lets user to either create or edit an existing Activity. * It only lets users to edit local activities, not those remotely retrieved * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @see it.unibz.pomodroid.SharedActivity */ public class EditActivity extends SharedActivity { /** * This member holds the unique id of the Activity * if we are editing it */ private Integer originId; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity); try { this.originId = this.getIntent().getExtras().getInt("originId"); fillEmptyFields(this.originId); } catch (NullPointerException e) { this.originId = null; } } /** * This method is responsible for filling all the layout views if the user * is editing an existing activity * * @param originId the unique id of the Activity */ private void fillEmptyFields(Integer originId) { if (originId == null) return; Activity activity; try { activity = Activity.get("local", originId, super.getDbHelper()); EditText aetSummary = (EditText) findViewById(R.id.aetSummary); aetSummary.setText(activity.getSummary()); EditText aetDescription = (EditText) findViewById(R.id.aetDescription); aetDescription.setText(activity.getDescription()); DatePicker adpDeadline = (DatePicker) findViewById(R.id.adpDeadline); Calendar calendar = new GregorianCalendar(); calendar.setTime(activity.getDeadline()); adpDeadline.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/EditActivity.java import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import android.widget.DatePicker; import android.widget.EditText; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * This class shows lets user to either create or edit an existing Activity. * It only lets users to edit local activities, not those remotely retrieved * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @see it.unibz.pomodroid.SharedActivity */ public class EditActivity extends SharedActivity { /** * This member holds the unique id of the Activity * if we are editing it */ private Integer originId; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity); try { this.originId = this.getIntent().getExtras().getInt("originId"); fillEmptyFields(this.originId); } catch (NullPointerException e) { this.originId = null; } } /** * This method is responsible for filling all the layout views if the user * is editing an existing activity * * @param originId the unique id of the Activity */ private void fillEmptyFields(Integer originId) { if (originId == null) return; Activity activity; try { activity = Activity.get("local", originId, super.getDbHelper()); EditText aetSummary = (EditText) findViewById(R.id.aetSummary); aetSummary.setText(activity.getSummary()); EditText aetDescription = (EditText) findViewById(R.id.aetDescription); aetDescription.setText(activity.getDescription()); DatePicker adpDeadline = (DatePicker) findViewById(R.id.adpDeadline); Calendar calendar = new GregorianCalendar(); calendar.setTime(activity.getDeadline()); adpDeadline.updateDate(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH), calendar.get(Calendar.DAY_OF_MONTH));
} catch (PomodroidException e) {
dgraziotin/openpomo
src/it/unibz/pomodroid/ListServices.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import android.app.AlertDialog; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import java.util.ArrayList; import java.util.List; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.TextView;
setContentView(R.layout.listservices); dbHelper = new DBHelper(this); this.context = this; services = new ArrayList<Service>(); this.adapter = new ServiceAdapter(this, R.layout.serviceentry, services); setListAdapter(this.adapter); } /** * Refreshes the list of Services when the Activity gains focus */ @Override public void onResume() { super.onResume(); retrieveServices(); } /** * Sets the custom Adapter, prepares the Runnable for getting Services, * creates and runs the Thread with the Runnable */ private void retrieveServices() { this.services = new ArrayList<Service>(); this.adapter = new ServiceAdapter(this, R.layout.serviceentry, services); this.setListAdapter(this.adapter); this.viewServices = new Runnable() { @Override public void run() { try { getServices();
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/ListServices.java import android.app.AlertDialog; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.Menu; import android.view.MenuItem; import java.util.ArrayList; import java.util.List; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.view.View.OnClickListener; import android.widget.ArrayAdapter; import android.widget.TextView; setContentView(R.layout.listservices); dbHelper = new DBHelper(this); this.context = this; services = new ArrayList<Service>(); this.adapter = new ServiceAdapter(this, R.layout.serviceentry, services); setListAdapter(this.adapter); } /** * Refreshes the list of Services when the Activity gains focus */ @Override public void onResume() { super.onResume(); retrieveServices(); } /** * Sets the custom Adapter, prepares the Runnable for getting Services, * creates and runs the Thread with the Runnable */ private void retrieveServices() { this.services = new ArrayList<Service>(); this.adapter = new ServiceAdapter(this, R.layout.serviceentry, services); this.setListAdapter(this.adapter); this.viewServices = new Runnable() { @Override public void run() { try { getServices();
} catch (PomodroidException e) {
dgraziotin/openpomo
src/it/unibz/pomodroid/SharedListActivity.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import java.util.ArrayList; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.app.AlertDialog; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView;
* * @param resourceLayout */ public void setResourceLayout(int resourceLayout) { this.resourceLayout = resourceLayout; } /** * Default onCreate behavior is defined here * * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activitysheet); this.dbHelper = new DBHelper(getApplicationContext()); this.context = this; this.user = this.getUser(); this.activities = new ArrayList<Activity>(); // first call the adapter to show zero Activities this.activityAdapter = new ActivityAdapter(this, R.layout.ttsactivityentry, activities); this.setListAdapter(this.activityAdapter); } public void refreshUser() { try { setUser(User.retrieve(dbHelper));
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/SharedListActivity.java import java.util.ArrayList; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.app.AlertDialog; import android.app.ListActivity; import android.app.ProgressDialog; import android.content.Context; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.Message; import android.view.LayoutInflater; import android.view.MenuItem; import android.view.View; import android.view.View.OnClickListener; import android.view.View.OnLongClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.TextView; * * @param resourceLayout */ public void setResourceLayout(int resourceLayout) { this.resourceLayout = resourceLayout; } /** * Default onCreate behavior is defined here * * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activitysheet); this.dbHelper = new DBHelper(getApplicationContext()); this.context = this; this.user = this.getUser(); this.activities = new ArrayList<Activity>(); // first call the adapter to show zero Activities this.activityAdapter = new ActivityAdapter(this, R.layout.ttsactivityentry, activities); this.setListAdapter(this.activityAdapter); } public void refreshUser() { try { setUser(User.retrieve(dbHelper));
} catch (PomodroidException e) {
dgraziotin/openpomo
src/it/unibz/pomodroid/PomodoroService.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import it.unibz.pomodroid.models.*; import it.unibz.pomodroid.exceptions.PomodroidException; import java.util.Date; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Messenger; import android.os.RemoteException;
package it.unibz.pomodroid; /** * this is the service that is hooked by the main activity - File Scanner this * will read the params and do something * * @author sschauhan */ public class PomodoroService extends android.app.Service { /** * How many seconds are in a minute */ private final static int SECONDS_PER_MINUTE = 60; /** * How many milliseconds are in a second */ public final static int MILLISECONDS_PER_SECOND = 1000; /** * Sent when Pomodoro ticks a second */ public final static int MSG_REGISTER_CLIENT = -1; /** * Sent when Pomodoro ticks a second */ public final static int MSG_POMODORO_TICK = 1; /** * Sent when Pomodoro finishes */ public final static int MSG_POMODORO_FINISHED = 2; /** * Sent when Pomodoro starts */ public final static int MSG_POMODORO_START = 3; /** * Sent when Pomodoro is stopped */ public final static int MSG_POMODORO_STOP = 4; /** * Sent when Pomodoro ticks a second */ public final static int MSG_UNREGISTER_CLIENT = -2; /** * Holds remaining time in seconds */ private int pomodoroSecondsValue = -1; /** * The Database container for db4o */ private DBHelper dbHelper; /** * The actual User */ private User user; /** * For communication with the Service */ private Messenger messenger; /** * @return dbHelper object */ public DBHelper getDbHelper() { return dbHelper; } /** * @return user object */ public User getUser() { try { return User.retrieve(dbHelper);
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/PomodoroService.java import it.unibz.pomodroid.models.*; import it.unibz.pomodroid.exceptions.PomodroidException; import java.util.Date; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.os.Handler; import android.os.IBinder; import android.os.Message; import android.os.Messenger; import android.os.RemoteException; package it.unibz.pomodroid; /** * this is the service that is hooked by the main activity - File Scanner this * will read the params and do something * * @author sschauhan */ public class PomodoroService extends android.app.Service { /** * How many seconds are in a minute */ private final static int SECONDS_PER_MINUTE = 60; /** * How many milliseconds are in a second */ public final static int MILLISECONDS_PER_SECOND = 1000; /** * Sent when Pomodoro ticks a second */ public final static int MSG_REGISTER_CLIENT = -1; /** * Sent when Pomodoro ticks a second */ public final static int MSG_POMODORO_TICK = 1; /** * Sent when Pomodoro finishes */ public final static int MSG_POMODORO_FINISHED = 2; /** * Sent when Pomodoro starts */ public final static int MSG_POMODORO_START = 3; /** * Sent when Pomodoro is stopped */ public final static int MSG_POMODORO_STOP = 4; /** * Sent when Pomodoro ticks a second */ public final static int MSG_UNREGISTER_CLIENT = -2; /** * Holds remaining time in seconds */ private int pomodoroSecondsValue = -1; /** * The Database container for db4o */ private DBHelper dbHelper; /** * The actual User */ private User user; /** * For communication with the Service */ private Messenger messenger; /** * @return dbHelper object */ public DBHelper getDbHelper() { return dbHelper; } /** * @return user object */ public User getUser() { try { return User.retrieve(dbHelper);
} catch (PomodroidException e) {
dgraziotin/openpomo
src/it/unibz/pomodroid/models/Service.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import java.util.List; import android.util.Log; import it.unibz.pomodroid.exceptions.PomodroidException; import com.db4o.ObjectSet; import com.db4o.query.Predicate; import com.db4o.query.Query;
*/ public String getType() { return type; } /** * Helper method for updating an existing Service * * @param service */ public void update(Service service) { this.name = service.getName(); this.url = service.getUrl(); this.type = service.getType(); this.username = service.getUsername(); this.password = service.getPassword(); this.isAnonymousAccess = service.isAnonymousAccess(); this.isActive = service.isActive(); } /** * Returns true if a Service with the given name is already * present in the DB * * @param name * @param dbHelper * @return true if the Service is Present * @throws PomodroidException */ public static boolean isPresent(final String name,
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/models/Service.java import java.util.List; import android.util.Log; import it.unibz.pomodroid.exceptions.PomodroidException; import com.db4o.ObjectSet; import com.db4o.query.Predicate; import com.db4o.query.Query; */ public String getType() { return type; } /** * Helper method for updating an existing Service * * @param service */ public void update(Service service) { this.name = service.getName(); this.url = service.getUrl(); this.type = service.getType(); this.username = service.getUsername(); this.password = service.getPassword(); this.isAnonymousAccess = service.isAnonymousAccess(); this.isActive = service.isActive(); } /** * Returns true if a Service with the given name is already * present in the DB * * @param name * @param dbHelper * @return true if the Service is Present * @throws PomodroidException */ public static boolean isPresent(final String name,
DBHelper dbHelper) throws PomodroidException {
dgraziotin/openpomo
src/it/unibz/pomodroid/Pomodroid.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import android.os.Bundle; import it.unibz.pomodroid.exceptions.PomodroidException;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * Main activity. It just loads the layout. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedActivity */ public class Pomodroid extends SharedActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.getUser().setSelectedActivity(null); super.getUser().setUnderPomodoro(false); try { super.getUser().save(getDbHelper());
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/Pomodroid.java import android.os.Bundle; import it.unibz.pomodroid.exceptions.PomodroidException; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * Main activity. It just loads the layout. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedActivity */ public class Pomodroid extends SharedActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); super.getUser().setSelectedActivity(null); super.getUser().setUnderPomodoro(false); try { super.getUser().save(getDbHelper());
} catch (PomodroidException e) {
dgraziotin/openpomo
src/it/unibz/pomodroid/TodoTodaySheet.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.RelativeLayout; import android.util.Log; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.Menu;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * Todo Today Sheet class is an extension of Shared List activity. This class * shows to the user which activities have to be done today. * <p/> * Here we can face the activity, move it into the activity inventory sheet or * into the trash sheet. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedListActivity */ public class TodoTodaySheet extends SharedListActivity { /** * @see it.unibz.pomodroid.SharedListActivity#onCreate(android.os.Bundle) */ @Override public void onCreate(Bundle savedInstanceState) { super.setResourceLayout(R.layout.ttsactivityentry); super.setContext(this); super.onCreate(savedInstanceState); //TextView textViewEmptySheet = (TextView) findViewById(R.id.atvEmptySheet); //textViewEmptySheet.setText(getString(R.string.no_activities_tts)); //textViewEmptySheet.setVisibility(View.INVISIBLE); Button abQuickInsertActivity = (Button) findViewById(R.id.abQuickInsertActivity); final EditText aetQuickInsertActivity = (EditText) findViewById(R.id.aetQuickInsertActivity); abQuickInsertActivity.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (aetQuickInsertActivity.getText().toString().equals("")) return; Calendar calendar = new GregorianCalendar(); try { Activity activity = new Activity(0, 0, new Date(), calendar .getTime(), aetQuickInsertActivity.getText() .toString(), "", "local", Activity .getLastLocalId(dbHelper) + 1, "medium", "you", "task"); activity.setTodoToday(true); activity.save(dbHelper); //findViewById(R.id.atvEmptySheet) // .setVisibility(View.INVISIBLE); refreshSheet();
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/TodoTodaySheet.java import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.EditText; import android.widget.RelativeLayout; import android.util.Log; import java.util.ArrayList; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.os.Bundle; import android.view.Menu; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * Todo Today Sheet class is an extension of Shared List activity. This class * shows to the user which activities have to be done today. * <p/> * Here we can face the activity, move it into the activity inventory sheet or * into the trash sheet. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedListActivity */ public class TodoTodaySheet extends SharedListActivity { /** * @see it.unibz.pomodroid.SharedListActivity#onCreate(android.os.Bundle) */ @Override public void onCreate(Bundle savedInstanceState) { super.setResourceLayout(R.layout.ttsactivityentry); super.setContext(this); super.onCreate(savedInstanceState); //TextView textViewEmptySheet = (TextView) findViewById(R.id.atvEmptySheet); //textViewEmptySheet.setText(getString(R.string.no_activities_tts)); //textViewEmptySheet.setVisibility(View.INVISIBLE); Button abQuickInsertActivity = (Button) findViewById(R.id.abQuickInsertActivity); final EditText aetQuickInsertActivity = (EditText) findViewById(R.id.aetQuickInsertActivity); abQuickInsertActivity.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (aetQuickInsertActivity.getText().toString().equals("")) return; Calendar calendar = new GregorianCalendar(); try { Activity activity = new Activity(0, 0, new Date(), calendar .getTime(), aetQuickInsertActivity.getText() .toString(), "", "local", Activity .getLastLocalId(dbHelper) + 1, "medium", "you", "task"); activity.setTodoToday(true); activity.save(dbHelper); //findViewById(R.id.atvEmptySheet) // .setVisibility(View.INVISIBLE); refreshSheet();
throw new PomodroidException("INFO: Activity saved.");
dgraziotin/openpomo
src/it/unibz/pomodroid/SharedActivity.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * Base-class of all activities. Defines common behavior for all Activities of * Pomodroid. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @see android.app.Activity */ public abstract class SharedActivity extends Activity { /** * The Database container for db4o */ private DBHelper dbHelper; /** * The current user */ private User user; /** * The Context of the Activity */ protected Context context; /** * @return dbHelper object */ public DBHelper getDbHelper() { return dbHelper; } /** * Set dbHelper * * @param dbHelper */ public void setDbHelper(DBHelper dbHelper) { this.dbHelper = dbHelper; } /** * @return user object */ public User getUser() { if (user == null) { try { if (User.isPresent(dbHelper)) { this.setUser(User.retrieve(dbHelper)); } else { this.user = new User(); this.user.setPomodoroMinutesDuration(25); this.user.save(this.dbHelper); }
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/SharedActivity.java import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * Base-class of all activities. Defines common behavior for all Activities of * Pomodroid. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @see android.app.Activity */ public abstract class SharedActivity extends Activity { /** * The Database container for db4o */ private DBHelper dbHelper; /** * The current user */ private User user; /** * The Context of the Activity */ protected Context context; /** * @return dbHelper object */ public DBHelper getDbHelper() { return dbHelper; } /** * Set dbHelper * * @param dbHelper */ public void setDbHelper(DBHelper dbHelper) { this.dbHelper = dbHelper; } /** * @return user object */ public User getUser() { if (user == null) { try { if (User.isPresent(dbHelper)) { this.setUser(User.retrieve(dbHelper)); } else { this.user = new User(); this.user.setPomodoroMinutesDuration(25); this.user.save(this.dbHelper); }
} catch (PomodroidException e) {
dgraziotin/openpomo
src/it/unibz/pomodroid/models/User.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import android.util.Log; import com.db4o.ObjectSet; import it.unibz.pomodroid.exceptions.PomodroidException; import java.util.Date;
* Every 4 pomodoro the user should do a longer break * * @return */ public boolean isFourthPomodoro() { return (this.facedPomodoro % 4 == 0); } /** * Add one pomodoro */ public void addPomodoro() { this.facedPomodoro++; } public boolean isDisplayDonations() { return displayDonations; } public void setDisplayDonations(boolean displayDonations) { this.displayDonations = displayDonations; } /** * @param username * @param dbHelper * @return * @throws it.unibz.pomodroid.exceptions.PomodroidException * */
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/models/User.java import android.util.Log; import com.db4o.ObjectSet; import it.unibz.pomodroid.exceptions.PomodroidException; import java.util.Date; * Every 4 pomodoro the user should do a longer break * * @return */ public boolean isFourthPomodoro() { return (this.facedPomodoro % 4 == 0); } /** * Add one pomodoro */ public void addPomodoro() { this.facedPomodoro++; } public boolean isDisplayDonations() { return displayDonations; } public void setDisplayDonations(boolean displayDonations) { this.displayDonations = displayDonations; } /** * @param username * @param dbHelper * @return * @throws it.unibz.pomodroid.exceptions.PomodroidException * */
public static boolean isPresent(DBHelper dbHelper) throws PomodroidException {
dgraziotin/openpomo
src/it/unibz/pomodroid/factories/ActivityFactory.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import java.util.Date; import java.util.HashMap; import java.util.Vector; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid.factories; /** * A class that saves all information about tickets it into the * database. Each ticket taken from a Service is checked. If some information * is empty, the class provides some auto-generated values. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> */ public class ActivityFactory { /** * String that represent a default value for empty fields in Activities */ final private static String autogen = "Autogenerated value"; /** * @param id trac identifier * @param deadLine date within the work has be done * @param attributes list containing all information about one ticket * @param dbHelper reference to the database */ public int produce(Vector<HashMap<String, Object>> tickets,
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/factories/ActivityFactory.java import java.util.Date; import java.util.HashMap; import java.util.Vector; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid.factories; /** * A class that saves all information about tickets it into the * database. Each ticket taken from a Service is checked. If some information * is empty, the class provides some auto-generated values. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> */ public class ActivityFactory { /** * String that represent a default value for empty fields in Activities */ final private static String autogen = "Autogenerated value"; /** * @param id trac identifier * @param deadLine date within the work has be done * @param attributes list containing all information about one ticket * @param dbHelper reference to the database */ public int produce(Vector<HashMap<String, Object>> tickets,
DBHelper dbHelper) throws PomodroidException {
dgraziotin/openpomo
src/it/unibz/pomodroid/TrashSheet.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import java.util.ArrayList; import java.util.List; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.Menu;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * Trash Sheet class is an extension of Shared List activity. * This class shows to the user which activities are done. * <p/> * From here we can move an activity into the todo today sheet (and automatically into * the activity inventory sheet) or into the activity inventory sheet. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedListActivity */ public class TrashSheet extends SharedListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.setResourceLayout(R.layout.trashactivityentry); super.setContext(this); super.onCreate(savedInstanceState); } /** * Gets the Activities from Activity.getCompleted() and adds them to the local * list of activities. It calls populateAdapter to populate the adapter with * the new list of activities * * @throws PomodroidException * @see Activity */ @Override
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/TrashSheet.java import java.util.ArrayList; import java.util.List; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.Menu; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * Trash Sheet class is an extension of Shared List activity. * This class shows to the user which activities are done. * <p/> * From here we can move an activity into the todo today sheet (and automatically into * the activity inventory sheet) or into the activity inventory sheet. * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @author Thomas Schievenin <[email protected]> * @see it.unibz.pomodroid.SharedListActivity */ public class TrashSheet extends SharedListActivity { @Override public void onCreate(Bundle savedInstanceState) { super.setResourceLayout(R.layout.trashactivityentry); super.setContext(this); super.onCreate(savedInstanceState); } /** * Gets the Activities from Activity.getCompleted() and adds them to the local * list of activities. It calls populateAdapter to populate the adapter with * the new list of activities * * @throws PomodroidException * @see Activity */ @Override
protected void retrieveActivities() throws PomodroidException {
dgraziotin/openpomo
src/it/unibz/pomodroid/Statistics.java
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // }
import android.os.Bundle; import android.widget.TextView; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*;
/** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * A simple Activity to show an About Window * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @see it.unibz.pomodroid.SharedActivity */ public class Statistics extends SharedActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.statistics); DBHelper dbHelper = getDbHelper(); String activitiesCreated = "0"; String activitiesCompleted = "0"; String pomodoroStarted = "0"; String pomodoroFinished = "0"; String pomodoroBroken = "0"; String pomodoroFinishedStarted = "0"; TextView atvActivitiesCreated = (TextView) findViewById(R.id.atvActivitiesCreated); TextView atvActivitiesCompleted = (TextView) findViewById(R.id.atvActivitiesCompleted); TextView atvPomodoroStarted = (TextView) findViewById(R.id.atvPomodoroStarted); TextView atvPomodoroFinished = (TextView) findViewById(R.id.atvPomodoroFinished); TextView atvPomodoroBroken = (TextView) findViewById(R.id.atvPomodoroBroken); TextView atvPomodoroFinishedStarted = (TextView) findViewById(R.id.atvPomodorosFinishedStarted); try { activitiesCreated = new Integer(Activity.getAll(dbHelper).size()).toString(); activitiesCompleted = new Integer(Activity.getCompleted(dbHelper).size()).toString(); Integer numPomodoroStarted = new Integer(Event.getAllStartedPomodoros(dbHelper).size()); pomodoroStarted = numPomodoroStarted.toString(); Integer numPomodoroFinished = new Integer(Event.getAllFinishedPomodoros(dbHelper).size()); pomodoroFinished = numPomodoroFinished.toString(); pomodoroBroken = new Integer(Event.getAllInterruptions(dbHelper).size()).toString(); Integer numPomodoroFinishedStarted = (int) (((float) numPomodoroFinished / (float) numPomodoroStarted) * 100); pomodoroFinishedStarted = numPomodoroFinishedStarted.toString().concat("%");
// Path: src/it/unibz/pomodroid/exceptions/PomodroidException.java // public class PomodroidException extends Exception { // // /** // * Required by the compiler // */ // private static final long serialVersionUID = 1L; // /** // * A Custom title for an Exception when displayed to User // */ // private String title = null; // // // /** // * Default constructor // */ // public PomodroidException(Exception e) { // // call superclass constructor // super(); // } // // /** // * Default constructor // */ // public PomodroidException() { // // call superclass constructor // super(); // } // // /** // * Constructor for displaying a custom message // */ // public PomodroidException(String message) { // // Call super class constructor // super(message); // } // // /** // * Constructor for displaying a custom message and title // */ // public PomodroidException(String message, String title) { // super(message); // this.title = title; // } // // /** // * @return title // */ // public String getTitle() { // return title; // } // // /** // * the title to set // * // * @param title // */ // public void setTitle(String title) { // this.title = title; // } // // // /** // * This method shows an exception to user, with a Toast // * // * @param context // */ // public void alertUser(Context context) { // Toast.makeText(context, this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public void alertUser(Context context, String title) { // Toast.makeText(context, title + ": " + this.getMessage(), Toast.LENGTH_LONG).show(); // } // // /** // * This method shows a simply message (information) // * // * @param context // * @param title // */ // public static void createAlert(Context context, String title, String message) { // Toast.makeText(context, title + ": " + message, Toast.LENGTH_LONG).show(); // } // // } // Path: src/it/unibz/pomodroid/Statistics.java import android.os.Bundle; import android.widget.TextView; import it.unibz.pomodroid.exceptions.PomodroidException; import it.unibz.pomodroid.models.*; /** * This file is part of Pomodroid. * * Pomodroid is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pomodroid 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Pomodroid. If not, see <http://www.gnu.org/licenses/>. */ package it.unibz.pomodroid; /** * A simple Activity to show an About Window * * @author Daniel Graziotin <d AT danielgraziotin DOT it> * @see it.unibz.pomodroid.SharedActivity */ public class Statistics extends SharedActivity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.statistics); DBHelper dbHelper = getDbHelper(); String activitiesCreated = "0"; String activitiesCompleted = "0"; String pomodoroStarted = "0"; String pomodoroFinished = "0"; String pomodoroBroken = "0"; String pomodoroFinishedStarted = "0"; TextView atvActivitiesCreated = (TextView) findViewById(R.id.atvActivitiesCreated); TextView atvActivitiesCompleted = (TextView) findViewById(R.id.atvActivitiesCompleted); TextView atvPomodoroStarted = (TextView) findViewById(R.id.atvPomodoroStarted); TextView atvPomodoroFinished = (TextView) findViewById(R.id.atvPomodoroFinished); TextView atvPomodoroBroken = (TextView) findViewById(R.id.atvPomodoroBroken); TextView atvPomodoroFinishedStarted = (TextView) findViewById(R.id.atvPomodorosFinishedStarted); try { activitiesCreated = new Integer(Activity.getAll(dbHelper).size()).toString(); activitiesCompleted = new Integer(Activity.getCompleted(dbHelper).size()).toString(); Integer numPomodoroStarted = new Integer(Event.getAllStartedPomodoros(dbHelper).size()); pomodoroStarted = numPomodoroStarted.toString(); Integer numPomodoroFinished = new Integer(Event.getAllFinishedPomodoros(dbHelper).size()); pomodoroFinished = numPomodoroFinished.toString(); pomodoroBroken = new Integer(Event.getAllInterruptions(dbHelper).size()).toString(); Integer numPomodoroFinishedStarted = (int) (((float) numPomodoroFinished / (float) numPomodoroStarted) * 100); pomodoroFinishedStarted = numPomodoroFinishedStarted.toString().concat("%");
} catch (PomodroidException e) {
MrBW/resilient-transport-service
booking-service/src/main/java/de/codecentric/resilient/booking/BookingServiceApplication.java
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // }
import de.codecentric.resilient.configuration.DefautConfiguration; import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
package de.codecentric.resilient.booking; /** * Connote Service * * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication @EnableCircuitBreaker
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // } // Path: booking-service/src/main/java/de/codecentric/resilient/booking/BookingServiceApplication.java import de.codecentric.resilient.configuration.DefautConfiguration; import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; package de.codecentric.resilient.booking; /** * Connote Service * * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication @EnableCircuitBreaker
@Import(DefautConfiguration.class)
MrBW/resilient-transport-service
address-service/src/main/java/de/codecentric/resilient/address/service/AddressService.java
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class AddressDTO { // // @JsonProperty(required = true) // private String country; // // @JsonProperty(required = true) // private String city; // // @JsonProperty(required = true) // private String postcode; // // @JsonProperty(required = true) // private String street; // // @JsonProperty(required = true) // private String streetNumber; // // public AddressDTO() { // } // // public AddressDTO(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("AddressDTO{"); // sb.append("country='").append(country).append('\''); // sb.append(", city='").append(city).append('\''); // sb.append(", postcode='").append(postcode).append('\''); // sb.append(", street='").append(street).append('\''); // sb.append(", streetNumber='").append(streetNumber).append('\''); // sb.append('}'); // return sb.toString(); // } // }
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith; import de.codecentric.resilient.address.repository.AddressRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.stereotype.Service; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.dto.AddressDTO;
package de.codecentric.resilient.address.service; /** * @author Benjamin Wilms (xd98870) */ @Service public class AddressService {
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class AddressDTO { // // @JsonProperty(required = true) // private String country; // // @JsonProperty(required = true) // private String city; // // @JsonProperty(required = true) // private String postcode; // // @JsonProperty(required = true) // private String street; // // @JsonProperty(required = true) // private String streetNumber; // // public AddressDTO() { // } // // public AddressDTO(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("AddressDTO{"); // sb.append("country='").append(country).append('\''); // sb.append(", city='").append(city).append('\''); // sb.append(", postcode='").append(postcode).append('\''); // sb.append(", street='").append(street).append('\''); // sb.append(", streetNumber='").append(streetNumber).append('\''); // sb.append('}'); // return sb.toString(); // } // } // Path: address-service/src/main/java/de/codecentric/resilient/address/service/AddressService.java import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith; import de.codecentric.resilient.address.repository.AddressRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.stereotype.Service; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.dto.AddressDTO; package de.codecentric.resilient.address.service; /** * @author Benjamin Wilms (xd98870) */ @Service public class AddressService {
private final AddressRepository addressRepository;
MrBW/resilient-transport-service
address-service/src/main/java/de/codecentric/resilient/address/service/AddressService.java
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class AddressDTO { // // @JsonProperty(required = true) // private String country; // // @JsonProperty(required = true) // private String city; // // @JsonProperty(required = true) // private String postcode; // // @JsonProperty(required = true) // private String street; // // @JsonProperty(required = true) // private String streetNumber; // // public AddressDTO() { // } // // public AddressDTO(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("AddressDTO{"); // sb.append("country='").append(country).append('\''); // sb.append(", city='").append(city).append('\''); // sb.append(", postcode='").append(postcode).append('\''); // sb.append(", street='").append(street).append('\''); // sb.append(", streetNumber='").append(streetNumber).append('\''); // sb.append('}'); // return sb.toString(); // } // }
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith; import de.codecentric.resilient.address.repository.AddressRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.stereotype.Service; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.dto.AddressDTO;
package de.codecentric.resilient.address.service; /** * @author Benjamin Wilms (xd98870) */ @Service public class AddressService { private final AddressRepository addressRepository; @Autowired public AddressService(AddressRepository addressRepository) { this.addressRepository = addressRepository; }
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class AddressDTO { // // @JsonProperty(required = true) // private String country; // // @JsonProperty(required = true) // private String city; // // @JsonProperty(required = true) // private String postcode; // // @JsonProperty(required = true) // private String street; // // @JsonProperty(required = true) // private String streetNumber; // // public AddressDTO() { // } // // public AddressDTO(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("AddressDTO{"); // sb.append("country='").append(country).append('\''); // sb.append(", city='").append(city).append('\''); // sb.append(", postcode='").append(postcode).append('\''); // sb.append(", street='").append(street).append('\''); // sb.append(", streetNumber='").append(streetNumber).append('\''); // sb.append('}'); // return sb.toString(); // } // } // Path: address-service/src/main/java/de/codecentric/resilient/address/service/AddressService.java import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith; import de.codecentric.resilient.address.repository.AddressRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.stereotype.Service; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.dto.AddressDTO; package de.codecentric.resilient.address.service; /** * @author Benjamin Wilms (xd98870) */ @Service public class AddressService { private final AddressRepository addressRepository; @Autowired public AddressService(AddressRepository addressRepository) { this.addressRepository = addressRepository; }
public Address validateAddress(AddressDTO addressDTO) {
MrBW/resilient-transport-service
address-service/src/main/java/de/codecentric/resilient/address/service/AddressService.java
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class AddressDTO { // // @JsonProperty(required = true) // private String country; // // @JsonProperty(required = true) // private String city; // // @JsonProperty(required = true) // private String postcode; // // @JsonProperty(required = true) // private String street; // // @JsonProperty(required = true) // private String streetNumber; // // public AddressDTO() { // } // // public AddressDTO(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("AddressDTO{"); // sb.append("country='").append(country).append('\''); // sb.append(", city='").append(city).append('\''); // sb.append(", postcode='").append(postcode).append('\''); // sb.append(", street='").append(street).append('\''); // sb.append(", streetNumber='").append(streetNumber).append('\''); // sb.append('}'); // return sb.toString(); // } // }
import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith; import de.codecentric.resilient.address.repository.AddressRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.stereotype.Service; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.dto.AddressDTO;
package de.codecentric.resilient.address.service; /** * @author Benjamin Wilms (xd98870) */ @Service public class AddressService { private final AddressRepository addressRepository; @Autowired public AddressService(AddressRepository addressRepository) { this.addressRepository = addressRepository; }
// Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class AddressDTO { // // @JsonProperty(required = true) // private String country; // // @JsonProperty(required = true) // private String city; // // @JsonProperty(required = true) // private String postcode; // // @JsonProperty(required = true) // private String street; // // @JsonProperty(required = true) // private String streetNumber; // // public AddressDTO() { // } // // public AddressDTO(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("AddressDTO{"); // sb.append("country='").append(country).append('\''); // sb.append(", city='").append(city).append('\''); // sb.append(", postcode='").append(postcode).append('\''); // sb.append(", street='").append(street).append('\''); // sb.append(", streetNumber='").append(streetNumber).append('\''); // sb.append('}'); // return sb.toString(); // } // } // Path: address-service/src/main/java/de/codecentric/resilient/address/service/AddressService.java import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.contains; import static org.springframework.data.domain.ExampleMatcher.GenericPropertyMatchers.startsWith; import de.codecentric.resilient.address.repository.AddressRepository; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Example; import org.springframework.data.domain.ExampleMatcher; import org.springframework.stereotype.Service; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.dto.AddressDTO; package de.codecentric.resilient.address.service; /** * @author Benjamin Wilms (xd98870) */ @Service public class AddressService { private final AddressRepository addressRepository; @Autowired public AddressService(AddressRepository addressRepository) { this.addressRepository = addressRepository; }
public Address validateAddress(AddressDTO addressDTO) {
MrBW/resilient-transport-service
address-service/src/main/java/de/codecentric/resilient/address/rest/AddressController.java
// Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/service/AddressService.java // @Service // public class AddressService { // // private final AddressRepository addressRepository; // // @Autowired // public AddressService(AddressRepository addressRepository) { // this.addressRepository = addressRepository; // } // // public Address validateAddress(AddressDTO addressDTO) { // // Address addressToSearch = new Address(addressDTO.getCountry(), addressDTO.getCity(), addressDTO.getPostcode(), // addressDTO.getStreet(), addressDTO.getStreetNumber()); // // //@formatter:off // ExampleMatcher matcher = // ExampleMatcher.matching() // .withMatcher("country", startsWith().ignoreCase()) // .withMatcher("postcode", startsWith().ignoreCase()) // .withMatcher("street", contains().ignoreCase()) // .withMatcher("streetNumber", contains().ignoreCase()) // .withMatcher("city", contains().ignoreCase()); // // //@formatter:on // Example<Address> searchExample = Example.of(addressToSearch, matcher); // // return addressRepository.findOne(searchExample); // // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class AddressDTO { // // @JsonProperty(required = true) // private String country; // // @JsonProperty(required = true) // private String city; // // @JsonProperty(required = true) // private String postcode; // // @JsonProperty(required = true) // private String street; // // @JsonProperty(required = true) // private String streetNumber; // // public AddressDTO() { // } // // public AddressDTO(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("AddressDTO{"); // sb.append("country='").append(country).append('\''); // sb.append(", city='").append(city).append('\''); // sb.append(", postcode='").append(postcode).append('\''); // sb.append(", street='").append(street).append('\''); // sb.append(", streetNumber='").append(streetNumber).append('\''); // sb.append('}'); // return sb.toString(); // } // }
import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.address.service.AddressService; import de.codecentric.resilient.dto.AddressDTO;
package de.codecentric.resilient.address.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/address") public class AddressController {
// Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/service/AddressService.java // @Service // public class AddressService { // // private final AddressRepository addressRepository; // // @Autowired // public AddressService(AddressRepository addressRepository) { // this.addressRepository = addressRepository; // } // // public Address validateAddress(AddressDTO addressDTO) { // // Address addressToSearch = new Address(addressDTO.getCountry(), addressDTO.getCity(), addressDTO.getPostcode(), // addressDTO.getStreet(), addressDTO.getStreetNumber()); // // //@formatter:off // ExampleMatcher matcher = // ExampleMatcher.matching() // .withMatcher("country", startsWith().ignoreCase()) // .withMatcher("postcode", startsWith().ignoreCase()) // .withMatcher("street", contains().ignoreCase()) // .withMatcher("streetNumber", contains().ignoreCase()) // .withMatcher("city", contains().ignoreCase()); // // //@formatter:on // Example<Address> searchExample = Example.of(addressToSearch, matcher); // // return addressRepository.findOne(searchExample); // // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/AddressDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class AddressDTO { // // @JsonProperty(required = true) // private String country; // // @JsonProperty(required = true) // private String city; // // @JsonProperty(required = true) // private String postcode; // // @JsonProperty(required = true) // private String street; // // @JsonProperty(required = true) // private String streetNumber; // // public AddressDTO() { // } // // public AddressDTO(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("AddressDTO{"); // sb.append("country='").append(country).append('\''); // sb.append(", city='").append(city).append('\''); // sb.append(", postcode='").append(postcode).append('\''); // sb.append(", street='").append(street).append('\''); // sb.append(", streetNumber='").append(streetNumber).append('\''); // sb.append('}'); // return sb.toString(); // } // } // Path: address-service/src/main/java/de/codecentric/resilient/address/rest/AddressController.java import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.address.service.AddressService; import de.codecentric.resilient.dto.AddressDTO; package de.codecentric.resilient.address.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/address") public class AddressController {
private final AddressService addressService;
MrBW/resilient-transport-service
connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // }
import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.codecentric.resilient.dto.ConnoteDTO;
package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms */ @Service public class ConnoteService { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class);
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // Path: connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.codecentric.resilient.dto.ConnoteDTO; package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms */ @Service public class ConnoteService { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class);
private ConnoteRepository connoteRepository;
MrBW/resilient-transport-service
connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // }
import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.codecentric.resilient.dto.ConnoteDTO;
package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms */ @Service public class ConnoteService { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); private ConnoteRepository connoteRepository;
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // Path: connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.codecentric.resilient.dto.ConnoteDTO; package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms */ @Service public class ConnoteService { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); private ConnoteRepository connoteRepository;
private final RandomConnoteGenerator connoteGenerator;
MrBW/resilient-transport-service
connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // }
import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.codecentric.resilient.dto.ConnoteDTO;
package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms */ @Service public class ConnoteService { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); private ConnoteRepository connoteRepository; private final RandomConnoteGenerator connoteGenerator; @Autowired public ConnoteService(ConnoteRepository connoteRepository, RandomConnoteGenerator connoteGenerator) { this.connoteRepository = connoteRepository; this.connoteGenerator = connoteGenerator; }
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // Path: connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.codecentric.resilient.dto.ConnoteDTO; package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms */ @Service public class ConnoteService { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); private ConnoteRepository connoteRepository; private final RandomConnoteGenerator connoteGenerator; @Autowired public ConnoteService(ConnoteRepository connoteRepository, RandomConnoteGenerator connoteGenerator) { this.connoteRepository = connoteRepository; this.connoteGenerator = connoteGenerator; }
public ConnoteDTO createConnote() {
MrBW/resilient-transport-service
connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // }
import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.codecentric.resilient.dto.ConnoteDTO;
package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms */ @Service public class ConnoteService { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); private ConnoteRepository connoteRepository; private final RandomConnoteGenerator connoteGenerator; @Autowired public ConnoteService(ConnoteRepository connoteRepository, RandomConnoteGenerator connoteGenerator) { this.connoteRepository = connoteRepository; this.connoteGenerator = connoteGenerator; } public ConnoteDTO createConnote() { Long nextConnote; do { nextConnote = connoteGenerator.randomNumber(); } while (!isUnique(nextConnote));
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // Path: connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import de.codecentric.resilient.dto.ConnoteDTO; package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms */ @Service public class ConnoteService { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); private ConnoteRepository connoteRepository; private final RandomConnoteGenerator connoteGenerator; @Autowired public ConnoteService(ConnoteRepository connoteRepository, RandomConnoteGenerator connoteGenerator) { this.connoteRepository = connoteRepository; this.connoteGenerator = connoteGenerator; } public ConnoteDTO createConnote() { Long nextConnote; do { nextConnote = connoteGenerator.randomNumber(); } while (!isUnique(nextConnote));
Connote connoteSaved = createConnote(nextConnote);
MrBW/resilient-transport-service
transport-api-gateway/src/main/java/de/codecentric/resilient/transport/api/gateway/TransportApiGatewayApplication.java
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // }
import de.codecentric.resilient.configuration.DefautConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import org.springframework.scheduling.annotation.EnableAsync;
package de.codecentric.resilient.transport.api.gateway; /** * Transport Api Gateway * * @author Benjamin Wilms */ @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication @EnableCircuitBreaker @EnableAsync
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // } // Path: transport-api-gateway/src/main/java/de/codecentric/resilient/transport/api/gateway/TransportApiGatewayApplication.java import de.codecentric.resilient.configuration.DefautConfiguration; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import org.springframework.scheduling.annotation.EnableAsync; package de.codecentric.resilient.transport.api.gateway; /** * Transport Api Gateway * * @author Benjamin Wilms */ @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication @EnableCircuitBreaker @EnableAsync
@Import(DefautConfiguration.class)
MrBW/resilient-transport-service
connote-service/src/main/java/de/codecentric/resilient/connote/ConnoteServiceApplication.java
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // }
import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import de.codecentric.resilient.configuration.DefautConfiguration;
package de.codecentric.resilient.connote; /** * Connote Service * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication
// Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // } // Path: connote-service/src/main/java/de/codecentric/resilient/connote/ConnoteServiceApplication.java import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import de.codecentric.resilient.configuration.DefautConfiguration; package de.codecentric.resilient.connote; /** * Connote Service * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication
@Import(DefautConfiguration.class)
MrBW/resilient-transport-service
connote-service/src/main/java/de/codecentric/resilient/connote/rest/ConnoteController.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java // @Service // public class ConnoteService { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); // // private ConnoteRepository connoteRepository; // // private final RandomConnoteGenerator connoteGenerator; // // @Autowired // public ConnoteService(ConnoteRepository connoteRepository, RandomConnoteGenerator connoteGenerator) { // // this.connoteRepository = connoteRepository; // this.connoteGenerator = connoteGenerator; // } // // public ConnoteDTO createConnote() { // // Long nextConnote; // // do { // nextConnote = connoteGenerator.randomNumber(); // // } while (!isUnique(nextConnote)); // // Connote connoteSaved = createConnote(nextConnote); // // ConnoteDTO connoteDTO = new ConnoteDTO(); // connoteDTO.setConnote(connoteSaved.getConnote()); // // return connoteDTO; // // } // // private Connote createConnote(Long connote) { // // Connote connoteSaved = connoteRepository.save(new Connote(connote)); // // LOGGER.debug(LOGGER.isDebugEnabled() ? "Saved new Connote entity: " + connoteSaved.getConnote() : null); // // return connoteSaved; // } // // private boolean isUnique(Long connote) { // // return connoteRepository.findOne(connote) == null; // // } // // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // }
import javax.servlet.http.HttpServletRequest; import de.codecentric.resilient.connote.service.ConnoteService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.dto.ConnoteDTO;
package de.codecentric.resilient.connote.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/connote") public class ConnoteController { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteController.class);
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java // @Service // public class ConnoteService { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); // // private ConnoteRepository connoteRepository; // // private final RandomConnoteGenerator connoteGenerator; // // @Autowired // public ConnoteService(ConnoteRepository connoteRepository, RandomConnoteGenerator connoteGenerator) { // // this.connoteRepository = connoteRepository; // this.connoteGenerator = connoteGenerator; // } // // public ConnoteDTO createConnote() { // // Long nextConnote; // // do { // nextConnote = connoteGenerator.randomNumber(); // // } while (!isUnique(nextConnote)); // // Connote connoteSaved = createConnote(nextConnote); // // ConnoteDTO connoteDTO = new ConnoteDTO(); // connoteDTO.setConnote(connoteSaved.getConnote()); // // return connoteDTO; // // } // // private Connote createConnote(Long connote) { // // Connote connoteSaved = connoteRepository.save(new Connote(connote)); // // LOGGER.debug(LOGGER.isDebugEnabled() ? "Saved new Connote entity: " + connoteSaved.getConnote() : null); // // return connoteSaved; // } // // private boolean isUnique(Long connote) { // // return connoteRepository.findOne(connote) == null; // // } // // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // Path: connote-service/src/main/java/de/codecentric/resilient/connote/rest/ConnoteController.java import javax.servlet.http.HttpServletRequest; import de.codecentric.resilient.connote.service.ConnoteService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.dto.ConnoteDTO; package de.codecentric.resilient.connote.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/connote") public class ConnoteController { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteController.class);
private ConnoteService connoteService;
MrBW/resilient-transport-service
connote-service/src/main/java/de/codecentric/resilient/connote/rest/ConnoteController.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java // @Service // public class ConnoteService { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); // // private ConnoteRepository connoteRepository; // // private final RandomConnoteGenerator connoteGenerator; // // @Autowired // public ConnoteService(ConnoteRepository connoteRepository, RandomConnoteGenerator connoteGenerator) { // // this.connoteRepository = connoteRepository; // this.connoteGenerator = connoteGenerator; // } // // public ConnoteDTO createConnote() { // // Long nextConnote; // // do { // nextConnote = connoteGenerator.randomNumber(); // // } while (!isUnique(nextConnote)); // // Connote connoteSaved = createConnote(nextConnote); // // ConnoteDTO connoteDTO = new ConnoteDTO(); // connoteDTO.setConnote(connoteSaved.getConnote()); // // return connoteDTO; // // } // // private Connote createConnote(Long connote) { // // Connote connoteSaved = connoteRepository.save(new Connote(connote)); // // LOGGER.debug(LOGGER.isDebugEnabled() ? "Saved new Connote entity: " + connoteSaved.getConnote() : null); // // return connoteSaved; // } // // private boolean isUnique(Long connote) { // // return connoteRepository.findOne(connote) == null; // // } // // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // }
import javax.servlet.http.HttpServletRequest; import de.codecentric.resilient.connote.service.ConnoteService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.dto.ConnoteDTO;
package de.codecentric.resilient.connote.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/connote") public class ConnoteController { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteController.class); private ConnoteService connoteService; private final Tracer tracer; @Autowired public ConnoteController(ConnoteService connoteService, Tracer tracer) { this.connoteService = connoteService; this.tracer = tracer; } @RequestMapping("create")
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/service/ConnoteService.java // @Service // public class ConnoteService { // // private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteService.class); // // private ConnoteRepository connoteRepository; // // private final RandomConnoteGenerator connoteGenerator; // // @Autowired // public ConnoteService(ConnoteRepository connoteRepository, RandomConnoteGenerator connoteGenerator) { // // this.connoteRepository = connoteRepository; // this.connoteGenerator = connoteGenerator; // } // // public ConnoteDTO createConnote() { // // Long nextConnote; // // do { // nextConnote = connoteGenerator.randomNumber(); // // } while (!isUnique(nextConnote)); // // Connote connoteSaved = createConnote(nextConnote); // // ConnoteDTO connoteDTO = new ConnoteDTO(); // connoteDTO.setConnote(connoteSaved.getConnote()); // // return connoteDTO; // // } // // private Connote createConnote(Long connote) { // // Connote connoteSaved = connoteRepository.save(new Connote(connote)); // // LOGGER.debug(LOGGER.isDebugEnabled() ? "Saved new Connote entity: " + connoteSaved.getConnote() : null); // // return connoteSaved; // } // // private boolean isUnique(Long connote) { // // return connoteRepository.findOne(connote) == null; // // } // // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // Path: connote-service/src/main/java/de/codecentric/resilient/connote/rest/ConnoteController.java import javax.servlet.http.HttpServletRequest; import de.codecentric.resilient.connote.service.ConnoteService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.dto.ConnoteDTO; package de.codecentric.resilient.connote.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/connote") public class ConnoteController { private static final Logger LOGGER = LoggerFactory.getLogger(ConnoteController.class); private ConnoteService connoteService; private final Tracer tracer; @Autowired public ConnoteController(ConnoteService connoteService, Tracer tracer) { this.connoteService = connoteService; this.tracer = tracer; } @RequestMapping("create")
public ConnoteDTO createDefault(HttpServletRequest request) {
MrBW/resilient-transport-service
address-service/src/main/java/de/codecentric/resilient/address/AddressServiceApplication.java
// Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // }
import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.address.repository.AddressRepository; import de.codecentric.resilient.configuration.DefautConfiguration;
package de.codecentric.resilient.address; /** * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication
// Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // } // Path: address-service/src/main/java/de/codecentric/resilient/address/AddressServiceApplication.java import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.address.repository.AddressRepository; import de.codecentric.resilient.configuration.DefautConfiguration; package de.codecentric.resilient.address; /** * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication
@Import(DefautConfiguration.class)
MrBW/resilient-transport-service
address-service/src/main/java/de/codecentric/resilient/address/AddressServiceApplication.java
// Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // }
import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.address.repository.AddressRepository; import de.codecentric.resilient.configuration.DefautConfiguration;
package de.codecentric.resilient.address; /** * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication @Import(DefautConfiguration.class) @EntityScan(basePackageClasses = {AddressServiceApplication.class, Jsr310JpaConverters.class}) public class AddressServiceApplication { @Bean public Sampler sampler() { return new AlwaysSampler(); } private static final Logger log = LoggerFactory.getLogger(AddressServiceApplication.class); public static void main(String[] args) { SpringApplication.run(AddressServiceApplication.class, args); } @Bean
// Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // } // Path: address-service/src/main/java/de/codecentric/resilient/address/AddressServiceApplication.java import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.address.repository.AddressRepository; import de.codecentric.resilient.configuration.DefautConfiguration; package de.codecentric.resilient.address; /** * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication @Import(DefautConfiguration.class) @EntityScan(basePackageClasses = {AddressServiceApplication.class, Jsr310JpaConverters.class}) public class AddressServiceApplication { @Bean public Sampler sampler() { return new AlwaysSampler(); } private static final Logger log = LoggerFactory.getLogger(AddressServiceApplication.class); public static void main(String[] args) { SpringApplication.run(AddressServiceApplication.class, args); } @Bean
public CommandLineRunner demo(AddressRepository repository) {
MrBW/resilient-transport-service
address-service/src/main/java/de/codecentric/resilient/address/AddressServiceApplication.java
// Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // }
import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.address.repository.AddressRepository; import de.codecentric.resilient.configuration.DefautConfiguration;
package de.codecentric.resilient.address; /** * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication @Import(DefautConfiguration.class) @EntityScan(basePackageClasses = {AddressServiceApplication.class, Jsr310JpaConverters.class}) public class AddressServiceApplication { @Bean public Sampler sampler() { return new AlwaysSampler(); } private static final Logger log = LoggerFactory.getLogger(AddressServiceApplication.class); public static void main(String[] args) { SpringApplication.run(AddressServiceApplication.class, args); } @Bean public CommandLineRunner demo(AddressRepository repository) { return (args) -> {
// Path: address-service/src/main/java/de/codecentric/resilient/address/entity/Address.java // @Entity // public class Address { // // @Id // @GeneratedValue // private Long id; // // private String country; // // private String city; // // private String postcode; // // private String street; // // private String streetNumber; // // public Address() { // } // // /*** // * // * @param country // * @param city // * @param postcode // * @param street // * @param streetNumber // */ // public Address(String country, String city, String postcode, String street, String streetNumber) { // this.country = country; // this.city = city; // this.postcode = postcode; // this.street = street; // this.streetNumber = streetNumber; // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: address-service/src/main/java/de/codecentric/resilient/address/repository/AddressRepository.java // public interface AddressRepository extends CrudRepository<Address, Long>, QueryByExampleExecutor<Address> { // // } // // Path: service-library/src/main/java/de/codecentric/resilient/configuration/DefautConfiguration.java // @Configuration // public class DefautConfiguration { // // private static final Logger LOGGER = LoggerFactory.getLogger(DefautConfiguration.class); // // @RefreshScope // @Bean // public AbstractConfiguration archaiusConfiguration() throws Exception { // // LOGGER.info("Enable Archaius Configuration"); // ConcurrentMapConfiguration concurrentMapConfiguration = new ConcurrentMapConfiguration(); // // return concurrentMapConfiguration; // } // // @LoadBalanced // @Bean // RestTemplate restTemplate() { // return new RestTemplate(); // } // // } // Path: address-service/src/main/java/de/codecentric/resilient/address/AddressServiceApplication.java import de.mrbw.chaos.monkey.EnableChaosMonkey; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.boot.CommandLineRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.cloud.sleuth.Sampler; import org.springframework.cloud.sleuth.sampler.AlwaysSampler; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters; import de.codecentric.resilient.address.entity.Address; import de.codecentric.resilient.address.repository.AddressRepository; import de.codecentric.resilient.configuration.DefautConfiguration; package de.codecentric.resilient.address; /** * @author Benjamin Wilms */ @EnableChaosMonkey @EnableDiscoveryClient @EnableAutoConfiguration @RefreshScope @SpringBootApplication @Import(DefautConfiguration.class) @EntityScan(basePackageClasses = {AddressServiceApplication.class, Jsr310JpaConverters.class}) public class AddressServiceApplication { @Bean public Sampler sampler() { return new AlwaysSampler(); } private static final Logger log = LoggerFactory.getLogger(AddressServiceApplication.class); public static void main(String[] args) { SpringApplication.run(AddressServiceApplication.class, args); } @Bean public CommandLineRunner demo(AddressRepository repository) { return (args) -> {
repository.save(new Address("DE", "Solingen", "42697", "Hochstrasse", "11"));
MrBW/resilient-transport-service
booking-service/src/test/java/de/codecentric/resilient/booking/rest/BookingControllerTest.java
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/service/BookingService.java // @Service // public class BookingService { // // private static final Logger LOGGER = LoggerFactory.getLogger(BookingService.class); // // private final BookingRepository bookingRepository; // // private final BookingMapper bookingMapper; // // private final RestTemplate restTemplate; // // private DynamicBooleanProperty secondServiceCallEnabled = // DynamicPropertyFactory.getInstance().getBooleanProperty("second.service.call", false); // // @Autowired // public BookingService(BookingRepository bookingRepository, BookingMapper bookingMapper, RestTemplate restTemplate) { // this.bookingRepository = bookingRepository; // this.bookingMapper = bookingMapper; // this.restTemplate = restTemplate; // } // // public BookingServiceResponseDTO createBooking(BookingServiceRequestDTO bookingRequestDTO) { // // BookingServiceResponseDTO bookingResponseDTO = new BookingServiceResponseDTO(); // // // 1.) Create connote // ConnoteDTO connoteDTO = receiveConnote(); // // if (connoteDTO.isFallback()) { // bookingResponseDTO.setErrorMsg("Connote error: " + connoteDTO.getErrorMsg()); // bookingResponseDTO.setStatus("ERROR"); // return bookingResponseDTO; // } // // // 2. Save booking request // // Booking booking = bookingMapper.mapToBookingEntity(bookingRequestDTO, connoteDTO.getConnote()); // bookingRepository.save(booking); // // CustomerResponseDTO customerDTO = bookingRequestDTO.getCustomerDTO(); // bookingResponseDTO.setCustomerDTO(new CustomerDTO(customerDTO.getCustomerId(), customerDTO.getCustomerName())); // bookingResponseDTO.setConnoteDTO(connoteDTO); // bookingResponseDTO.setStatus("OK"); // // return bookingResponseDTO; // // } // // private ConnoteDTO receiveConnote() { // LOGGER.debug("Starting getConnote"); // // return new ConnoteCommand(restTemplate, secondServiceCallEnabled.get()).execute(); // } // }
import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import de.codecentric.resilient.booking.service.BookingService; import de.codecentric.resilient.dto.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper;
package de.codecentric.resilient.booking.rest; /** * @author Benjamin Wilms (xd98870) */ @RunWith(MockitoJUnitRunner.class) public class BookingControllerTest { @Test public void create1() throws Exception { } private MockMvc mockMvc; @Mock
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/service/BookingService.java // @Service // public class BookingService { // // private static final Logger LOGGER = LoggerFactory.getLogger(BookingService.class); // // private final BookingRepository bookingRepository; // // private final BookingMapper bookingMapper; // // private final RestTemplate restTemplate; // // private DynamicBooleanProperty secondServiceCallEnabled = // DynamicPropertyFactory.getInstance().getBooleanProperty("second.service.call", false); // // @Autowired // public BookingService(BookingRepository bookingRepository, BookingMapper bookingMapper, RestTemplate restTemplate) { // this.bookingRepository = bookingRepository; // this.bookingMapper = bookingMapper; // this.restTemplate = restTemplate; // } // // public BookingServiceResponseDTO createBooking(BookingServiceRequestDTO bookingRequestDTO) { // // BookingServiceResponseDTO bookingResponseDTO = new BookingServiceResponseDTO(); // // // 1.) Create connote // ConnoteDTO connoteDTO = receiveConnote(); // // if (connoteDTO.isFallback()) { // bookingResponseDTO.setErrorMsg("Connote error: " + connoteDTO.getErrorMsg()); // bookingResponseDTO.setStatus("ERROR"); // return bookingResponseDTO; // } // // // 2. Save booking request // // Booking booking = bookingMapper.mapToBookingEntity(bookingRequestDTO, connoteDTO.getConnote()); // bookingRepository.save(booking); // // CustomerResponseDTO customerDTO = bookingRequestDTO.getCustomerDTO(); // bookingResponseDTO.setCustomerDTO(new CustomerDTO(customerDTO.getCustomerId(), customerDTO.getCustomerName())); // bookingResponseDTO.setConnoteDTO(connoteDTO); // bookingResponseDTO.setStatus("OK"); // // return bookingResponseDTO; // // } // // private ConnoteDTO receiveConnote() { // LOGGER.debug("Starting getConnote"); // // return new ConnoteCommand(restTemplate, secondServiceCallEnabled.get()).execute(); // } // } // Path: booking-service/src/test/java/de/codecentric/resilient/booking/rest/BookingControllerTest.java import static org.mockito.Mockito.when; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import de.codecentric.resilient.booking.service.BookingService; import de.codecentric.resilient.dto.*; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.setup.MockMvcBuilders; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; package de.codecentric.resilient.booking.rest; /** * @author Benjamin Wilms (xd98870) */ @RunWith(MockitoJUnitRunner.class) public class BookingControllerTest { @Test public void create1() throws Exception { } private MockMvc mockMvc; @Mock
private BookingService bookingServiceMock;
MrBW/resilient-transport-service
customer-service/src/main/java/de/codecentric/resilient/customer/rest/CustomerController.java
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java // @Service // public class CustomerService { // // private final CustomerRepository customerRepository; // // @Autowired // public CustomerService(CustomerRepository customerRepository) { // // this.customerRepository = customerRepository; // } // // public Customer findCustomerById(Long customerId) throws CustomerNotFoundException { // // Customer customer = null; // try { // customer = customerRepository.findOne(customerId); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by id: " + customerId, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by id: " + customerId); // } // // return customer; // // } // // public Customer findByName(String name) { // Customer customer; // try { // customer = customerRepository.findByName(name); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by name: " + name, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by name: " + name); // } // // return customer; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/CustomerDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class CustomerDTO { // // @JsonProperty(required = true) // private Long customerId; // // @JsonProperty(required = true) // private String customerName; // // public CustomerDTO(Long customerId, String customerName) { // this.customerId = customerId; // this.customerName = customerName; // } // // public CustomerDTO() { // // } // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("CustomerDTO{"); // sb.append("customerId=").append(customerId); // sb.append(", customerName='").append(customerName).append('\''); // sb.append('}'); // return sb.toString(); // } // }
import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.service.CustomerService; import de.codecentric.resilient.dto.CustomerDTO;
package de.codecentric.resilient.customer.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/customer") public class CustomerController {
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java // @Service // public class CustomerService { // // private final CustomerRepository customerRepository; // // @Autowired // public CustomerService(CustomerRepository customerRepository) { // // this.customerRepository = customerRepository; // } // // public Customer findCustomerById(Long customerId) throws CustomerNotFoundException { // // Customer customer = null; // try { // customer = customerRepository.findOne(customerId); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by id: " + customerId, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by id: " + customerId); // } // // return customer; // // } // // public Customer findByName(String name) { // Customer customer; // try { // customer = customerRepository.findByName(name); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by name: " + name, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by name: " + name); // } // // return customer; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/CustomerDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class CustomerDTO { // // @JsonProperty(required = true) // private Long customerId; // // @JsonProperty(required = true) // private String customerName; // // public CustomerDTO(Long customerId, String customerName) { // this.customerId = customerId; // this.customerName = customerName; // } // // public CustomerDTO() { // // } // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("CustomerDTO{"); // sb.append("customerId=").append(customerId); // sb.append(", customerName='").append(customerName).append('\''); // sb.append('}'); // return sb.toString(); // } // } // Path: customer-service/src/main/java/de/codecentric/resilient/customer/rest/CustomerController.java import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.service.CustomerService; import de.codecentric.resilient.dto.CustomerDTO; package de.codecentric.resilient.customer.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/customer") public class CustomerController {
private final CustomerService customerService;
MrBW/resilient-transport-service
customer-service/src/main/java/de/codecentric/resilient/customer/rest/CustomerController.java
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java // @Service // public class CustomerService { // // private final CustomerRepository customerRepository; // // @Autowired // public CustomerService(CustomerRepository customerRepository) { // // this.customerRepository = customerRepository; // } // // public Customer findCustomerById(Long customerId) throws CustomerNotFoundException { // // Customer customer = null; // try { // customer = customerRepository.findOne(customerId); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by id: " + customerId, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by id: " + customerId); // } // // return customer; // // } // // public Customer findByName(String name) { // Customer customer; // try { // customer = customerRepository.findByName(name); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by name: " + name, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by name: " + name); // } // // return customer; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/CustomerDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class CustomerDTO { // // @JsonProperty(required = true) // private Long customerId; // // @JsonProperty(required = true) // private String customerName; // // public CustomerDTO(Long customerId, String customerName) { // this.customerId = customerId; // this.customerName = customerName; // } // // public CustomerDTO() { // // } // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("CustomerDTO{"); // sb.append("customerId=").append(customerId); // sb.append(", customerName='").append(customerName).append('\''); // sb.append('}'); // return sb.toString(); // } // }
import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.service.CustomerService; import de.codecentric.resilient.dto.CustomerDTO;
package de.codecentric.resilient.customer.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/customer") public class CustomerController { private final CustomerService customerService; private final Tracer tracer; @Autowired public CustomerController(CustomerService customerService, Tracer tracer) { this.customerService = customerService; this.tracer = tracer; } @RequestMapping(value = "search/id") @ResponseBody
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java // @Service // public class CustomerService { // // private final CustomerRepository customerRepository; // // @Autowired // public CustomerService(CustomerRepository customerRepository) { // // this.customerRepository = customerRepository; // } // // public Customer findCustomerById(Long customerId) throws CustomerNotFoundException { // // Customer customer = null; // try { // customer = customerRepository.findOne(customerId); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by id: " + customerId, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by id: " + customerId); // } // // return customer; // // } // // public Customer findByName(String name) { // Customer customer; // try { // customer = customerRepository.findByName(name); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by name: " + name, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by name: " + name); // } // // return customer; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/CustomerDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class CustomerDTO { // // @JsonProperty(required = true) // private Long customerId; // // @JsonProperty(required = true) // private String customerName; // // public CustomerDTO(Long customerId, String customerName) { // this.customerId = customerId; // this.customerName = customerName; // } // // public CustomerDTO() { // // } // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("CustomerDTO{"); // sb.append("customerId=").append(customerId); // sb.append(", customerName='").append(customerName).append('\''); // sb.append('}'); // return sb.toString(); // } // } // Path: customer-service/src/main/java/de/codecentric/resilient/customer/rest/CustomerController.java import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.service.CustomerService; import de.codecentric.resilient.dto.CustomerDTO; package de.codecentric.resilient.customer.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/customer") public class CustomerController { private final CustomerService customerService; private final Tracer tracer; @Autowired public CustomerController(CustomerService customerService, Tracer tracer) { this.customerService = customerService; this.tracer = tracer; } @RequestMapping(value = "search/id") @ResponseBody
public ResponseEntity<CustomerDTO> searchById(@RequestParam("customerId") Long customerId, HttpServletRequest request) {
MrBW/resilient-transport-service
customer-service/src/main/java/de/codecentric/resilient/customer/rest/CustomerController.java
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java // @Service // public class CustomerService { // // private final CustomerRepository customerRepository; // // @Autowired // public CustomerService(CustomerRepository customerRepository) { // // this.customerRepository = customerRepository; // } // // public Customer findCustomerById(Long customerId) throws CustomerNotFoundException { // // Customer customer = null; // try { // customer = customerRepository.findOne(customerId); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by id: " + customerId, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by id: " + customerId); // } // // return customer; // // } // // public Customer findByName(String name) { // Customer customer; // try { // customer = customerRepository.findByName(name); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by name: " + name, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by name: " + name); // } // // return customer; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/CustomerDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class CustomerDTO { // // @JsonProperty(required = true) // private Long customerId; // // @JsonProperty(required = true) // private String customerName; // // public CustomerDTO(Long customerId, String customerName) { // this.customerId = customerId; // this.customerName = customerName; // } // // public CustomerDTO() { // // } // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("CustomerDTO{"); // sb.append("customerId=").append(customerId); // sb.append(", customerName='").append(customerName).append('\''); // sb.append('}'); // return sb.toString(); // } // }
import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.service.CustomerService; import de.codecentric.resilient.dto.CustomerDTO;
package de.codecentric.resilient.customer.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/customer") public class CustomerController { private final CustomerService customerService; private final Tracer tracer; @Autowired public CustomerController(CustomerService customerService, Tracer tracer) { this.customerService = customerService; this.tracer = tracer; } @RequestMapping(value = "search/id") @ResponseBody public ResponseEntity<CustomerDTO> searchById(@RequestParam("customerId") Long customerId, HttpServletRequest request) {
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java // @Service // public class CustomerService { // // private final CustomerRepository customerRepository; // // @Autowired // public CustomerService(CustomerRepository customerRepository) { // // this.customerRepository = customerRepository; // } // // public Customer findCustomerById(Long customerId) throws CustomerNotFoundException { // // Customer customer = null; // try { // customer = customerRepository.findOne(customerId); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by id: " + customerId, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by id: " + customerId); // } // // return customer; // // } // // public Customer findByName(String name) { // Customer customer; // try { // customer = customerRepository.findByName(name); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by name: " + name, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by name: " + name); // } // // return customer; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/CustomerDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class CustomerDTO { // // @JsonProperty(required = true) // private Long customerId; // // @JsonProperty(required = true) // private String customerName; // // public CustomerDTO(Long customerId, String customerName) { // this.customerId = customerId; // this.customerName = customerName; // } // // public CustomerDTO() { // // } // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("CustomerDTO{"); // sb.append("customerId=").append(customerId); // sb.append(", customerName='").append(customerName).append('\''); // sb.append('}'); // return sb.toString(); // } // } // Path: customer-service/src/main/java/de/codecentric/resilient/customer/rest/CustomerController.java import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.service.CustomerService; import de.codecentric.resilient.dto.CustomerDTO; package de.codecentric.resilient.customer.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/customer") public class CustomerController { private final CustomerService customerService; private final Tracer tracer; @Autowired public CustomerController(CustomerService customerService, Tracer tracer) { this.customerService = customerService; this.tracer = tracer; } @RequestMapping(value = "search/id") @ResponseBody public ResponseEntity<CustomerDTO> searchById(@RequestParam("customerId") Long customerId, HttpServletRequest request) {
Customer customer;
MrBW/resilient-transport-service
customer-service/src/main/java/de/codecentric/resilient/customer/rest/CustomerController.java
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java // @Service // public class CustomerService { // // private final CustomerRepository customerRepository; // // @Autowired // public CustomerService(CustomerRepository customerRepository) { // // this.customerRepository = customerRepository; // } // // public Customer findCustomerById(Long customerId) throws CustomerNotFoundException { // // Customer customer = null; // try { // customer = customerRepository.findOne(customerId); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by id: " + customerId, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by id: " + customerId); // } // // return customer; // // } // // public Customer findByName(String name) { // Customer customer; // try { // customer = customerRepository.findByName(name); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by name: " + name, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by name: " + name); // } // // return customer; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/CustomerDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class CustomerDTO { // // @JsonProperty(required = true) // private Long customerId; // // @JsonProperty(required = true) // private String customerName; // // public CustomerDTO(Long customerId, String customerName) { // this.customerId = customerId; // this.customerName = customerName; // } // // public CustomerDTO() { // // } // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("CustomerDTO{"); // sb.append("customerId=").append(customerId); // sb.append(", customerName='").append(customerName).append('\''); // sb.append('}'); // return sb.toString(); // } // }
import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.service.CustomerService; import de.codecentric.resilient.dto.CustomerDTO;
package de.codecentric.resilient.customer.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/customer") public class CustomerController { private final CustomerService customerService; private final Tracer tracer; @Autowired public CustomerController(CustomerService customerService, Tracer tracer) { this.customerService = customerService; this.tracer = tracer; } @RequestMapping(value = "search/id") @ResponseBody public ResponseEntity<CustomerDTO> searchById(@RequestParam("customerId") Long customerId, HttpServletRequest request) { Customer customer; try { customer = customerService.findCustomerById(customerId);
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java // @Service // public class CustomerService { // // private final CustomerRepository customerRepository; // // @Autowired // public CustomerService(CustomerRepository customerRepository) { // // this.customerRepository = customerRepository; // } // // public Customer findCustomerById(Long customerId) throws CustomerNotFoundException { // // Customer customer = null; // try { // customer = customerRepository.findOne(customerId); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by id: " + customerId, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by id: " + customerId); // } // // return customer; // // } // // public Customer findByName(String name) { // Customer customer; // try { // customer = customerRepository.findByName(name); // // } catch (Exception e) { // throw new CustomerNotFoundException("Error by finding customer by name: " + name, e); // } // // if (customer == null) { // throw new CustomerNotFoundException("Customer not found by name: " + name); // } // // return customer; // } // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/CustomerDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class CustomerDTO { // // @JsonProperty(required = true) // private Long customerId; // // @JsonProperty(required = true) // private String customerName; // // public CustomerDTO(Long customerId, String customerName) { // this.customerId = customerId; // this.customerName = customerName; // } // // public CustomerDTO() { // // } // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // // @Override // public String toString() { // final StringBuilder sb = new StringBuilder("CustomerDTO{"); // sb.append("customerId=").append(customerId); // sb.append(", customerName='").append(customerName).append('\''); // sb.append('}'); // return sb.toString(); // } // } // Path: customer-service/src/main/java/de/codecentric/resilient/customer/rest/CustomerController.java import javax.servlet.http.HttpServletRequest; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.sleuth.Span; import org.springframework.cloud.sleuth.Tracer; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.RestController; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.service.CustomerService; import de.codecentric.resilient.dto.CustomerDTO; package de.codecentric.resilient.customer.rest; /** * @author Benjamin Wilms */ @RestController @RequestMapping("rest/customer") public class CustomerController { private final CustomerService customerService; private final Tracer tracer; @Autowired public CustomerController(CustomerService customerService, Tracer tracer) { this.customerService = customerService; this.tracer = tracer; } @RequestMapping(value = "search/id") @ResponseBody public ResponseEntity<CustomerDTO> searchById(@RequestParam("customerId") Long customerId, HttpServletRequest request) { Customer customer; try { customer = customerService.findCustomerById(customerId);
} catch (CustomerNotFoundException e) {
MrBW/resilient-transport-service
customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java // public interface CustomerRepository extends CrudRepository<Customer, Long> { // Customer findByName(String name); // }
import org.springframework.beans.factory.annotation.Autowired; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.repository.CustomerRepository; import org.springframework.stereotype.Service;
package de.codecentric.resilient.customer.service; /** * @author Benjamin Wilms */ @Service public class CustomerService {
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java // public interface CustomerRepository extends CrudRepository<Customer, Long> { // Customer findByName(String name); // } // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java import org.springframework.beans.factory.annotation.Autowired; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.repository.CustomerRepository; import org.springframework.stereotype.Service; package de.codecentric.resilient.customer.service; /** * @author Benjamin Wilms */ @Service public class CustomerService {
private final CustomerRepository customerRepository;
MrBW/resilient-transport-service
customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java // public interface CustomerRepository extends CrudRepository<Customer, Long> { // Customer findByName(String name); // }
import org.springframework.beans.factory.annotation.Autowired; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.repository.CustomerRepository; import org.springframework.stereotype.Service;
package de.codecentric.resilient.customer.service; /** * @author Benjamin Wilms */ @Service public class CustomerService { private final CustomerRepository customerRepository; @Autowired public CustomerService(CustomerRepository customerRepository) { this.customerRepository = customerRepository; }
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java // public interface CustomerRepository extends CrudRepository<Customer, Long> { // Customer findByName(String name); // } // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java import org.springframework.beans.factory.annotation.Autowired; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.repository.CustomerRepository; import org.springframework.stereotype.Service; package de.codecentric.resilient.customer.service; /** * @author Benjamin Wilms */ @Service public class CustomerService { private final CustomerRepository customerRepository; @Autowired public CustomerService(CustomerRepository customerRepository) { this.customerRepository = customerRepository; }
public Customer findCustomerById(Long customerId) throws CustomerNotFoundException {
MrBW/resilient-transport-service
customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java // public interface CustomerRepository extends CrudRepository<Customer, Long> { // Customer findByName(String name); // }
import org.springframework.beans.factory.annotation.Autowired; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.repository.CustomerRepository; import org.springframework.stereotype.Service;
package de.codecentric.resilient.customer.service; /** * @author Benjamin Wilms */ @Service public class CustomerService { private final CustomerRepository customerRepository; @Autowired public CustomerService(CustomerRepository customerRepository) { this.customerRepository = customerRepository; }
// Path: customer-service/src/main/java/de/codecentric/resilient/customer/entity/Customer.java // @Entity // public class Customer { // // @Id // @GeneratedValue // private Long id; // // private String name; // // public Customer(String name) { // this.name = name; // } // // public Customer() { // } // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/exception/CustomerNotFoundException.java // public class CustomerNotFoundException extends RuntimeException { // public CustomerNotFoundException(String message) { // super(message); // } // // public CustomerNotFoundException(String message, Throwable cause) { // super(message, cause); // } // } // // Path: customer-service/src/main/java/de/codecentric/resilient/customer/repository/CustomerRepository.java // public interface CustomerRepository extends CrudRepository<Customer, Long> { // Customer findByName(String name); // } // Path: customer-service/src/main/java/de/codecentric/resilient/customer/service/CustomerService.java import org.springframework.beans.factory.annotation.Autowired; import de.codecentric.resilient.customer.entity.Customer; import de.codecentric.resilient.customer.exception.CustomerNotFoundException; import de.codecentric.resilient.customer.repository.CustomerRepository; import org.springframework.stereotype.Service; package de.codecentric.resilient.customer.service; /** * @author Benjamin Wilms */ @Service public class CustomerService { private final CustomerRepository customerRepository; @Autowired public CustomerService(CustomerRepository customerRepository) { this.customerRepository = customerRepository; }
public Customer findCustomerById(Long customerId) throws CustomerNotFoundException {
MrBW/resilient-transport-service
booking-service/src/main/java/de/codecentric/resilient/booking/mapper/BookingMapper.java
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java // @Embeddable // public class Address { // // @Basic // private String country; // // @Basic // private String city; // // @Basic // private String postcode; // // @Basic // private String street; // // @Basic // private String streetNumber; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java // @Entity // public class Booking { // // @Id // @GeneratedValue // private Long id; // // @Embedded // private Customer customer; // // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="receiverStreet")), // @AttributeOverride(name="city",column=@Column(name="receiverCity")), // @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")), // @AttributeOverride(name="country",column=@Column(name="receiverCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber")) // }) // private Address receiverAddress; // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="senderStreet")), // @AttributeOverride(name="city",column=@Column(name="senderCity")), // @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")), // @AttributeOverride(name="country",column=@Column(name="senderCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber")) // }) // private Address senderAddress; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Customer getCustomer() { // return customer; // } // // public void setCustomer(Customer customer) { // this.customer = customer; // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public Address getReceiverAddress() { // return receiverAddress; // } // // public void setReceiverAddress(Address receiverAddress) { // this.receiverAddress = receiverAddress; // } // // public Address getSenderAddress() { // return senderAddress; // } // // public void setSenderAddress(Address senderAddress) { // this.senderAddress = senderAddress; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java // @Embeddable // public class Customer { // // private Long customerId; // // private String customerName; // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // }
import de.codecentric.resilient.dto.*; import org.springframework.stereotype.Component; import de.codecentric.resilient.booking.entity.Address; import de.codecentric.resilient.booking.entity.Booking; import de.codecentric.resilient.booking.entity.Customer;
package de.codecentric.resilient.booking.mapper; /** * @author Benjamin Wilms (xd98870) */ @Component public class BookingMapper {
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java // @Embeddable // public class Address { // // @Basic // private String country; // // @Basic // private String city; // // @Basic // private String postcode; // // @Basic // private String street; // // @Basic // private String streetNumber; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java // @Entity // public class Booking { // // @Id // @GeneratedValue // private Long id; // // @Embedded // private Customer customer; // // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="receiverStreet")), // @AttributeOverride(name="city",column=@Column(name="receiverCity")), // @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")), // @AttributeOverride(name="country",column=@Column(name="receiverCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber")) // }) // private Address receiverAddress; // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="senderStreet")), // @AttributeOverride(name="city",column=@Column(name="senderCity")), // @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")), // @AttributeOverride(name="country",column=@Column(name="senderCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber")) // }) // private Address senderAddress; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Customer getCustomer() { // return customer; // } // // public void setCustomer(Customer customer) { // this.customer = customer; // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public Address getReceiverAddress() { // return receiverAddress; // } // // public void setReceiverAddress(Address receiverAddress) { // this.receiverAddress = receiverAddress; // } // // public Address getSenderAddress() { // return senderAddress; // } // // public void setSenderAddress(Address senderAddress) { // this.senderAddress = senderAddress; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java // @Embeddable // public class Customer { // // private Long customerId; // // private String customerName; // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // } // Path: booking-service/src/main/java/de/codecentric/resilient/booking/mapper/BookingMapper.java import de.codecentric.resilient.dto.*; import org.springframework.stereotype.Component; import de.codecentric.resilient.booking.entity.Address; import de.codecentric.resilient.booking.entity.Booking; import de.codecentric.resilient.booking.entity.Customer; package de.codecentric.resilient.booking.mapper; /** * @author Benjamin Wilms (xd98870) */ @Component public class BookingMapper {
public Booking mapToBookingEntity(BookingServiceRequestDTO bookingRequestDTO, Long connote) {
MrBW/resilient-transport-service
booking-service/src/main/java/de/codecentric/resilient/booking/mapper/BookingMapper.java
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java // @Embeddable // public class Address { // // @Basic // private String country; // // @Basic // private String city; // // @Basic // private String postcode; // // @Basic // private String street; // // @Basic // private String streetNumber; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java // @Entity // public class Booking { // // @Id // @GeneratedValue // private Long id; // // @Embedded // private Customer customer; // // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="receiverStreet")), // @AttributeOverride(name="city",column=@Column(name="receiverCity")), // @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")), // @AttributeOverride(name="country",column=@Column(name="receiverCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber")) // }) // private Address receiverAddress; // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="senderStreet")), // @AttributeOverride(name="city",column=@Column(name="senderCity")), // @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")), // @AttributeOverride(name="country",column=@Column(name="senderCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber")) // }) // private Address senderAddress; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Customer getCustomer() { // return customer; // } // // public void setCustomer(Customer customer) { // this.customer = customer; // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public Address getReceiverAddress() { // return receiverAddress; // } // // public void setReceiverAddress(Address receiverAddress) { // this.receiverAddress = receiverAddress; // } // // public Address getSenderAddress() { // return senderAddress; // } // // public void setSenderAddress(Address senderAddress) { // this.senderAddress = senderAddress; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java // @Embeddable // public class Customer { // // private Long customerId; // // private String customerName; // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // }
import de.codecentric.resilient.dto.*; import org.springframework.stereotype.Component; import de.codecentric.resilient.booking.entity.Address; import de.codecentric.resilient.booking.entity.Booking; import de.codecentric.resilient.booking.entity.Customer;
package de.codecentric.resilient.booking.mapper; /** * @author Benjamin Wilms (xd98870) */ @Component public class BookingMapper { public Booking mapToBookingEntity(BookingServiceRequestDTO bookingRequestDTO, Long connote) { Booking booking = new Booking(); booking.setConnote(connote); booking.setReceiverAddress(mapToAddressEntity(bookingRequestDTO.getReceiverAddress())); booking.setSenderAddress(mapToAddressEntity(bookingRequestDTO.getSenderAddress())); booking.setCustomer(mapToCustomer(bookingRequestDTO.getCustomerDTO())); return booking; }
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java // @Embeddable // public class Address { // // @Basic // private String country; // // @Basic // private String city; // // @Basic // private String postcode; // // @Basic // private String street; // // @Basic // private String streetNumber; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java // @Entity // public class Booking { // // @Id // @GeneratedValue // private Long id; // // @Embedded // private Customer customer; // // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="receiverStreet")), // @AttributeOverride(name="city",column=@Column(name="receiverCity")), // @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")), // @AttributeOverride(name="country",column=@Column(name="receiverCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber")) // }) // private Address receiverAddress; // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="senderStreet")), // @AttributeOverride(name="city",column=@Column(name="senderCity")), // @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")), // @AttributeOverride(name="country",column=@Column(name="senderCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber")) // }) // private Address senderAddress; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Customer getCustomer() { // return customer; // } // // public void setCustomer(Customer customer) { // this.customer = customer; // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public Address getReceiverAddress() { // return receiverAddress; // } // // public void setReceiverAddress(Address receiverAddress) { // this.receiverAddress = receiverAddress; // } // // public Address getSenderAddress() { // return senderAddress; // } // // public void setSenderAddress(Address senderAddress) { // this.senderAddress = senderAddress; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java // @Embeddable // public class Customer { // // private Long customerId; // // private String customerName; // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // } // Path: booking-service/src/main/java/de/codecentric/resilient/booking/mapper/BookingMapper.java import de.codecentric.resilient.dto.*; import org.springframework.stereotype.Component; import de.codecentric.resilient.booking.entity.Address; import de.codecentric.resilient.booking.entity.Booking; import de.codecentric.resilient.booking.entity.Customer; package de.codecentric.resilient.booking.mapper; /** * @author Benjamin Wilms (xd98870) */ @Component public class BookingMapper { public Booking mapToBookingEntity(BookingServiceRequestDTO bookingRequestDTO, Long connote) { Booking booking = new Booking(); booking.setConnote(connote); booking.setReceiverAddress(mapToAddressEntity(bookingRequestDTO.getReceiverAddress())); booking.setSenderAddress(mapToAddressEntity(bookingRequestDTO.getSenderAddress())); booking.setCustomer(mapToCustomer(bookingRequestDTO.getCustomerDTO())); return booking; }
public Customer mapToCustomer(CustomerResponseDTO customerDTO) {
MrBW/resilient-transport-service
booking-service/src/main/java/de/codecentric/resilient/booking/mapper/BookingMapper.java
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java // @Embeddable // public class Address { // // @Basic // private String country; // // @Basic // private String city; // // @Basic // private String postcode; // // @Basic // private String street; // // @Basic // private String streetNumber; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java // @Entity // public class Booking { // // @Id // @GeneratedValue // private Long id; // // @Embedded // private Customer customer; // // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="receiverStreet")), // @AttributeOverride(name="city",column=@Column(name="receiverCity")), // @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")), // @AttributeOverride(name="country",column=@Column(name="receiverCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber")) // }) // private Address receiverAddress; // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="senderStreet")), // @AttributeOverride(name="city",column=@Column(name="senderCity")), // @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")), // @AttributeOverride(name="country",column=@Column(name="senderCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber")) // }) // private Address senderAddress; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Customer getCustomer() { // return customer; // } // // public void setCustomer(Customer customer) { // this.customer = customer; // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public Address getReceiverAddress() { // return receiverAddress; // } // // public void setReceiverAddress(Address receiverAddress) { // this.receiverAddress = receiverAddress; // } // // public Address getSenderAddress() { // return senderAddress; // } // // public void setSenderAddress(Address senderAddress) { // this.senderAddress = senderAddress; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java // @Embeddable // public class Customer { // // private Long customerId; // // private String customerName; // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // }
import de.codecentric.resilient.dto.*; import org.springframework.stereotype.Component; import de.codecentric.resilient.booking.entity.Address; import de.codecentric.resilient.booking.entity.Booking; import de.codecentric.resilient.booking.entity.Customer;
package de.codecentric.resilient.booking.mapper; /** * @author Benjamin Wilms (xd98870) */ @Component public class BookingMapper { public Booking mapToBookingEntity(BookingServiceRequestDTO bookingRequestDTO, Long connote) { Booking booking = new Booking(); booking.setConnote(connote); booking.setReceiverAddress(mapToAddressEntity(bookingRequestDTO.getReceiverAddress())); booking.setSenderAddress(mapToAddressEntity(bookingRequestDTO.getSenderAddress())); booking.setCustomer(mapToCustomer(bookingRequestDTO.getCustomerDTO())); return booking; } public Customer mapToCustomer(CustomerResponseDTO customerDTO) { Customer customer = new Customer(); customer.setCustomerName(customerDTO.getCustomerName()); customer.setCustomerId(customerDTO.getCustomerId()); return customer; }
// Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Address.java // @Embeddable // public class Address { // // @Basic // private String country; // // @Basic // private String city; // // @Basic // private String postcode; // // @Basic // private String street; // // @Basic // private String streetNumber; // // public String getCountry() { // return country; // } // // public void setCountry(String country) { // this.country = country; // } // // public String getCity() { // return city; // } // // public void setCity(String city) { // this.city = city; // } // // public String getPostcode() { // return postcode; // } // // public void setPostcode(String postcode) { // this.postcode = postcode; // } // // public String getStreet() { // return street; // } // // public void setStreet(String street) { // this.street = street; // } // // public String getStreetNumber() { // return streetNumber; // } // // public void setStreetNumber(String streetNumber) { // this.streetNumber = streetNumber; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Booking.java // @Entity // public class Booking { // // @Id // @GeneratedValue // private Long id; // // @Embedded // private Customer customer; // // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="receiverStreet")), // @AttributeOverride(name="city",column=@Column(name="receiverCity")), // @AttributeOverride(name="postcode",column=@Column(name="receiverPostcode")), // @AttributeOverride(name="country",column=@Column(name="receiverCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="receiverStreeNumber")) // }) // private Address receiverAddress; // // @Embedded // @AttributeOverrides({ // @AttributeOverride(name="street",column=@Column(name="senderStreet")), // @AttributeOverride(name="city",column=@Column(name="senderCity")), // @AttributeOverride(name="postcode",column=@Column(name="senderPostcode")), // @AttributeOverride(name="country",column=@Column(name="senderCountry")), // @AttributeOverride(name="streetNumber",column=@Column(name="senderStreeNumber")) // }) // private Address senderAddress; // // public Long getId() { // return id; // } // // public void setId(Long id) { // this.id = id; // } // // public Customer getCustomer() { // return customer; // } // // public void setCustomer(Customer customer) { // this.customer = customer; // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public Address getReceiverAddress() { // return receiverAddress; // } // // public void setReceiverAddress(Address receiverAddress) { // this.receiverAddress = receiverAddress; // } // // public Address getSenderAddress() { // return senderAddress; // } // // public void setSenderAddress(Address senderAddress) { // this.senderAddress = senderAddress; // } // } // // Path: booking-service/src/main/java/de/codecentric/resilient/booking/entity/Customer.java // @Embeddable // public class Customer { // // private Long customerId; // // private String customerName; // // public Long getCustomerId() { // return customerId; // } // // public void setCustomerId(Long customerId) { // this.customerId = customerId; // } // // public String getCustomerName() { // return customerName; // } // // public void setCustomerName(String customerName) { // this.customerName = customerName; // } // } // Path: booking-service/src/main/java/de/codecentric/resilient/booking/mapper/BookingMapper.java import de.codecentric.resilient.dto.*; import org.springframework.stereotype.Component; import de.codecentric.resilient.booking.entity.Address; import de.codecentric.resilient.booking.entity.Booking; import de.codecentric.resilient.booking.entity.Customer; package de.codecentric.resilient.booking.mapper; /** * @author Benjamin Wilms (xd98870) */ @Component public class BookingMapper { public Booking mapToBookingEntity(BookingServiceRequestDTO bookingRequestDTO, Long connote) { Booking booking = new Booking(); booking.setConnote(connote); booking.setReceiverAddress(mapToAddressEntity(bookingRequestDTO.getReceiverAddress())); booking.setSenderAddress(mapToAddressEntity(bookingRequestDTO.getSenderAddress())); booking.setCustomer(mapToCustomer(bookingRequestDTO.getCustomerDTO())); return booking; } public Customer mapToCustomer(CustomerResponseDTO customerDTO) { Customer customer = new Customer(); customer.setCustomerName(customerDTO.getCustomerName()); customer.setCustomerId(customerDTO.getCustomerId()); return customer; }
public Address mapToAddressEntity(AddressResponseDTO addressDTO) {
MrBW/resilient-transport-service
connote-service/src/test/java/de/codecentric/resilient/connote/service/ConnoteServiceTest.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // }
import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import org.joda.time.LocalDateTime; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import de.codecentric.resilient.dto.ConnoteDTO; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator;
package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms (xd98870) */ @RunWith(MockitoJUnitRunner.class) public class ConnoteServiceTest { @Mock
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // Path: connote-service/src/test/java/de/codecentric/resilient/connote/service/ConnoteServiceTest.java import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import org.joda.time.LocalDateTime; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import de.codecentric.resilient.dto.ConnoteDTO; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms (xd98870) */ @RunWith(MockitoJUnitRunner.class) public class ConnoteServiceTest { @Mock
private ConnoteRepository connoteRepositoryMock;
MrBW/resilient-transport-service
connote-service/src/test/java/de/codecentric/resilient/connote/service/ConnoteServiceTest.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // }
import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import org.joda.time.LocalDateTime; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import de.codecentric.resilient.dto.ConnoteDTO; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator;
package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms (xd98870) */ @RunWith(MockitoJUnitRunner.class) public class ConnoteServiceTest { @Mock private ConnoteRepository connoteRepositoryMock; @Mock
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // Path: connote-service/src/test/java/de/codecentric/resilient/connote/service/ConnoteServiceTest.java import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import org.joda.time.LocalDateTime; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import de.codecentric.resilient.dto.ConnoteDTO; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms (xd98870) */ @RunWith(MockitoJUnitRunner.class) public class ConnoteServiceTest { @Mock private ConnoteRepository connoteRepositoryMock; @Mock
private RandomConnoteGenerator randomConnoteGeneratorMock;
MrBW/resilient-transport-service
connote-service/src/test/java/de/codecentric/resilient/connote/service/ConnoteServiceTest.java
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // }
import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import org.joda.time.LocalDateTime; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import de.codecentric.resilient.dto.ConnoteDTO; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator;
package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms (xd98870) */ @RunWith(MockitoJUnitRunner.class) public class ConnoteServiceTest { @Mock private ConnoteRepository connoteRepositoryMock; @Mock private RandomConnoteGenerator randomConnoteGeneratorMock; private ConnoteService connoteService; @Before public void setUp() throws Exception { connoteService = new ConnoteService(connoteRepositoryMock, randomConnoteGeneratorMock); } @Test public void nextConnote_Goodcase() throws Exception { Long uniqueConnote = 1L;
// Path: connote-service/src/main/java/de/codecentric/resilient/connote/entity/Connote.java // @Entity // public class Connote { // // @Id // private Long connote; // // @Column(name = "created", nullable = false) // private LocalDateTime created = LocalDateTime.now(); // // public Connote(Long connote) { // // this.connote = connote; // } // // public Connote() { // } // // public Long getConnote() { // return connote; // } // // public void setConnote(Long connote) { // this.connote = connote; // } // // public LocalDateTime getCreated() { // return created; // } // // public void setCreated(LocalDateTime created) { // this.created = created; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/repository/ConnoteRepository.java // public interface ConnoteRepository extends CrudRepository<Connote, Long> { // // @Override // Connote save(Connote connote); // } // // Path: service-library/src/main/java/de/codecentric/resilient/dto/ConnoteDTO.java // @JsonInclude(JsonInclude.Include.NON_NULL) // public class ConnoteDTO extends FallbackAbstractDTO { // // @JsonProperty(required = true) // private Long connote; // // public void setConnote(Long connote) { // this.connote = connote; // } // // public Long getConnote() { // return connote; // } // // } // // Path: connote-service/src/main/java/de/codecentric/resilient/connote/utils/RandomConnoteGenerator.java // @Service // @RefreshScope // public class RandomConnoteGenerator { // // // Connote start range // private DynamicLongProperty startRange = // DynamicPropertyFactory.getInstance().getLongProperty("connote.range.start", 1000000); // // // Connote end range // private DynamicLongProperty endRange = DynamicPropertyFactory.getInstance().getLongProperty("connote.range.end", 5000000); // // @Value("${connote.range.start}") // private int connoteStart; // // @Value("${connote.range.end}") // private int connoteEnd; // // public long randomNumber() { // startRange.get(); // endRange.get(); // return RandomUtils.nextLong(connoteStart, connoteEnd); // // //return RandomUtils.nextLong(startRange.get(), endRange.get()); // } // } // Path: connote-service/src/test/java/de/codecentric/resilient/connote/service/ConnoteServiceTest.java import static org.hamcrest.core.Is.is; import static org.junit.Assert.assertThat; import static org.mockito.Matchers.any; import static org.mockito.Mockito.*; import de.codecentric.resilient.connote.entity.Connote; import de.codecentric.resilient.connote.repository.ConnoteRepository; import org.joda.time.LocalDateTime; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.runners.MockitoJUnitRunner; import de.codecentric.resilient.dto.ConnoteDTO; import de.codecentric.resilient.connote.utils.RandomConnoteGenerator; package de.codecentric.resilient.connote.service; /** * @author Benjamin Wilms (xd98870) */ @RunWith(MockitoJUnitRunner.class) public class ConnoteServiceTest { @Mock private ConnoteRepository connoteRepositoryMock; @Mock private RandomConnoteGenerator randomConnoteGeneratorMock; private ConnoteService connoteService; @Before public void setUp() throws Exception { connoteService = new ConnoteService(connoteRepositoryMock, randomConnoteGeneratorMock); } @Test public void nextConnote_Goodcase() throws Exception { Long uniqueConnote = 1L;
Connote connoteToBeSaved = new Connote(uniqueConnote);