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
|
---|---|---|---|---|---|---|
IKCAP/turbosoft
|
reasoner/src/main/java/org/earthcube/geosoft/software/classes/Software.java
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/sn/SNAssumption.java
// public class SNAssumption extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// private String categoryId;
// private String note;
//
// public SNAssumption(String id) {
// super(id);
// }
//
// public String getCategoryId() {
// return categoryId;
// }
//
// public void setCategoryId(String categoryId) {
// this.categoryId = categoryId;
// }
//
// public String getNote() {
// return note;
// }
//
// public void setNote(String note) {
// this.note = note;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/sn/StandardName.java
// public class StandardName extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// private String objectId;
// private String quantityId;
// private ArrayList<String> operatorIds;
// private String internalVariable;
// private String note;
//
// public StandardName(String id) {
// super(id);
// operatorIds = new ArrayList<String>();
// }
//
// public String getObjectId() {
// return objectId;
// }
//
// public void setObjectId(String objectId) {
// this.objectId = objectId;
// }
//
// public String getQuantityId() {
// return quantityId;
// }
//
// public void setQuantityId(String quantityId) {
// this.quantityId = quantityId;
// }
//
// public ArrayList<String> getOperatorIds() {
// return operatorIds;
// }
//
// public void addOperatorId(String operatorId) {
// this.operatorIds.add(operatorId);
// }
//
// public String getInternalVariable() {
// return internalVariable;
// }
//
// public void setInternalVariable(String internalVariable) {
// this.internalVariable = internalVariable;
// }
//
// public String getNote() {
// return note;
// }
//
// public void setNote(String note) {
// this.note = note;
// }
//
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/util/URIEntity.java
// public class URIEntity implements Serializable {
// private static final long serialVersionUID = 1L;
// private URI id;
// private String label;
//
// HashMap<String, Object> provenance;
//
// public URIEntity(String id) {
// setID(id);
// this.provenance = new HashMap<String, Object>();
// }
//
// public URIEntity(String id, String label) {
// setID(id);
// this.label = label;
// this.provenance = new HashMap<String, Object>();
// }
//
// public String getID() {
// if (id != null)
// return id.toString();
// else
// return null;
// }
//
// public void setID(String id) {
// try {
// this.id = new URI(id).normalize();
// } catch (Exception e) {
// System.err.println(id + " Not a URI. Only URIs allowed for IDs");
// }
// }
//
// public String getURL() {
// return this.getNamespace().replaceAll("#$", "");
// }
//
// public String getName() {
// if (id != null)
// return id.getFragment();
// else
// return null;
// }
//
// public String getNamespace() {
// if (id != null)
// return id.getScheme() + ":" + id.getSchemeSpecificPart() + "#";
// else
// return null;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public HashMap<String, Object> getProvenance() {
// return provenance;
// }
//
// public void addProvenance(String propId, Object value) {
// this.provenance.put(propId, value);
// }
//
// public String toString() {
// return getName();
// }
//
// public int hashCode() {
// return id.hashCode();
// }
//
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import org.earthcube.geosoft.software.classes.sn.SNAssumption;
import org.earthcube.geosoft.software.classes.sn.StandardName;
import org.earthcube.geosoft.util.URIEntity;
|
package org.earthcube.geosoft.software.classes;
public class Software extends URIEntity {
private static final long serialVersionUID = 1L;
String classId;
ArrayList<SWPropertyValue> propertyValues;
ArrayList<SoftwareRole> inputs;
ArrayList<SoftwareRole> outputs;
ArrayList<String> explanations;
HashMap<String, String> labels;
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/sn/SNAssumption.java
// public class SNAssumption extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// private String categoryId;
// private String note;
//
// public SNAssumption(String id) {
// super(id);
// }
//
// public String getCategoryId() {
// return categoryId;
// }
//
// public void setCategoryId(String categoryId) {
// this.categoryId = categoryId;
// }
//
// public String getNote() {
// return note;
// }
//
// public void setNote(String note) {
// this.note = note;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/sn/StandardName.java
// public class StandardName extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// private String objectId;
// private String quantityId;
// private ArrayList<String> operatorIds;
// private String internalVariable;
// private String note;
//
// public StandardName(String id) {
// super(id);
// operatorIds = new ArrayList<String>();
// }
//
// public String getObjectId() {
// return objectId;
// }
//
// public void setObjectId(String objectId) {
// this.objectId = objectId;
// }
//
// public String getQuantityId() {
// return quantityId;
// }
//
// public void setQuantityId(String quantityId) {
// this.quantityId = quantityId;
// }
//
// public ArrayList<String> getOperatorIds() {
// return operatorIds;
// }
//
// public void addOperatorId(String operatorId) {
// this.operatorIds.add(operatorId);
// }
//
// public String getInternalVariable() {
// return internalVariable;
// }
//
// public void setInternalVariable(String internalVariable) {
// this.internalVariable = internalVariable;
// }
//
// public String getNote() {
// return note;
// }
//
// public void setNote(String note) {
// this.note = note;
// }
//
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/util/URIEntity.java
// public class URIEntity implements Serializable {
// private static final long serialVersionUID = 1L;
// private URI id;
// private String label;
//
// HashMap<String, Object> provenance;
//
// public URIEntity(String id) {
// setID(id);
// this.provenance = new HashMap<String, Object>();
// }
//
// public URIEntity(String id, String label) {
// setID(id);
// this.label = label;
// this.provenance = new HashMap<String, Object>();
// }
//
// public String getID() {
// if (id != null)
// return id.toString();
// else
// return null;
// }
//
// public void setID(String id) {
// try {
// this.id = new URI(id).normalize();
// } catch (Exception e) {
// System.err.println(id + " Not a URI. Only URIs allowed for IDs");
// }
// }
//
// public String getURL() {
// return this.getNamespace().replaceAll("#$", "");
// }
//
// public String getName() {
// if (id != null)
// return id.getFragment();
// else
// return null;
// }
//
// public String getNamespace() {
// if (id != null)
// return id.getScheme() + ":" + id.getSchemeSpecificPart() + "#";
// else
// return null;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public HashMap<String, Object> getProvenance() {
// return provenance;
// }
//
// public void addProvenance(String propId, Object value) {
// this.provenance.put(propId, value);
// }
//
// public String toString() {
// return getName();
// }
//
// public int hashCode() {
// return id.hashCode();
// }
//
// }
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/Software.java
import java.util.ArrayList;
import java.util.HashMap;
import org.earthcube.geosoft.software.classes.sn.SNAssumption;
import org.earthcube.geosoft.software.classes.sn.StandardName;
import org.earthcube.geosoft.util.URIEntity;
package org.earthcube.geosoft.software.classes;
public class Software extends URIEntity {
private static final long serialVersionUID = 1L;
String classId;
ArrayList<SWPropertyValue> propertyValues;
ArrayList<SoftwareRole> inputs;
ArrayList<SoftwareRole> outputs;
ArrayList<String> explanations;
HashMap<String, String> labels;
|
ArrayList<SNAssumption> assumptions;
|
IKCAP/turbosoft
|
reasoner/src/main/java/org/earthcube/geosoft/software/classes/Software.java
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/sn/SNAssumption.java
// public class SNAssumption extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// private String categoryId;
// private String note;
//
// public SNAssumption(String id) {
// super(id);
// }
//
// public String getCategoryId() {
// return categoryId;
// }
//
// public void setCategoryId(String categoryId) {
// this.categoryId = categoryId;
// }
//
// public String getNote() {
// return note;
// }
//
// public void setNote(String note) {
// this.note = note;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/sn/StandardName.java
// public class StandardName extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// private String objectId;
// private String quantityId;
// private ArrayList<String> operatorIds;
// private String internalVariable;
// private String note;
//
// public StandardName(String id) {
// super(id);
// operatorIds = new ArrayList<String>();
// }
//
// public String getObjectId() {
// return objectId;
// }
//
// public void setObjectId(String objectId) {
// this.objectId = objectId;
// }
//
// public String getQuantityId() {
// return quantityId;
// }
//
// public void setQuantityId(String quantityId) {
// this.quantityId = quantityId;
// }
//
// public ArrayList<String> getOperatorIds() {
// return operatorIds;
// }
//
// public void addOperatorId(String operatorId) {
// this.operatorIds.add(operatorId);
// }
//
// public String getInternalVariable() {
// return internalVariable;
// }
//
// public void setInternalVariable(String internalVariable) {
// this.internalVariable = internalVariable;
// }
//
// public String getNote() {
// return note;
// }
//
// public void setNote(String note) {
// this.note = note;
// }
//
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/util/URIEntity.java
// public class URIEntity implements Serializable {
// private static final long serialVersionUID = 1L;
// private URI id;
// private String label;
//
// HashMap<String, Object> provenance;
//
// public URIEntity(String id) {
// setID(id);
// this.provenance = new HashMap<String, Object>();
// }
//
// public URIEntity(String id, String label) {
// setID(id);
// this.label = label;
// this.provenance = new HashMap<String, Object>();
// }
//
// public String getID() {
// if (id != null)
// return id.toString();
// else
// return null;
// }
//
// public void setID(String id) {
// try {
// this.id = new URI(id).normalize();
// } catch (Exception e) {
// System.err.println(id + " Not a URI. Only URIs allowed for IDs");
// }
// }
//
// public String getURL() {
// return this.getNamespace().replaceAll("#$", "");
// }
//
// public String getName() {
// if (id != null)
// return id.getFragment();
// else
// return null;
// }
//
// public String getNamespace() {
// if (id != null)
// return id.getScheme() + ":" + id.getSchemeSpecificPart() + "#";
// else
// return null;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public HashMap<String, Object> getProvenance() {
// return provenance;
// }
//
// public void addProvenance(String propId, Object value) {
// this.provenance.put(propId, value);
// }
//
// public String toString() {
// return getName();
// }
//
// public int hashCode() {
// return id.hashCode();
// }
//
// }
|
import java.util.ArrayList;
import java.util.HashMap;
import org.earthcube.geosoft.software.classes.sn.SNAssumption;
import org.earthcube.geosoft.software.classes.sn.StandardName;
import org.earthcube.geosoft.util.URIEntity;
|
package org.earthcube.geosoft.software.classes;
public class Software extends URIEntity {
private static final long serialVersionUID = 1L;
String classId;
ArrayList<SWPropertyValue> propertyValues;
ArrayList<SoftwareRole> inputs;
ArrayList<SoftwareRole> outputs;
ArrayList<String> explanations;
HashMap<String, String> labels;
ArrayList<SNAssumption> assumptions;
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/sn/SNAssumption.java
// public class SNAssumption extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// private String categoryId;
// private String note;
//
// public SNAssumption(String id) {
// super(id);
// }
//
// public String getCategoryId() {
// return categoryId;
// }
//
// public void setCategoryId(String categoryId) {
// this.categoryId = categoryId;
// }
//
// public String getNote() {
// return note;
// }
//
// public void setNote(String note) {
// this.note = note;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/sn/StandardName.java
// public class StandardName extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// private String objectId;
// private String quantityId;
// private ArrayList<String> operatorIds;
// private String internalVariable;
// private String note;
//
// public StandardName(String id) {
// super(id);
// operatorIds = new ArrayList<String>();
// }
//
// public String getObjectId() {
// return objectId;
// }
//
// public void setObjectId(String objectId) {
// this.objectId = objectId;
// }
//
// public String getQuantityId() {
// return quantityId;
// }
//
// public void setQuantityId(String quantityId) {
// this.quantityId = quantityId;
// }
//
// public ArrayList<String> getOperatorIds() {
// return operatorIds;
// }
//
// public void addOperatorId(String operatorId) {
// this.operatorIds.add(operatorId);
// }
//
// public String getInternalVariable() {
// return internalVariable;
// }
//
// public void setInternalVariable(String internalVariable) {
// this.internalVariable = internalVariable;
// }
//
// public String getNote() {
// return note;
// }
//
// public void setNote(String note) {
// this.note = note;
// }
//
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/util/URIEntity.java
// public class URIEntity implements Serializable {
// private static final long serialVersionUID = 1L;
// private URI id;
// private String label;
//
// HashMap<String, Object> provenance;
//
// public URIEntity(String id) {
// setID(id);
// this.provenance = new HashMap<String, Object>();
// }
//
// public URIEntity(String id, String label) {
// setID(id);
// this.label = label;
// this.provenance = new HashMap<String, Object>();
// }
//
// public String getID() {
// if (id != null)
// return id.toString();
// else
// return null;
// }
//
// public void setID(String id) {
// try {
// this.id = new URI(id).normalize();
// } catch (Exception e) {
// System.err.println(id + " Not a URI. Only URIs allowed for IDs");
// }
// }
//
// public String getURL() {
// return this.getNamespace().replaceAll("#$", "");
// }
//
// public String getName() {
// if (id != null)
// return id.getFragment();
// else
// return null;
// }
//
// public String getNamespace() {
// if (id != null)
// return id.getScheme() + ":" + id.getSchemeSpecificPart() + "#";
// else
// return null;
// }
//
// public String getLabel() {
// return label;
// }
//
// public void setLabel(String label) {
// this.label = label;
// }
//
// public HashMap<String, Object> getProvenance() {
// return provenance;
// }
//
// public void addProvenance(String propId, Object value) {
// this.provenance.put(propId, value);
// }
//
// public String toString() {
// return getName();
// }
//
// public int hashCode() {
// return id.hashCode();
// }
//
// }
// Path: reasoner/src/main/java/org/earthcube/geosoft/software/classes/Software.java
import java.util.ArrayList;
import java.util.HashMap;
import org.earthcube.geosoft.software.classes.sn.SNAssumption;
import org.earthcube.geosoft.software.classes.sn.StandardName;
import org.earthcube.geosoft.util.URIEntity;
package org.earthcube.geosoft.software.classes;
public class Software extends URIEntity {
private static final long serialVersionUID = 1L;
String classId;
ArrayList<SWPropertyValue> propertyValues;
ArrayList<SoftwareRole> inputs;
ArrayList<SoftwareRole> outputs;
ArrayList<String> explanations;
HashMap<String, String> labels;
ArrayList<SNAssumption> assumptions;
|
ArrayList<StandardName> standardnames;
|
IKCAP/turbosoft
|
reasoner/src/main/java/org/earthcube/geosoft/data/api/DataAPI.java
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataItem.java
// public class DataItem extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// public static int DATATYPE = 1;
// public static int DATA = 2;
//
// int type;
//
// public DataItem(String id, int type) {
// super(id);
// this.type = type;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataTree.java
// public class DataTree {
// DataTreeNode root;
//
// public DataTree(DataTreeNode root) {
// this.root = root;
// }
//
// public DataTreeNode getRoot() {
// return root;
// }
//
// public void setRoot(DataTreeNode root) {
// this.root = root;
// }
//
// public ArrayList<DataTreeNode> flatten() {
// ArrayList<DataTreeNode> list = new ArrayList<DataTreeNode>();
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// list.add(node);
// queue.addAll(node.getChildren());
// }
// return list;
// }
//
// public DataTreeNode findNode(String nodeid) {
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// if (node.getItem().getID().equals(nodeid))
// return node;
// queue.addAll(node.getChildren());
// }
// return null;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataProperty.java
// public class MetadataProperty extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// int type;
// ArrayList<String> domains;
// String range;
//
// public static int DATATYPE = 1;
// public static int OBJECT = 2;
//
// public MetadataProperty(String id, int type) {
// super(id);
// this.type = type;
// this.domains = new ArrayList<String>();
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public int getType() {
// return this.type;
// }
//
// public boolean isDatatypeProperty() {
// if (this.type == DATATYPE)
// return true;
// return false;
// }
//
// public boolean isObjectProperty() {
// if (this.type == OBJECT)
// return true;
// return false;
// }
//
// public ArrayList<String> getDomains() {
// return this.domains;
// }
//
// public String getRange() {
// return this.range;
// }
//
// public void addDomain(String id) {
// this.domains.add(id);
// }
//
// public void setRange(String id) {
// this.range = id;
// }
//
// public String toString() {
// String str = "";
// str += "\n" + getName() + "(" + type + ")\nDomains:" + domains + "\nRange:" + range + "\n";
// return str;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataValue.java
// public class MetadataValue {
// public final static int OBJECT = 1;
// public final static int DATATYPE = 2;
//
// String propertyId;
// Object value;
// int type;
//
// public MetadataValue(String propertyId, Object value, int type) {
// this.propertyId = propertyId;
// this.value = value;
// this.type = type;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
|
import java.util.ArrayList;
import org.earthcube.geosoft.data.classes.DataItem;
import org.earthcube.geosoft.data.classes.DataTree;
import org.earthcube.geosoft.data.classes.MetadataProperty;
import org.earthcube.geosoft.data.classes.MetadataValue;
|
package org.earthcube.geosoft.data.api;
/**
* The interface used by data catalog viewers to query the data. Read/Only
* access
*/
public interface DataAPI {
// Query
DataTree getDataHierarchy(); // Tree List of Data and Datatypes
DataTree getDatatypeHierarchy(); // Tree List of Datatypes
DataTree getMetricsHierarchy(); // Tree List of Metrics and Metric
// types
ArrayList<String> getAllDatatypeIds();
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataItem.java
// public class DataItem extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// public static int DATATYPE = 1;
// public static int DATA = 2;
//
// int type;
//
// public DataItem(String id, int type) {
// super(id);
// this.type = type;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataTree.java
// public class DataTree {
// DataTreeNode root;
//
// public DataTree(DataTreeNode root) {
// this.root = root;
// }
//
// public DataTreeNode getRoot() {
// return root;
// }
//
// public void setRoot(DataTreeNode root) {
// this.root = root;
// }
//
// public ArrayList<DataTreeNode> flatten() {
// ArrayList<DataTreeNode> list = new ArrayList<DataTreeNode>();
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// list.add(node);
// queue.addAll(node.getChildren());
// }
// return list;
// }
//
// public DataTreeNode findNode(String nodeid) {
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// if (node.getItem().getID().equals(nodeid))
// return node;
// queue.addAll(node.getChildren());
// }
// return null;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataProperty.java
// public class MetadataProperty extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// int type;
// ArrayList<String> domains;
// String range;
//
// public static int DATATYPE = 1;
// public static int OBJECT = 2;
//
// public MetadataProperty(String id, int type) {
// super(id);
// this.type = type;
// this.domains = new ArrayList<String>();
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public int getType() {
// return this.type;
// }
//
// public boolean isDatatypeProperty() {
// if (this.type == DATATYPE)
// return true;
// return false;
// }
//
// public boolean isObjectProperty() {
// if (this.type == OBJECT)
// return true;
// return false;
// }
//
// public ArrayList<String> getDomains() {
// return this.domains;
// }
//
// public String getRange() {
// return this.range;
// }
//
// public void addDomain(String id) {
// this.domains.add(id);
// }
//
// public void setRange(String id) {
// this.range = id;
// }
//
// public String toString() {
// String str = "";
// str += "\n" + getName() + "(" + type + ")\nDomains:" + domains + "\nRange:" + range + "\n";
// return str;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataValue.java
// public class MetadataValue {
// public final static int OBJECT = 1;
// public final static int DATATYPE = 2;
//
// String propertyId;
// Object value;
// int type;
//
// public MetadataValue(String propertyId, Object value, int type) {
// this.propertyId = propertyId;
// this.value = value;
// this.type = type;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/api/DataAPI.java
import java.util.ArrayList;
import org.earthcube.geosoft.data.classes.DataItem;
import org.earthcube.geosoft.data.classes.DataTree;
import org.earthcube.geosoft.data.classes.MetadataProperty;
import org.earthcube.geosoft.data.classes.MetadataValue;
package org.earthcube.geosoft.data.api;
/**
* The interface used by data catalog viewers to query the data. Read/Only
* access
*/
public interface DataAPI {
// Query
DataTree getDataHierarchy(); // Tree List of Data and Datatypes
DataTree getDatatypeHierarchy(); // Tree List of Datatypes
DataTree getMetricsHierarchy(); // Tree List of Metrics and Metric
// types
ArrayList<String> getAllDatatypeIds();
|
MetadataProperty getMetadataProperty(String propid);
|
IKCAP/turbosoft
|
reasoner/src/main/java/org/earthcube/geosoft/data/api/DataAPI.java
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataItem.java
// public class DataItem extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// public static int DATATYPE = 1;
// public static int DATA = 2;
//
// int type;
//
// public DataItem(String id, int type) {
// super(id);
// this.type = type;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataTree.java
// public class DataTree {
// DataTreeNode root;
//
// public DataTree(DataTreeNode root) {
// this.root = root;
// }
//
// public DataTreeNode getRoot() {
// return root;
// }
//
// public void setRoot(DataTreeNode root) {
// this.root = root;
// }
//
// public ArrayList<DataTreeNode> flatten() {
// ArrayList<DataTreeNode> list = new ArrayList<DataTreeNode>();
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// list.add(node);
// queue.addAll(node.getChildren());
// }
// return list;
// }
//
// public DataTreeNode findNode(String nodeid) {
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// if (node.getItem().getID().equals(nodeid))
// return node;
// queue.addAll(node.getChildren());
// }
// return null;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataProperty.java
// public class MetadataProperty extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// int type;
// ArrayList<String> domains;
// String range;
//
// public static int DATATYPE = 1;
// public static int OBJECT = 2;
//
// public MetadataProperty(String id, int type) {
// super(id);
// this.type = type;
// this.domains = new ArrayList<String>();
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public int getType() {
// return this.type;
// }
//
// public boolean isDatatypeProperty() {
// if (this.type == DATATYPE)
// return true;
// return false;
// }
//
// public boolean isObjectProperty() {
// if (this.type == OBJECT)
// return true;
// return false;
// }
//
// public ArrayList<String> getDomains() {
// return this.domains;
// }
//
// public String getRange() {
// return this.range;
// }
//
// public void addDomain(String id) {
// this.domains.add(id);
// }
//
// public void setRange(String id) {
// this.range = id;
// }
//
// public String toString() {
// String str = "";
// str += "\n" + getName() + "(" + type + ")\nDomains:" + domains + "\nRange:" + range + "\n";
// return str;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataValue.java
// public class MetadataValue {
// public final static int OBJECT = 1;
// public final static int DATATYPE = 2;
//
// String propertyId;
// Object value;
// int type;
//
// public MetadataValue(String propertyId, Object value, int type) {
// this.propertyId = propertyId;
// this.value = value;
// this.type = type;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
|
import java.util.ArrayList;
import org.earthcube.geosoft.data.classes.DataItem;
import org.earthcube.geosoft.data.classes.DataTree;
import org.earthcube.geosoft.data.classes.MetadataProperty;
import org.earthcube.geosoft.data.classes.MetadataValue;
|
package org.earthcube.geosoft.data.api;
/**
* The interface used by data catalog viewers to query the data. Read/Only
* access
*/
public interface DataAPI {
// Query
DataTree getDataHierarchy(); // Tree List of Data and Datatypes
DataTree getDatatypeHierarchy(); // Tree List of Datatypes
DataTree getMetricsHierarchy(); // Tree List of Metrics and Metric
// types
ArrayList<String> getAllDatatypeIds();
MetadataProperty getMetadataProperty(String propid);
ArrayList<MetadataProperty> getMetadataProperties(String dtypeid, boolean direct);
ArrayList<MetadataProperty> getAllMetadataProperties();
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataItem.java
// public class DataItem extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// public static int DATATYPE = 1;
// public static int DATA = 2;
//
// int type;
//
// public DataItem(String id, int type) {
// super(id);
// this.type = type;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataTree.java
// public class DataTree {
// DataTreeNode root;
//
// public DataTree(DataTreeNode root) {
// this.root = root;
// }
//
// public DataTreeNode getRoot() {
// return root;
// }
//
// public void setRoot(DataTreeNode root) {
// this.root = root;
// }
//
// public ArrayList<DataTreeNode> flatten() {
// ArrayList<DataTreeNode> list = new ArrayList<DataTreeNode>();
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// list.add(node);
// queue.addAll(node.getChildren());
// }
// return list;
// }
//
// public DataTreeNode findNode(String nodeid) {
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// if (node.getItem().getID().equals(nodeid))
// return node;
// queue.addAll(node.getChildren());
// }
// return null;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataProperty.java
// public class MetadataProperty extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// int type;
// ArrayList<String> domains;
// String range;
//
// public static int DATATYPE = 1;
// public static int OBJECT = 2;
//
// public MetadataProperty(String id, int type) {
// super(id);
// this.type = type;
// this.domains = new ArrayList<String>();
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public int getType() {
// return this.type;
// }
//
// public boolean isDatatypeProperty() {
// if (this.type == DATATYPE)
// return true;
// return false;
// }
//
// public boolean isObjectProperty() {
// if (this.type == OBJECT)
// return true;
// return false;
// }
//
// public ArrayList<String> getDomains() {
// return this.domains;
// }
//
// public String getRange() {
// return this.range;
// }
//
// public void addDomain(String id) {
// this.domains.add(id);
// }
//
// public void setRange(String id) {
// this.range = id;
// }
//
// public String toString() {
// String str = "";
// str += "\n" + getName() + "(" + type + ")\nDomains:" + domains + "\nRange:" + range + "\n";
// return str;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataValue.java
// public class MetadataValue {
// public final static int OBJECT = 1;
// public final static int DATATYPE = 2;
//
// String propertyId;
// Object value;
// int type;
//
// public MetadataValue(String propertyId, Object value, int type) {
// this.propertyId = propertyId;
// this.value = value;
// this.type = type;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/api/DataAPI.java
import java.util.ArrayList;
import org.earthcube.geosoft.data.classes.DataItem;
import org.earthcube.geosoft.data.classes.DataTree;
import org.earthcube.geosoft.data.classes.MetadataProperty;
import org.earthcube.geosoft.data.classes.MetadataValue;
package org.earthcube.geosoft.data.api;
/**
* The interface used by data catalog viewers to query the data. Read/Only
* access
*/
public interface DataAPI {
// Query
DataTree getDataHierarchy(); // Tree List of Data and Datatypes
DataTree getDatatypeHierarchy(); // Tree List of Datatypes
DataTree getMetricsHierarchy(); // Tree List of Metrics and Metric
// types
ArrayList<String> getAllDatatypeIds();
MetadataProperty getMetadataProperty(String propid);
ArrayList<MetadataProperty> getMetadataProperties(String dtypeid, boolean direct);
ArrayList<MetadataProperty> getAllMetadataProperties();
|
DataItem getDatatypeForData(String dataid);
|
IKCAP/turbosoft
|
reasoner/src/main/java/org/earthcube/geosoft/data/api/DataAPI.java
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataItem.java
// public class DataItem extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// public static int DATATYPE = 1;
// public static int DATA = 2;
//
// int type;
//
// public DataItem(String id, int type) {
// super(id);
// this.type = type;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataTree.java
// public class DataTree {
// DataTreeNode root;
//
// public DataTree(DataTreeNode root) {
// this.root = root;
// }
//
// public DataTreeNode getRoot() {
// return root;
// }
//
// public void setRoot(DataTreeNode root) {
// this.root = root;
// }
//
// public ArrayList<DataTreeNode> flatten() {
// ArrayList<DataTreeNode> list = new ArrayList<DataTreeNode>();
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// list.add(node);
// queue.addAll(node.getChildren());
// }
// return list;
// }
//
// public DataTreeNode findNode(String nodeid) {
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// if (node.getItem().getID().equals(nodeid))
// return node;
// queue.addAll(node.getChildren());
// }
// return null;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataProperty.java
// public class MetadataProperty extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// int type;
// ArrayList<String> domains;
// String range;
//
// public static int DATATYPE = 1;
// public static int OBJECT = 2;
//
// public MetadataProperty(String id, int type) {
// super(id);
// this.type = type;
// this.domains = new ArrayList<String>();
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public int getType() {
// return this.type;
// }
//
// public boolean isDatatypeProperty() {
// if (this.type == DATATYPE)
// return true;
// return false;
// }
//
// public boolean isObjectProperty() {
// if (this.type == OBJECT)
// return true;
// return false;
// }
//
// public ArrayList<String> getDomains() {
// return this.domains;
// }
//
// public String getRange() {
// return this.range;
// }
//
// public void addDomain(String id) {
// this.domains.add(id);
// }
//
// public void setRange(String id) {
// this.range = id;
// }
//
// public String toString() {
// String str = "";
// str += "\n" + getName() + "(" + type + ")\nDomains:" + domains + "\nRange:" + range + "\n";
// return str;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataValue.java
// public class MetadataValue {
// public final static int OBJECT = 1;
// public final static int DATATYPE = 2;
//
// String propertyId;
// Object value;
// int type;
//
// public MetadataValue(String propertyId, Object value, int type) {
// this.propertyId = propertyId;
// this.value = value;
// this.type = type;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
|
import java.util.ArrayList;
import org.earthcube.geosoft.data.classes.DataItem;
import org.earthcube.geosoft.data.classes.DataTree;
import org.earthcube.geosoft.data.classes.MetadataProperty;
import org.earthcube.geosoft.data.classes.MetadataValue;
|
package org.earthcube.geosoft.data.api;
/**
* The interface used by data catalog viewers to query the data. Read/Only
* access
*/
public interface DataAPI {
// Query
DataTree getDataHierarchy(); // Tree List of Data and Datatypes
DataTree getDatatypeHierarchy(); // Tree List of Datatypes
DataTree getMetricsHierarchy(); // Tree List of Metrics and Metric
// types
ArrayList<String> getAllDatatypeIds();
MetadataProperty getMetadataProperty(String propid);
ArrayList<MetadataProperty> getMetadataProperties(String dtypeid, boolean direct);
ArrayList<MetadataProperty> getAllMetadataProperties();
DataItem getDatatypeForData(String dataid);
ArrayList<DataItem> getDataForDatatype(String dtypeid, boolean direct);
String getTypeNameFormat(String dtypeid);
String getDataLocation(String dataid);
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataItem.java
// public class DataItem extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// public static int DATATYPE = 1;
// public static int DATA = 2;
//
// int type;
//
// public DataItem(String id, int type) {
// super(id);
// this.type = type;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/DataTree.java
// public class DataTree {
// DataTreeNode root;
//
// public DataTree(DataTreeNode root) {
// this.root = root;
// }
//
// public DataTreeNode getRoot() {
// return root;
// }
//
// public void setRoot(DataTreeNode root) {
// this.root = root;
// }
//
// public ArrayList<DataTreeNode> flatten() {
// ArrayList<DataTreeNode> list = new ArrayList<DataTreeNode>();
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// list.add(node);
// queue.addAll(node.getChildren());
// }
// return list;
// }
//
// public DataTreeNode findNode(String nodeid) {
// ArrayList<DataTreeNode> queue = new ArrayList<DataTreeNode>();
// queue.add(root);
// while (!queue.isEmpty()) {
// DataTreeNode node = queue.remove(0);
// if (node.getItem().getID().equals(nodeid))
// return node;
// queue.addAll(node.getChildren());
// }
// return null;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataProperty.java
// public class MetadataProperty extends URIEntity {
// private static final long serialVersionUID = 1L;
//
// int type;
// ArrayList<String> domains;
// String range;
//
// public static int DATATYPE = 1;
// public static int OBJECT = 2;
//
// public MetadataProperty(String id, int type) {
// super(id);
// this.type = type;
// this.domains = new ArrayList<String>();
// }
//
// public void setType(int type) {
// this.type = type;
// }
//
// public int getType() {
// return this.type;
// }
//
// public boolean isDatatypeProperty() {
// if (this.type == DATATYPE)
// return true;
// return false;
// }
//
// public boolean isObjectProperty() {
// if (this.type == OBJECT)
// return true;
// return false;
// }
//
// public ArrayList<String> getDomains() {
// return this.domains;
// }
//
// public String getRange() {
// return this.range;
// }
//
// public void addDomain(String id) {
// this.domains.add(id);
// }
//
// public void setRange(String id) {
// this.range = id;
// }
//
// public String toString() {
// String str = "";
// str += "\n" + getName() + "(" + type + ")\nDomains:" + domains + "\nRange:" + range + "\n";
// return str;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/classes/MetadataValue.java
// public class MetadataValue {
// public final static int OBJECT = 1;
// public final static int DATATYPE = 2;
//
// String propertyId;
// Object value;
// int type;
//
// public MetadataValue(String propertyId, Object value, int type) {
// this.propertyId = propertyId;
// this.value = value;
// this.type = type;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public int getType() {
// return type;
// }
//
// public void setType(int type) {
// this.type = type;
// }
// }
// Path: reasoner/src/main/java/org/earthcube/geosoft/data/api/DataAPI.java
import java.util.ArrayList;
import org.earthcube.geosoft.data.classes.DataItem;
import org.earthcube.geosoft.data.classes.DataTree;
import org.earthcube.geosoft.data.classes.MetadataProperty;
import org.earthcube.geosoft.data.classes.MetadataValue;
package org.earthcube.geosoft.data.api;
/**
* The interface used by data catalog viewers to query the data. Read/Only
* access
*/
public interface DataAPI {
// Query
DataTree getDataHierarchy(); // Tree List of Data and Datatypes
DataTree getDatatypeHierarchy(); // Tree List of Datatypes
DataTree getMetricsHierarchy(); // Tree List of Metrics and Metric
// types
ArrayList<String> getAllDatatypeIds();
MetadataProperty getMetadataProperty(String propid);
ArrayList<MetadataProperty> getMetadataProperties(String dtypeid, boolean direct);
ArrayList<MetadataProperty> getAllMetadataProperties();
DataItem getDatatypeForData(String dataid);
ArrayList<DataItem> getDataForDatatype(String dtypeid, boolean direct);
String getTypeNameFormat(String dtypeid);
String getDataLocation(String dataid);
|
ArrayList<MetadataValue> getMetadataValues(String dataid, ArrayList<String> propids);
|
IKCAP/turbosoft
|
reasoner/src/main/java/org/earthcube/geosoft/community/api/CommunityAPI.java
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/classes/User.java
// public class User extends URIEntity{
// private static final long serialVersionUID = 1L;
// String username, picture, site, expertise, affiliation;
// boolean isDeveloper;
//
// public User(String id) {
// super(id);
// }
//
// public String getUsername() {
// return this.username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPicture() {
// return picture;
// }
//
// public void setPicture(String picture) {
// this.picture = picture;
// }
//
// public String getSite() {
// return site;
// }
//
// public void setSite(String site) {
// this.site = site;
// }
//
// public String getExpertise() {
// return expertise;
// }
//
// public void setExpertise(String expertise) {
// this.expertise = expertise;
// }
//
// public String getAffiliation() {
// return affiliation;
// }
//
// public void setAffiliation(String affiliation) {
// this.affiliation = affiliation;
// }
//
// public boolean isDeveloper() {
// return isDeveloper;
// }
//
// public void setDeveloper(boolean isDeveloper) {
// this.isDeveloper = isDeveloper;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/classes/UserContribution.java
// public class UserContribution {
// String softwareId;
// String propertyId;
// Object value;
// long timestamp;
//
// public String getSoftwareId() {
// return softwareId;
// }
//
// public void setSoftwareId(String softwareId) {
// this.softwareId = softwareId;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
// }
|
import java.util.ArrayList;
import org.earthcube.geosoft.community.classes.User;
import org.earthcube.geosoft.community.classes.UserContribution;
|
package org.earthcube.geosoft.community.api;
public interface CommunityAPI {
void initializeUser(String username);
ArrayList<String> listUserIds();
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/classes/User.java
// public class User extends URIEntity{
// private static final long serialVersionUID = 1L;
// String username, picture, site, expertise, affiliation;
// boolean isDeveloper;
//
// public User(String id) {
// super(id);
// }
//
// public String getUsername() {
// return this.username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPicture() {
// return picture;
// }
//
// public void setPicture(String picture) {
// this.picture = picture;
// }
//
// public String getSite() {
// return site;
// }
//
// public void setSite(String site) {
// this.site = site;
// }
//
// public String getExpertise() {
// return expertise;
// }
//
// public void setExpertise(String expertise) {
// this.expertise = expertise;
// }
//
// public String getAffiliation() {
// return affiliation;
// }
//
// public void setAffiliation(String affiliation) {
// this.affiliation = affiliation;
// }
//
// public boolean isDeveloper() {
// return isDeveloper;
// }
//
// public void setDeveloper(boolean isDeveloper) {
// this.isDeveloper = isDeveloper;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/classes/UserContribution.java
// public class UserContribution {
// String softwareId;
// String propertyId;
// Object value;
// long timestamp;
//
// public String getSoftwareId() {
// return softwareId;
// }
//
// public void setSoftwareId(String softwareId) {
// this.softwareId = softwareId;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
// }
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/api/CommunityAPI.java
import java.util.ArrayList;
import org.earthcube.geosoft.community.classes.User;
import org.earthcube.geosoft.community.classes.UserContribution;
package org.earthcube.geosoft.community.api;
public interface CommunityAPI {
void initializeUser(String username);
ArrayList<String> listUserIds();
|
ArrayList<User> getAllUsers();
|
IKCAP/turbosoft
|
reasoner/src/main/java/org/earthcube/geosoft/community/api/CommunityAPI.java
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/classes/User.java
// public class User extends URIEntity{
// private static final long serialVersionUID = 1L;
// String username, picture, site, expertise, affiliation;
// boolean isDeveloper;
//
// public User(String id) {
// super(id);
// }
//
// public String getUsername() {
// return this.username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPicture() {
// return picture;
// }
//
// public void setPicture(String picture) {
// this.picture = picture;
// }
//
// public String getSite() {
// return site;
// }
//
// public void setSite(String site) {
// this.site = site;
// }
//
// public String getExpertise() {
// return expertise;
// }
//
// public void setExpertise(String expertise) {
// this.expertise = expertise;
// }
//
// public String getAffiliation() {
// return affiliation;
// }
//
// public void setAffiliation(String affiliation) {
// this.affiliation = affiliation;
// }
//
// public boolean isDeveloper() {
// return isDeveloper;
// }
//
// public void setDeveloper(boolean isDeveloper) {
// this.isDeveloper = isDeveloper;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/classes/UserContribution.java
// public class UserContribution {
// String softwareId;
// String propertyId;
// Object value;
// long timestamp;
//
// public String getSoftwareId() {
// return softwareId;
// }
//
// public void setSoftwareId(String softwareId) {
// this.softwareId = softwareId;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
// }
|
import java.util.ArrayList;
import org.earthcube.geosoft.community.classes.User;
import org.earthcube.geosoft.community.classes.UserContribution;
|
package org.earthcube.geosoft.community.api;
public interface CommunityAPI {
void initializeUser(String username);
ArrayList<String> listUserIds();
ArrayList<User> getAllUsers();
User getUser(String userid);
boolean saveUser(User user);
|
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/classes/User.java
// public class User extends URIEntity{
// private static final long serialVersionUID = 1L;
// String username, picture, site, expertise, affiliation;
// boolean isDeveloper;
//
// public User(String id) {
// super(id);
// }
//
// public String getUsername() {
// return this.username;
// }
//
// public void setUsername(String username) {
// this.username = username;
// }
//
// public String getPicture() {
// return picture;
// }
//
// public void setPicture(String picture) {
// this.picture = picture;
// }
//
// public String getSite() {
// return site;
// }
//
// public void setSite(String site) {
// this.site = site;
// }
//
// public String getExpertise() {
// return expertise;
// }
//
// public void setExpertise(String expertise) {
// this.expertise = expertise;
// }
//
// public String getAffiliation() {
// return affiliation;
// }
//
// public void setAffiliation(String affiliation) {
// this.affiliation = affiliation;
// }
//
// public boolean isDeveloper() {
// return isDeveloper;
// }
//
// public void setDeveloper(boolean isDeveloper) {
// this.isDeveloper = isDeveloper;
// }
// }
//
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/classes/UserContribution.java
// public class UserContribution {
// String softwareId;
// String propertyId;
// Object value;
// long timestamp;
//
// public String getSoftwareId() {
// return softwareId;
// }
//
// public void setSoftwareId(String softwareId) {
// this.softwareId = softwareId;
// }
//
// public String getPropertyId() {
// return propertyId;
// }
//
// public void setPropertyId(String propertyId) {
// this.propertyId = propertyId;
// }
//
// public Object getValue() {
// return value;
// }
//
// public void setValue(Object value) {
// this.value = value;
// }
//
// public long getTimestamp() {
// return timestamp;
// }
//
// public void setTimestamp(long timestamp) {
// this.timestamp = timestamp;
// }
// }
// Path: reasoner/src/main/java/org/earthcube/geosoft/community/api/CommunityAPI.java
import java.util.ArrayList;
import org.earthcube.geosoft.community.classes.User;
import org.earthcube.geosoft.community.classes.UserContribution;
package org.earthcube.geosoft.community.api;
public interface CommunityAPI {
void initializeUser(String username);
ArrayList<String> listUserIds();
ArrayList<User> getAllUsers();
User getUser(String userid);
boolean saveUser(User user);
|
ArrayList<UserContribution> getUserContributions(String userid);
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-jaxrs/src/test/java/org/tuxdevelop/spring/data/solr/demo/service/CommonStoreServiceIT.java
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
|
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Point;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
|
package org.tuxdevelop.spring.data.solr.demo.service;
public abstract class CommonStoreServiceIT {
@Autowired
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
// Path: spring-data-solr-demo-jaxrs/src/test/java/org/tuxdevelop/spring/data/solr/demo/service/CommonStoreServiceIT.java
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Point;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
package org.tuxdevelop.spring.data.solr.demo.service;
public abstract class CommonStoreServiceIT {
@Autowired
|
private StoreService storeService;
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-jaxrs/src/test/java/org/tuxdevelop/spring/data/solr/demo/service/CommonStoreServiceIT.java
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
|
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Point;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
|
package org.tuxdevelop.spring.data.solr.demo.service;
public abstract class CommonStoreServiceIT {
@Autowired
private StoreService storeService;
@Test
public void addIT() {
final Collection<String> products = new LinkedList<>();
products.add("Tux");
final Collection<String> services = new LinkedList<>();
services.add("Live Hacking");
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
// Path: spring-data-solr-demo-jaxrs/src/test/java/org/tuxdevelop/spring/data/solr/demo/service/CommonStoreServiceIT.java
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Point;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
package org.tuxdevelop.spring.data.solr.demo.service;
public abstract class CommonStoreServiceIT {
@Autowired
private StoreService storeService;
@Test
public void addIT() {
final Collection<String> products = new LinkedList<>();
products.add("Tux");
final Collection<String> services = new LinkedList<>();
services.add("Live Hacking");
|
final StarbucksStore starbucksStore = new StarbucksStore();
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-data-rest/src/test/java/org/tuxdevelop/spring/data/solr/demo/ITTests.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
|
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
|
package org.tuxdevelop.spring.data.solr.demo;
@Slf4j
public abstract class ITTests {
protected static final String HTTP_LOCALHOST = "http://localhost:";
protected static final String DATA_SOLR_STORES = "/dataSolr/stores";
protected static final String SEARCH = "/search";
protected static final String FIND_BY_NAME = "/findByName";
protected static final String FIND_BY_NAME_QUERY = "/findByNameQuery";
@Autowired
private RestTemplate restTemplate;
protected String baseUrl;
@Test
public void findByIdIT() {
final Integer id = 1;
final HttpEntity<?> httpEntity = getHttpEntity();
final String uri = baseUrl + "/{id}";
log.info("query url: " + uri);
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
// Path: spring-data-solr-demo-data-rest/src/test/java/org/tuxdevelop/spring/data/solr/demo/ITTests.java
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
package org.tuxdevelop.spring.data.solr.demo;
@Slf4j
public abstract class ITTests {
protected static final String HTTP_LOCALHOST = "http://localhost:";
protected static final String DATA_SOLR_STORES = "/dataSolr/stores";
protected static final String SEARCH = "/search";
protected static final String FIND_BY_NAME = "/findByName";
protected static final String FIND_BY_NAME_QUERY = "/findByNameQuery";
@Autowired
private RestTemplate restTemplate;
protected String baseUrl;
@Test
public void findByIdIT() {
final Integer id = 1;
final HttpEntity<?> httpEntity = getHttpEntity();
final String uri = baseUrl + "/{id}";
log.info("query url: " + uri);
|
final ResponseEntity<StarbucksStore> response =
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
|
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.mapping.DefaultLineMapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy;
import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.geo.Point;
import org.springframework.data.solr.UncategorizedSolrException;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindException;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import java.util.*;
|
package org.tuxdevelop.spring.data.solr.demo.util;
@Slf4j
@Component
public class SolrInitializer {
private static final String LONGTITUDE = "Longitude";
private static final String LATITUDE = "Latitude";
private static final String ZIP_CODE = "Zip";
private static final String NAME = "Name";
private static final String CITY = "City";
private static final String STREET_ADDRESS = "Street Address";
private static final String FEATURES_PRODUCTS = "Features - Products";
private static final String FEATURES_SERVICES = "Features - Service";
private static final Double MAX_X = 180.0;
private static final Double MIN_X = -180.0;
private static final Double MAX_Y = 90.0;
private static final Double MIN_Y = -90.0;
@Autowired
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.mapping.DefaultLineMapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy;
import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.geo.Point;
import org.springframework.data.solr.UncategorizedSolrException;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindException;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import java.util.*;
package org.tuxdevelop.spring.data.solr.demo.util;
@Slf4j
@Component
public class SolrInitializer {
private static final String LONGTITUDE = "Longitude";
private static final String LATITUDE = "Latitude";
private static final String ZIP_CODE = "Zip";
private static final String NAME = "Name";
private static final String CITY = "City";
private static final String STREET_ADDRESS = "Street Address";
private static final String FEATURES_PRODUCTS = "Features - Products";
private static final String FEATURES_SERVICES = "Features - Service";
private static final Double MAX_X = 180.0;
private static final Double MIN_X = -180.0;
private static final Double MAX_Y = 90.0;
private static final Double MIN_Y = -90.0;
@Autowired
|
private StarbucksStoreRepository starbucksStoreRepository;
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
|
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.mapping.DefaultLineMapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy;
import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.geo.Point;
import org.springframework.data.solr.UncategorizedSolrException;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindException;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import java.util.*;
|
package org.tuxdevelop.spring.data.solr.demo.util;
@Slf4j
@Component
public class SolrInitializer {
private static final String LONGTITUDE = "Longitude";
private static final String LATITUDE = "Latitude";
private static final String ZIP_CODE = "Zip";
private static final String NAME = "Name";
private static final String CITY = "City";
private static final String STREET_ADDRESS = "Street Address";
private static final String FEATURES_PRODUCTS = "Features - Products";
private static final String FEATURES_SERVICES = "Features - Service";
private static final Double MAX_X = 180.0;
private static final Double MIN_X = -180.0;
private static final Double MAX_Y = 90.0;
private static final Double MIN_Y = -90.0;
@Autowired
private StarbucksStoreRepository starbucksStoreRepository;
public void importStarbucks() throws Exception {
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ExecutionContext;
import org.springframework.batch.item.file.FlatFileItemReader;
import org.springframework.batch.item.file.mapping.DefaultLineMapper;
import org.springframework.batch.item.file.mapping.FieldSetMapper;
import org.springframework.batch.item.file.separator.DefaultRecordSeparatorPolicy;
import org.springframework.batch.item.file.transform.DelimitedLineTokenizer;
import org.springframework.batch.item.file.transform.FieldSet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.geo.Point;
import org.springframework.data.solr.UncategorizedSolrException;
import org.springframework.stereotype.Component;
import org.springframework.validation.BindException;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import java.util.*;
package org.tuxdevelop.spring.data.solr.demo.util;
@Slf4j
@Component
public class SolrInitializer {
private static final String LONGTITUDE = "Longitude";
private static final String LATITUDE = "Latitude";
private static final String ZIP_CODE = "Zip";
private static final String NAME = "Name";
private static final String CITY = "City";
private static final String STREET_ADDRESS = "Street Address";
private static final String FEATURES_PRODUCTS = "Features - Products";
private static final String FEATURES_SERVICES = "Features - Service";
private static final Double MAX_X = 180.0;
private static final Double MIN_X = -180.0;
private static final Double MAX_Y = 90.0;
private static final Double MIN_Y = -90.0;
@Autowired
private StarbucksStoreRepository starbucksStoreRepository;
public void importStarbucks() throws Exception {
|
final List<List<StarbucksStore>> stores = importStores();
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-starbucks/src/main/java/org/tuxdevelop/spring/data/solr/demo/model/CityGroupModel.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
|
import lombok.Data;
import org.springframework.data.domain.Page;
import org.springframework.data.solr.core.query.result.GroupEntry;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
|
package org.tuxdevelop.spring.data.solr.demo.model;
@Data
public class CityGroupModel {
private Integer currentPage;
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
// Path: spring-data-solr-demo-starbucks/src/main/java/org/tuxdevelop/spring/data/solr/demo/model/CityGroupModel.java
import lombok.Data;
import org.springframework.data.domain.Page;
import org.springframework.data.solr.core.query.result.GroupEntry;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
package org.tuxdevelop.spring.data.solr.demo.model;
@Data
public class CityGroupModel {
private Integer currentPage;
|
private Page<GroupEntry<StarbucksStore>> groupEntries;
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-starbucks/src/main/java/org/tuxdevelop/spring/data/solr/demo/StarbucksApplication.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
// @Slf4j
// @Component
// public class SolrInitializer {
//
// private static final String LONGTITUDE = "Longitude";
// private static final String LATITUDE = "Latitude";
// private static final String ZIP_CODE = "Zip";
// private static final String NAME = "Name";
// private static final String CITY = "City";
// private static final String STREET_ADDRESS = "Street Address";
// private static final String FEATURES_PRODUCTS = "Features - Products";
// private static final String FEATURES_SERVICES = "Features - Service";
//
// private static final Double MAX_X = 180.0;
// private static final Double MIN_X = -180.0;
//
// private static final Double MAX_Y = 90.0;
// private static final Double MIN_Y = -90.0;
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// public void importStarbucks() throws Exception {
// final List<List<StarbucksStore>> stores = importStores();
// for (List<StarbucksStore> starbucksStoreList : stores) {
// try {
// starbucksStoreRepository.save(starbucksStoreList);
// } catch (UncategorizedSolrException e) {
// log.error(e.getMessage());
// }
// }
//
// }
//
// private List<List<StarbucksStore>> importStores() throws Exception {
// final ClassPathResource resource = new ClassPathResource("starbucks.csv");
// final Scanner scanner = new Scanner(resource.getInputStream());
// final String line = scanner.nextLine();
// scanner.close();
//
// final FlatFileItemReader<StarbucksStore> itemReader = new FlatFileItemReader<StarbucksStore>();
// itemReader.setResource(resource);
//
// // DelimitedLineTokenizer defaults to comma as its delimiter
// final DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
// tokenizer.setNames(line.split(","));
// tokenizer.setStrict(false);
//
// final DefaultLineMapper<StarbucksStore> lineMapper = new DefaultLineMapper<StarbucksStore>();
// lineMapper.setLineTokenizer(tokenizer);
// lineMapper.setFieldSetMapper(StoreFieldSetMapper.INSTANCE);
// itemReader.setLineMapper(lineMapper);
// itemReader.setRecordSeparatorPolicy(new DefaultRecordSeparatorPolicy());
// itemReader.setLinesToSkip(1);
// itemReader.open(new ExecutionContext());
// final List<List<StarbucksStore>> stores = new LinkedList<>();
// List<StarbucksStore> starbucksStoreList = new LinkedList<>();
// StarbucksStore starbucksStore;
// int id = 1;
// int currentCount = 1;
// do {
// starbucksStore = itemReader.read();
// if (starbucksStore != null) {
// starbucksStore.setId(String.valueOf(id));
// starbucksStoreList.add(starbucksStore);
// id++;
// currentCount++;
// }
// if (currentCount == 1000) {
// stores.add(new LinkedList<>(starbucksStoreList));
// currentCount = 1;
// starbucksStoreList = new LinkedList<>();
// }
// } while (starbucksStore != null);
//
// return stores;
// }
//
// private enum StoreFieldSetMapper implements FieldSetMapper<StarbucksStore> {
//
// INSTANCE;
//
// @Override
// public StarbucksStore mapFieldSet(FieldSet fields) throws BindException {
// final Double longtitudeRead = fields.readDouble(LONGTITUDE);
// final Double latitudeRead = fields.readDouble(LATITUDE);
// final Point location = getLocationPoint(longtitudeRead, latitudeRead);
//
// final String name = fields.readString(NAME);
// final String zipCode = fields.readString(ZIP_CODE);
// final String city = fields.readString(CITY);
// final String street = fields.readString(STREET_ADDRESS);
// final String productsString = fields.readString(FEATURES_PRODUCTS);
// final Collection<String> products = Arrays.asList(productsString.split(","));
// final String servicesString = fields.readString(FEATURES_SERVICES);
// final Collection<String> services = Arrays.asList(servicesString.split(","));
// return new StarbucksStore(null, name, zipCode, city, street, products, services, location);
// }
//
// private Point getLocationPoint(final Double longtitudeRead, final Double latitudeRead) {
//
// final int longtitudeCompareMax = MAX_Y.compareTo(longtitudeRead);
// final int longtitudeCompareMin = MIN_Y.compareTo(longtitudeRead);
//
// final int latitudeCompareMax = MAX_X.compareTo(latitudeRead);
// final int latitudeCompareMin = MIN_X.compareTo(latitudeRead);
//
// final Double longtitude;
// final Double latitude;
//
// if (longtitudeCompareMax < 0) {
// longtitude = MAX_Y;
// } else if (longtitudeCompareMin > 0) {
// longtitude = MIN_Y;
// } else {
// longtitude = longtitudeRead;
// }
//
// if (latitudeCompareMax < 0) {
// latitude = MAX_X;
// } else if (latitudeCompareMin > 0) {
// latitude = MIN_X;
// } else {
// latitude = latitudeRead;
// }
// return new Point(latitude, longtitude);
// }
// }
//
//
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.tuxdevelop.spring.data.solr.demo.util.SolrInitializer;
import javax.annotation.PostConstruct;
|
package org.tuxdevelop.spring.data.solr.demo;
@SpringBootApplication
@EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
public class StarbucksApplication {
@Autowired
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
// @Slf4j
// @Component
// public class SolrInitializer {
//
// private static final String LONGTITUDE = "Longitude";
// private static final String LATITUDE = "Latitude";
// private static final String ZIP_CODE = "Zip";
// private static final String NAME = "Name";
// private static final String CITY = "City";
// private static final String STREET_ADDRESS = "Street Address";
// private static final String FEATURES_PRODUCTS = "Features - Products";
// private static final String FEATURES_SERVICES = "Features - Service";
//
// private static final Double MAX_X = 180.0;
// private static final Double MIN_X = -180.0;
//
// private static final Double MAX_Y = 90.0;
// private static final Double MIN_Y = -90.0;
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// public void importStarbucks() throws Exception {
// final List<List<StarbucksStore>> stores = importStores();
// for (List<StarbucksStore> starbucksStoreList : stores) {
// try {
// starbucksStoreRepository.save(starbucksStoreList);
// } catch (UncategorizedSolrException e) {
// log.error(e.getMessage());
// }
// }
//
// }
//
// private List<List<StarbucksStore>> importStores() throws Exception {
// final ClassPathResource resource = new ClassPathResource("starbucks.csv");
// final Scanner scanner = new Scanner(resource.getInputStream());
// final String line = scanner.nextLine();
// scanner.close();
//
// final FlatFileItemReader<StarbucksStore> itemReader = new FlatFileItemReader<StarbucksStore>();
// itemReader.setResource(resource);
//
// // DelimitedLineTokenizer defaults to comma as its delimiter
// final DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
// tokenizer.setNames(line.split(","));
// tokenizer.setStrict(false);
//
// final DefaultLineMapper<StarbucksStore> lineMapper = new DefaultLineMapper<StarbucksStore>();
// lineMapper.setLineTokenizer(tokenizer);
// lineMapper.setFieldSetMapper(StoreFieldSetMapper.INSTANCE);
// itemReader.setLineMapper(lineMapper);
// itemReader.setRecordSeparatorPolicy(new DefaultRecordSeparatorPolicy());
// itemReader.setLinesToSkip(1);
// itemReader.open(new ExecutionContext());
// final List<List<StarbucksStore>> stores = new LinkedList<>();
// List<StarbucksStore> starbucksStoreList = new LinkedList<>();
// StarbucksStore starbucksStore;
// int id = 1;
// int currentCount = 1;
// do {
// starbucksStore = itemReader.read();
// if (starbucksStore != null) {
// starbucksStore.setId(String.valueOf(id));
// starbucksStoreList.add(starbucksStore);
// id++;
// currentCount++;
// }
// if (currentCount == 1000) {
// stores.add(new LinkedList<>(starbucksStoreList));
// currentCount = 1;
// starbucksStoreList = new LinkedList<>();
// }
// } while (starbucksStore != null);
//
// return stores;
// }
//
// private enum StoreFieldSetMapper implements FieldSetMapper<StarbucksStore> {
//
// INSTANCE;
//
// @Override
// public StarbucksStore mapFieldSet(FieldSet fields) throws BindException {
// final Double longtitudeRead = fields.readDouble(LONGTITUDE);
// final Double latitudeRead = fields.readDouble(LATITUDE);
// final Point location = getLocationPoint(longtitudeRead, latitudeRead);
//
// final String name = fields.readString(NAME);
// final String zipCode = fields.readString(ZIP_CODE);
// final String city = fields.readString(CITY);
// final String street = fields.readString(STREET_ADDRESS);
// final String productsString = fields.readString(FEATURES_PRODUCTS);
// final Collection<String> products = Arrays.asList(productsString.split(","));
// final String servicesString = fields.readString(FEATURES_SERVICES);
// final Collection<String> services = Arrays.asList(servicesString.split(","));
// return new StarbucksStore(null, name, zipCode, city, street, products, services, location);
// }
//
// private Point getLocationPoint(final Double longtitudeRead, final Double latitudeRead) {
//
// final int longtitudeCompareMax = MAX_Y.compareTo(longtitudeRead);
// final int longtitudeCompareMin = MIN_Y.compareTo(longtitudeRead);
//
// final int latitudeCompareMax = MAX_X.compareTo(latitudeRead);
// final int latitudeCompareMin = MIN_X.compareTo(latitudeRead);
//
// final Double longtitude;
// final Double latitude;
//
// if (longtitudeCompareMax < 0) {
// longtitude = MAX_Y;
// } else if (longtitudeCompareMin > 0) {
// longtitude = MIN_Y;
// } else {
// longtitude = longtitudeRead;
// }
//
// if (latitudeCompareMax < 0) {
// latitude = MAX_X;
// } else if (latitudeCompareMin > 0) {
// latitude = MIN_X;
// } else {
// latitude = latitudeRead;
// }
// return new Point(latitude, longtitude);
// }
// }
//
//
// }
// Path: spring-data-solr-demo-starbucks/src/main/java/org/tuxdevelop/spring/data/solr/demo/StarbucksApplication.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.tuxdevelop.spring.data.solr.demo.util.SolrInitializer;
import javax.annotation.PostConstruct;
package org.tuxdevelop.spring.data.solr.demo;
@SpringBootApplication
@EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
public class StarbucksApplication {
@Autowired
|
private SolrInitializer solrInitializer;
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-data-rest/src/test/java/org/tuxdevelop/spring/data/solr/demo/configuration/ITConfiguration.java
|
// Path: spring-data-solr-demo-data-rest/src/main/java/org/tuxdevelop/spring/data/solr/demo/SolrDataRestApplication.java
// @SpringBootApplication
// @EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
// public class SolrDataRestApplication {
//
// @Autowired
// private SolrInitializer solrInitializer;
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// public static void main(final String[] args) {
// SpringApplication.run(SolrDataRestApplication.class, args);
// }
//
// @PostConstruct
// public void init() throws Exception {
// solrInitializer.importStarbucks();
// }
//
// @PreDestroy
// public void deleteAll() {
// starbucksStoreRepository.deleteAll();
// }
// }
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.springframework.web.client.RestTemplate;
import org.tuxdevelop.spring.data.solr.demo.SolrDataRestApplication;
|
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Configuration
@EnableAutoConfiguration
@EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value =
|
// Path: spring-data-solr-demo-data-rest/src/main/java/org/tuxdevelop/spring/data/solr/demo/SolrDataRestApplication.java
// @SpringBootApplication
// @EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
// public class SolrDataRestApplication {
//
// @Autowired
// private SolrInitializer solrInitializer;
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// public static void main(final String[] args) {
// SpringApplication.run(SolrDataRestApplication.class, args);
// }
//
// @PostConstruct
// public void init() throws Exception {
// solrInitializer.importStarbucks();
// }
//
// @PreDestroy
// public void deleteAll() {
// starbucksStoreRepository.deleteAll();
// }
// }
// Path: spring-data-solr-demo-data-rest/src/test/java/org/tuxdevelop/spring/data/solr/demo/configuration/ITConfiguration.java
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.springframework.web.client.RestTemplate;
import org.tuxdevelop.spring.data.solr.demo.SolrDataRestApplication;
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Configuration
@EnableAutoConfiguration
@EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
@ComponentScan(excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value =
|
SolrDataRestApplication.class))
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-common/src/test/java/org/tuxdevelop/spring/data/solr/demo/configuration/ConfigurationSetupIT.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
// @Slf4j
// @Component
// public class SolrInitializer {
//
// private static final String LONGTITUDE = "Longitude";
// private static final String LATITUDE = "Latitude";
// private static final String ZIP_CODE = "Zip";
// private static final String NAME = "Name";
// private static final String CITY = "City";
// private static final String STREET_ADDRESS = "Street Address";
// private static final String FEATURES_PRODUCTS = "Features - Products";
// private static final String FEATURES_SERVICES = "Features - Service";
//
// private static final Double MAX_X = 180.0;
// private static final Double MIN_X = -180.0;
//
// private static final Double MAX_Y = 90.0;
// private static final Double MIN_Y = -90.0;
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// public void importStarbucks() throws Exception {
// final List<List<StarbucksStore>> stores = importStores();
// for (List<StarbucksStore> starbucksStoreList : stores) {
// try {
// starbucksStoreRepository.save(starbucksStoreList);
// } catch (UncategorizedSolrException e) {
// log.error(e.getMessage());
// }
// }
//
// }
//
// private List<List<StarbucksStore>> importStores() throws Exception {
// final ClassPathResource resource = new ClassPathResource("starbucks.csv");
// final Scanner scanner = new Scanner(resource.getInputStream());
// final String line = scanner.nextLine();
// scanner.close();
//
// final FlatFileItemReader<StarbucksStore> itemReader = new FlatFileItemReader<StarbucksStore>();
// itemReader.setResource(resource);
//
// // DelimitedLineTokenizer defaults to comma as its delimiter
// final DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
// tokenizer.setNames(line.split(","));
// tokenizer.setStrict(false);
//
// final DefaultLineMapper<StarbucksStore> lineMapper = new DefaultLineMapper<StarbucksStore>();
// lineMapper.setLineTokenizer(tokenizer);
// lineMapper.setFieldSetMapper(StoreFieldSetMapper.INSTANCE);
// itemReader.setLineMapper(lineMapper);
// itemReader.setRecordSeparatorPolicy(new DefaultRecordSeparatorPolicy());
// itemReader.setLinesToSkip(1);
// itemReader.open(new ExecutionContext());
// final List<List<StarbucksStore>> stores = new LinkedList<>();
// List<StarbucksStore> starbucksStoreList = new LinkedList<>();
// StarbucksStore starbucksStore;
// int id = 1;
// int currentCount = 1;
// do {
// starbucksStore = itemReader.read();
// if (starbucksStore != null) {
// starbucksStore.setId(String.valueOf(id));
// starbucksStoreList.add(starbucksStore);
// id++;
// currentCount++;
// }
// if (currentCount == 1000) {
// stores.add(new LinkedList<>(starbucksStoreList));
// currentCount = 1;
// starbucksStoreList = new LinkedList<>();
// }
// } while (starbucksStore != null);
//
// return stores;
// }
//
// private enum StoreFieldSetMapper implements FieldSetMapper<StarbucksStore> {
//
// INSTANCE;
//
// @Override
// public StarbucksStore mapFieldSet(FieldSet fields) throws BindException {
// final Double longtitudeRead = fields.readDouble(LONGTITUDE);
// final Double latitudeRead = fields.readDouble(LATITUDE);
// final Point location = getLocationPoint(longtitudeRead, latitudeRead);
//
// final String name = fields.readString(NAME);
// final String zipCode = fields.readString(ZIP_CODE);
// final String city = fields.readString(CITY);
// final String street = fields.readString(STREET_ADDRESS);
// final String productsString = fields.readString(FEATURES_PRODUCTS);
// final Collection<String> products = Arrays.asList(productsString.split(","));
// final String servicesString = fields.readString(FEATURES_SERVICES);
// final Collection<String> services = Arrays.asList(servicesString.split(","));
// return new StarbucksStore(null, name, zipCode, city, street, products, services, location);
// }
//
// private Point getLocationPoint(final Double longtitudeRead, final Double latitudeRead) {
//
// final int longtitudeCompareMax = MAX_Y.compareTo(longtitudeRead);
// final int longtitudeCompareMin = MIN_Y.compareTo(longtitudeRead);
//
// final int latitudeCompareMax = MAX_X.compareTo(latitudeRead);
// final int latitudeCompareMin = MIN_X.compareTo(latitudeRead);
//
// final Double longtitude;
// final Double latitude;
//
// if (longtitudeCompareMax < 0) {
// longtitude = MAX_Y;
// } else if (longtitudeCompareMin > 0) {
// longtitude = MIN_Y;
// } else {
// longtitude = longtitudeRead;
// }
//
// if (latitudeCompareMax < 0) {
// latitude = MAX_X;
// } else if (latitudeCompareMin > 0) {
// latitude = MIN_X;
// } else {
// latitude = latitudeRead;
// }
// return new Point(latitude, longtitude);
// }
// }
//
//
// }
|
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.tuxdevelop.spring.data.solr.demo.util.SolrInitializer;
|
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = ITConfiguration.class)
public class ConfigurationSetupIT {
@Autowired
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
// @Slf4j
// @Component
// public class SolrInitializer {
//
// private static final String LONGTITUDE = "Longitude";
// private static final String LATITUDE = "Latitude";
// private static final String ZIP_CODE = "Zip";
// private static final String NAME = "Name";
// private static final String CITY = "City";
// private static final String STREET_ADDRESS = "Street Address";
// private static final String FEATURES_PRODUCTS = "Features - Products";
// private static final String FEATURES_SERVICES = "Features - Service";
//
// private static final Double MAX_X = 180.0;
// private static final Double MIN_X = -180.0;
//
// private static final Double MAX_Y = 90.0;
// private static final Double MIN_Y = -90.0;
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// public void importStarbucks() throws Exception {
// final List<List<StarbucksStore>> stores = importStores();
// for (List<StarbucksStore> starbucksStoreList : stores) {
// try {
// starbucksStoreRepository.save(starbucksStoreList);
// } catch (UncategorizedSolrException e) {
// log.error(e.getMessage());
// }
// }
//
// }
//
// private List<List<StarbucksStore>> importStores() throws Exception {
// final ClassPathResource resource = new ClassPathResource("starbucks.csv");
// final Scanner scanner = new Scanner(resource.getInputStream());
// final String line = scanner.nextLine();
// scanner.close();
//
// final FlatFileItemReader<StarbucksStore> itemReader = new FlatFileItemReader<StarbucksStore>();
// itemReader.setResource(resource);
//
// // DelimitedLineTokenizer defaults to comma as its delimiter
// final DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
// tokenizer.setNames(line.split(","));
// tokenizer.setStrict(false);
//
// final DefaultLineMapper<StarbucksStore> lineMapper = new DefaultLineMapper<StarbucksStore>();
// lineMapper.setLineTokenizer(tokenizer);
// lineMapper.setFieldSetMapper(StoreFieldSetMapper.INSTANCE);
// itemReader.setLineMapper(lineMapper);
// itemReader.setRecordSeparatorPolicy(new DefaultRecordSeparatorPolicy());
// itemReader.setLinesToSkip(1);
// itemReader.open(new ExecutionContext());
// final List<List<StarbucksStore>> stores = new LinkedList<>();
// List<StarbucksStore> starbucksStoreList = new LinkedList<>();
// StarbucksStore starbucksStore;
// int id = 1;
// int currentCount = 1;
// do {
// starbucksStore = itemReader.read();
// if (starbucksStore != null) {
// starbucksStore.setId(String.valueOf(id));
// starbucksStoreList.add(starbucksStore);
// id++;
// currentCount++;
// }
// if (currentCount == 1000) {
// stores.add(new LinkedList<>(starbucksStoreList));
// currentCount = 1;
// starbucksStoreList = new LinkedList<>();
// }
// } while (starbucksStore != null);
//
// return stores;
// }
//
// private enum StoreFieldSetMapper implements FieldSetMapper<StarbucksStore> {
//
// INSTANCE;
//
// @Override
// public StarbucksStore mapFieldSet(FieldSet fields) throws BindException {
// final Double longtitudeRead = fields.readDouble(LONGTITUDE);
// final Double latitudeRead = fields.readDouble(LATITUDE);
// final Point location = getLocationPoint(longtitudeRead, latitudeRead);
//
// final String name = fields.readString(NAME);
// final String zipCode = fields.readString(ZIP_CODE);
// final String city = fields.readString(CITY);
// final String street = fields.readString(STREET_ADDRESS);
// final String productsString = fields.readString(FEATURES_PRODUCTS);
// final Collection<String> products = Arrays.asList(productsString.split(","));
// final String servicesString = fields.readString(FEATURES_SERVICES);
// final Collection<String> services = Arrays.asList(servicesString.split(","));
// return new StarbucksStore(null, name, zipCode, city, street, products, services, location);
// }
//
// private Point getLocationPoint(final Double longtitudeRead, final Double latitudeRead) {
//
// final int longtitudeCompareMax = MAX_Y.compareTo(longtitudeRead);
// final int longtitudeCompareMin = MIN_Y.compareTo(longtitudeRead);
//
// final int latitudeCompareMax = MAX_X.compareTo(latitudeRead);
// final int latitudeCompareMin = MIN_X.compareTo(latitudeRead);
//
// final Double longtitude;
// final Double latitude;
//
// if (longtitudeCompareMax < 0) {
// longtitude = MAX_Y;
// } else if (longtitudeCompareMin > 0) {
// longtitude = MIN_Y;
// } else {
// longtitude = longtitudeRead;
// }
//
// if (latitudeCompareMax < 0) {
// latitude = MAX_X;
// } else if (latitudeCompareMin > 0) {
// latitude = MIN_X;
// } else {
// latitude = latitudeRead;
// }
// return new Point(latitude, longtitude);
// }
// }
//
//
// }
// Path: spring-data-solr-demo-common/src/test/java/org/tuxdevelop/spring/data/solr/demo/configuration/ConfigurationSetupIT.java
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.tuxdevelop.spring.data.solr.demo.util.SolrInitializer;
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = ITConfiguration.class)
public class ConfigurationSetupIT {
@Autowired
|
private SolrInitializer solrInitializer;
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-common/src/test/java/org/tuxdevelop/spring/data/solr/demo/configuration/ITConfiguration.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import javax.annotation.PreDestroy;
|
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Configuration
@EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
@ComponentScan(basePackages = "org.tuxdevelop.spring.data.solr.demo")
public class ITConfiguration {
@Bean
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
final PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
propertyPlaceholderConfigurer.setLocation(new ClassPathResource("application.properties"));
return propertyPlaceholderConfigurer;
}
@PreDestroy
@Autowired
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
// Path: spring-data-solr-demo-common/src/test/java/org/tuxdevelop/spring/data/solr/demo/configuration/ITConfiguration.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import javax.annotation.PreDestroy;
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Configuration
@EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
@ComponentScan(basePackages = "org.tuxdevelop.spring.data.solr.demo")
public class ITConfiguration {
@Bean
public PropertyPlaceholderConfigurer propertyPlaceholderConfigurer() {
final PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
propertyPlaceholderConfigurer.setLocation(new ClassPathResource("application.properties"));
return propertyPlaceholderConfigurer;
}
@PreDestroy
@Autowired
|
public void deleteAll(final StarbucksStoreRepository starbucksStoreRepository) {
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/impl/StarbucksStoreRepositoryImpl.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreCrudOperations.java
// public interface StarbucksStoreCrudOperations {
//
// void updateProducts(final String id, final Collection<String> products);
//
// Collection<StarbucksStore> findStoreByNameFilterQuery(@Param("name") final String name);
//
// FacetPage<StarbucksStore> findFacetOnNameSolrTemplate(@Param("products") final List<String> products);
//
// GroupPage<StarbucksStore> groupByZipCode(@Param("products") final List<String> products);
//
// GroupPage<StarbucksStore> findByLocationAndgroupByCity(final Point point, final Distance distance, final Integer
// pageNumber);
//
// GroupPage<StarbucksStore> groupByCity();
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.data.solr.core.query.*;
import org.springframework.data.solr.core.query.result.FacetPage;
import org.springframework.data.solr.core.query.result.GroupPage;
import org.springframework.data.solr.core.query.result.ScoredPage;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreCrudOperations;
import java.util.Collection;
import java.util.List;
|
package org.tuxdevelop.spring.data.solr.demo.repository.impl;
public class StarbucksStoreRepositoryImpl implements StarbucksStoreCrudOperations {
@Autowired
private SolrTemplate solrTemplate;
@Override
public void updateProducts(String id, Collection<String> products) {
final PartialUpdate partialUpdate = new PartialUpdate("id", id);
partialUpdate.add("products", products);
solrTemplate.saveBean(partialUpdate);
solrTemplate.commit();
}
@Override
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreCrudOperations.java
// public interface StarbucksStoreCrudOperations {
//
// void updateProducts(final String id, final Collection<String> products);
//
// Collection<StarbucksStore> findStoreByNameFilterQuery(@Param("name") final String name);
//
// FacetPage<StarbucksStore> findFacetOnNameSolrTemplate(@Param("products") final List<String> products);
//
// GroupPage<StarbucksStore> groupByZipCode(@Param("products") final List<String> products);
//
// GroupPage<StarbucksStore> findByLocationAndgroupByCity(final Point point, final Distance distance, final Integer
// pageNumber);
//
// GroupPage<StarbucksStore> groupByCity();
// }
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/impl/StarbucksStoreRepositoryImpl.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.solr.core.SolrTemplate;
import org.springframework.data.solr.core.query.*;
import org.springframework.data.solr.core.query.result.FacetPage;
import org.springframework.data.solr.core.query.result.GroupPage;
import org.springframework.data.solr.core.query.result.ScoredPage;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreCrudOperations;
import java.util.Collection;
import java.util.List;
package org.tuxdevelop.spring.data.solr.demo.repository.impl;
public class StarbucksStoreRepositoryImpl implements StarbucksStoreCrudOperations {
@Autowired
private SolrTemplate solrTemplate;
@Override
public void updateProducts(String id, Collection<String> products) {
final PartialUpdate partialUpdate = new PartialUpdate("id", id);
partialUpdate.add("products", products);
solrTemplate.saveBean(partialUpdate);
solrTemplate.commit();
}
@Override
|
public Collection<StarbucksStore> findStoreByNameFilterQuery(final String name) {
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-jaxrs/src/test/java/org/tuxdevelop/spring/data/solr/demo/configuration/SystemITConfiguration.java
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/StarbucksJaxRSApplication.java
// @SpringBootApplication
// @EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
// public class StarbucksJaxRSApplication {
//
// @Autowired
// private SolrInitializer solrInitializer;
//
// public static void main(final String[] args) {
// SpringApplication.run(StarbucksJaxRSApplication.class, args);
// }
//
// @PostConstruct
// public void init() throws Exception {
// solrInitializer.importStarbucks();
// }
//
//
// }
//
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
|
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.proxy.WebResourceFactory;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.tuxdevelop.spring.data.solr.demo.StarbucksJaxRSApplication;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
|
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Configuration
@ComponentScan(excludeFilters = {@ComponentScan.Filter(value = StarbucksJaxRSApplication.class, type = FilterType
.ASSIGNABLE_TYPE), @ComponentScan.Filter(value = ITConfiguration.class, type = FilterType.ASSIGNABLE_TYPE),
@ComponentScan.Filter(value = SolrConfiguration.class, type = FilterType.ASSIGNABLE_TYPE)})
public class SystemITConfiguration {
private static final String PORT = "9011";
@Bean
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/StarbucksJaxRSApplication.java
// @SpringBootApplication
// @EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
// public class StarbucksJaxRSApplication {
//
// @Autowired
// private SolrInitializer solrInitializer;
//
// public static void main(final String[] args) {
// SpringApplication.run(StarbucksJaxRSApplication.class, args);
// }
//
// @PostConstruct
// public void init() throws Exception {
// solrInitializer.importStarbucks();
// }
//
//
// }
//
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
// Path: spring-data-solr-demo-jaxrs/src/test/java/org/tuxdevelop/spring/data/solr/demo/configuration/SystemITConfiguration.java
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.client.proxy.WebResourceFactory;
import org.glassfish.jersey.jackson.JacksonFeature;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.tuxdevelop.spring.data.solr.demo.StarbucksJaxRSApplication;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Configuration
@ComponentScan(excludeFilters = {@ComponentScan.Filter(value = StarbucksJaxRSApplication.class, type = FilterType
.ASSIGNABLE_TYPE), @ComponentScan.Filter(value = ITConfiguration.class, type = FilterType.ASSIGNABLE_TYPE),
@ComponentScan.Filter(value = SolrConfiguration.class, type = FilterType.ASSIGNABLE_TYPE)})
public class SystemITConfiguration {
private static final String PORT = "9011";
@Bean
|
public StoreService storeService() {
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/configuration/JerseyConfiguration.java
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/service/StoreServiceBean.java
// @Component
// public class StoreServiceBean implements StoreService {
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// @Override
// public StarbucksStore add(final StarbucksStore starbucksStore) {
// final long count = starbucksStoreRepository.count();
// final String id = new String("" + (count + 1));
// starbucksStore.setId(id);
// return starbucksStoreRepository.save(starbucksStore);
// }
//
// @Override
// public StarbucksStore get(final String id) {
// return starbucksStoreRepository.findOne(id);
// }
//
// @Override
// public void delete(final String id) {
// starbucksStoreRepository.delete(id);
// }
//
// @Override
// public Collection<StarbucksStore> findByName(String name) {
// return starbucksStoreRepository.findByName(name);
// }
//
// @Override
// public Collection<StarbucksStore> findNear(final Double longtitude, final Double latitude, final Double distance,
// final List<String> products) {
// final Point point = new Point(latitude, longtitude);
// final Distance dist = new Distance(distance);
// final Collection<StarbucksStore> starbucksStores;
// if (products == null || products.isEmpty()) {
// starbucksStores = starbucksStoreRepository.findByLocationNear(point, dist);
// } else {
// starbucksStores = starbucksStoreRepository.findByProductsInAndLocationNear(products, point, dist);
// }
// return starbucksStores;
// }
// }
|
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.context.annotation.Configuration;
import org.tuxdevelop.spring.data.solr.demo.service.StoreServiceBean;
import javax.ws.rs.ApplicationPath;
|
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Configuration
@ApplicationPath("/dataSolr/api")
public class JerseyConfiguration extends ResourceConfig {
public JerseyConfiguration() {
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/service/StoreServiceBean.java
// @Component
// public class StoreServiceBean implements StoreService {
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// @Override
// public StarbucksStore add(final StarbucksStore starbucksStore) {
// final long count = starbucksStoreRepository.count();
// final String id = new String("" + (count + 1));
// starbucksStore.setId(id);
// return starbucksStoreRepository.save(starbucksStore);
// }
//
// @Override
// public StarbucksStore get(final String id) {
// return starbucksStoreRepository.findOne(id);
// }
//
// @Override
// public void delete(final String id) {
// starbucksStoreRepository.delete(id);
// }
//
// @Override
// public Collection<StarbucksStore> findByName(String name) {
// return starbucksStoreRepository.findByName(name);
// }
//
// @Override
// public Collection<StarbucksStore> findNear(final Double longtitude, final Double latitude, final Double distance,
// final List<String> products) {
// final Point point = new Point(latitude, longtitude);
// final Distance dist = new Distance(distance);
// final Collection<StarbucksStore> starbucksStores;
// if (products == null || products.isEmpty()) {
// starbucksStores = starbucksStoreRepository.findByLocationNear(point, dist);
// } else {
// starbucksStores = starbucksStoreRepository.findByProductsInAndLocationNear(products, point, dist);
// }
// return starbucksStores;
// }
// }
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/configuration/JerseyConfiguration.java
import org.glassfish.jersey.jackson.JacksonFeature;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.context.annotation.Configuration;
import org.tuxdevelop.spring.data.solr.demo.service.StoreServiceBean;
import javax.ws.rs.ApplicationPath;
package org.tuxdevelop.spring.data.solr.demo.configuration;
@Configuration
@ApplicationPath("/dataSolr/api")
public class JerseyConfiguration extends ResourceConfig {
public JerseyConfiguration() {
|
register(StoreServiceBean.class);
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreCrudOperations.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
|
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.repository.query.Param;
import org.springframework.data.solr.core.query.result.FacetPage;
import org.springframework.data.solr.core.query.result.GroupPage;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import java.util.Collection;
import java.util.List;
|
package org.tuxdevelop.spring.data.solr.demo.repository;
public interface StarbucksStoreCrudOperations {
void updateProducts(final String id, final Collection<String> products);
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreCrudOperations.java
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.data.repository.query.Param;
import org.springframework.data.solr.core.query.result.FacetPage;
import org.springframework.data.solr.core.query.result.GroupPage;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import java.util.Collection;
import java.util.List;
package org.tuxdevelop.spring.data.solr.demo.repository;
public interface StarbucksStoreCrudOperations {
void updateProducts(final String id, final Collection<String> products);
|
Collection<StarbucksStore> findStoreByNameFilterQuery(@Param("name") final String name);
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/service/StoreServiceBean.java
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.stereotype.Component;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import java.util.Collection;
import java.util.List;
|
package org.tuxdevelop.spring.data.solr.demo.service;
@Component
public class StoreServiceBean implements StoreService {
@Autowired
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/service/StoreServiceBean.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.stereotype.Component;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import java.util.Collection;
import java.util.List;
package org.tuxdevelop.spring.data.solr.demo.service;
@Component
public class StoreServiceBean implements StoreService {
@Autowired
|
private StarbucksStoreRepository starbucksStoreRepository;
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/service/StoreServiceBean.java
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.stereotype.Component;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import java.util.Collection;
import java.util.List;
|
package org.tuxdevelop.spring.data.solr.demo.service;
@Component
public class StoreServiceBean implements StoreService {
@Autowired
private StarbucksStoreRepository starbucksStoreRepository;
@Override
|
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
// @Path("/stores")
// public interface StoreService {
//
// String SEARCH = "/search";
//
// @POST
// @Path("/")
// @Produces("application/json")
// @Consumes("application/json")
// StarbucksStore add(final StarbucksStore starbucksStore);
//
// @GET
// @Path("/{id}")
// @Produces("application/json")
// StarbucksStore get(@PathParam("id") String id);
//
// @DELETE
// @Path("/{id}")
// void delete(@PathParam("id") final String id);
//
// @GET
// @Path(SEARCH + "/byName")
// @Produces("application/json")
// Collection<StarbucksStore> findByName(@QueryParam("name") final String name);
//
// @GET
// @Path(SEARCH + "/near")
// @Produces("application/json")
// Collection<StarbucksStore> findNear(@QueryParam("longtitude") final Double longtitude,
// @QueryParam("latitude") final Double latitude,
// @QueryParam("distance") final Double distance,
// @QueryParam("products") final List<String> products);
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
//
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/repository/StarbucksStoreRepository.java
// public interface StarbucksStoreRepository extends SolrCrudRepository<StarbucksStore, String>, StarbucksStoreCrudOperations {
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByName(@Param("name") final String name);
//
//
// /**
// * find all stores whoch provides the given products
// *
// * @param products products query parameter
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsIn(@Param("products") final Collection<String> products);
//
// /**
// * find all stores which provides the given products and are next to a geo point and given distance
// *
// * @param products products query parameter
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByProductsInAndLocationNear(@Param("products") final Collection<String> products, @Param
// ("point") final Point point, final @Param("distance") Distance distance);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query("name:?0")
// Collection<StarbucksStore> findByNameQuery(@Param("name") final String name);
//
// /**
// * find stores by name
// *
// * @param name the name of store
// * @return a collection of stores, where the input match
// */
// @Query(value = "*:*", filters = {"name:=?0"})
// Collection<StarbucksStore> findByNameFilterQuery(@Param("name") final String name);
//
// /**
// * find all stores which are next to a geo point and given distance
// *
// * @param point geo location
// * @param distance radius distance to the geo point
// * @return a collection of stores, where the input match
// */
// Collection<StarbucksStore> findByLocationNear(@Param("point") final Point point, @Param("distance") final Distance distance);
//
// /**
// * find all stores of a give zip code
// *
// * @param zipCode query parameter
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "zipCode:?0")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByZipCodeFacetOnProducts(@Param("zipCode") final String zipCode, final Pageable page);
//
// /**
// * find all stores
// *
// * @param page input page
// * @return a facet of the products of stores, where the input matches
// */
// @Query(value = "*:*")
// @Facet(fields = {"products"})
// FacetPage<StarbucksStore> findByFacetOnProducts(final Pageable page);
//
// /**
// * find all stores which provides the given products
// *
// * @param products query param
// * @param page input page
// * @return a facet of the names of stores, where the input matches
// */
// @Query(value = "*:*", filters = "products:?0")
// @Facet(fields = {"name"})
// FacetPage<StarbucksStore> findFacetOnName(@Param("products") final List<String> products, final Pageable page);
// }
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/service/StoreServiceBean.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.geo.Distance;
import org.springframework.data.geo.Point;
import org.springframework.stereotype.Component;
import org.tuxdevelop.spring.data.solr.demo.api.StoreService;
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import org.tuxdevelop.spring.data.solr.demo.repository.StarbucksStoreRepository;
import java.util.Collection;
import java.util.List;
package org.tuxdevelop.spring.data.solr.demo.service;
@Component
public class StoreServiceBean implements StoreService {
@Autowired
private StarbucksStoreRepository starbucksStoreRepository;
@Override
|
public StarbucksStore add(final StarbucksStore starbucksStore) {
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
|
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import javax.ws.rs.*;
import java.util.Collection;
import java.util.List;
|
package org.tuxdevelop.spring.data.solr.demo.api;
@Path("/stores")
public interface StoreService {
String SEARCH = "/search";
@POST
@Path("/")
@Produces("application/json")
@Consumes("application/json")
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/domain/StarbucksStore.java
// @Data
// @AllArgsConstructor
// @NoArgsConstructor
// @SolrDocument
// @XmlRootElement
// public class StarbucksStore {
//
// @Id
// @Field("id")
// private String id;
// @Field("name")
// private String name;
// @Field("zipCode")
// private String zipCode;
// @Field("city")
// private String city;
// @Field("street")
// private String street;
// @Field("products")
// private Collection<String> products;
// @Field("services")
// private Collection<String> services;
// @JsonIgnore
// @Field("location")
// private Point location;
//
// }
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/api/StoreService.java
import org.tuxdevelop.spring.data.solr.demo.domain.StarbucksStore;
import javax.ws.rs.*;
import java.util.Collection;
import java.util.List;
package org.tuxdevelop.spring.data.solr.demo.api;
@Path("/stores")
public interface StoreService {
String SEARCH = "/search";
@POST
@Path("/")
@Produces("application/json")
@Consumes("application/json")
|
StarbucksStore add(final StarbucksStore starbucksStore);
|
tuxdevelop/spring-data-solr-demo
|
spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/StarbucksJaxRSApplication.java
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
// @Slf4j
// @Component
// public class SolrInitializer {
//
// private static final String LONGTITUDE = "Longitude";
// private static final String LATITUDE = "Latitude";
// private static final String ZIP_CODE = "Zip";
// private static final String NAME = "Name";
// private static final String CITY = "City";
// private static final String STREET_ADDRESS = "Street Address";
// private static final String FEATURES_PRODUCTS = "Features - Products";
// private static final String FEATURES_SERVICES = "Features - Service";
//
// private static final Double MAX_X = 180.0;
// private static final Double MIN_X = -180.0;
//
// private static final Double MAX_Y = 90.0;
// private static final Double MIN_Y = -90.0;
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// public void importStarbucks() throws Exception {
// final List<List<StarbucksStore>> stores = importStores();
// for (List<StarbucksStore> starbucksStoreList : stores) {
// try {
// starbucksStoreRepository.save(starbucksStoreList);
// } catch (UncategorizedSolrException e) {
// log.error(e.getMessage());
// }
// }
//
// }
//
// private List<List<StarbucksStore>> importStores() throws Exception {
// final ClassPathResource resource = new ClassPathResource("starbucks.csv");
// final Scanner scanner = new Scanner(resource.getInputStream());
// final String line = scanner.nextLine();
// scanner.close();
//
// final FlatFileItemReader<StarbucksStore> itemReader = new FlatFileItemReader<StarbucksStore>();
// itemReader.setResource(resource);
//
// // DelimitedLineTokenizer defaults to comma as its delimiter
// final DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
// tokenizer.setNames(line.split(","));
// tokenizer.setStrict(false);
//
// final DefaultLineMapper<StarbucksStore> lineMapper = new DefaultLineMapper<StarbucksStore>();
// lineMapper.setLineTokenizer(tokenizer);
// lineMapper.setFieldSetMapper(StoreFieldSetMapper.INSTANCE);
// itemReader.setLineMapper(lineMapper);
// itemReader.setRecordSeparatorPolicy(new DefaultRecordSeparatorPolicy());
// itemReader.setLinesToSkip(1);
// itemReader.open(new ExecutionContext());
// final List<List<StarbucksStore>> stores = new LinkedList<>();
// List<StarbucksStore> starbucksStoreList = new LinkedList<>();
// StarbucksStore starbucksStore;
// int id = 1;
// int currentCount = 1;
// do {
// starbucksStore = itemReader.read();
// if (starbucksStore != null) {
// starbucksStore.setId(String.valueOf(id));
// starbucksStoreList.add(starbucksStore);
// id++;
// currentCount++;
// }
// if (currentCount == 1000) {
// stores.add(new LinkedList<>(starbucksStoreList));
// currentCount = 1;
// starbucksStoreList = new LinkedList<>();
// }
// } while (starbucksStore != null);
//
// return stores;
// }
//
// private enum StoreFieldSetMapper implements FieldSetMapper<StarbucksStore> {
//
// INSTANCE;
//
// @Override
// public StarbucksStore mapFieldSet(FieldSet fields) throws BindException {
// final Double longtitudeRead = fields.readDouble(LONGTITUDE);
// final Double latitudeRead = fields.readDouble(LATITUDE);
// final Point location = getLocationPoint(longtitudeRead, latitudeRead);
//
// final String name = fields.readString(NAME);
// final String zipCode = fields.readString(ZIP_CODE);
// final String city = fields.readString(CITY);
// final String street = fields.readString(STREET_ADDRESS);
// final String productsString = fields.readString(FEATURES_PRODUCTS);
// final Collection<String> products = Arrays.asList(productsString.split(","));
// final String servicesString = fields.readString(FEATURES_SERVICES);
// final Collection<String> services = Arrays.asList(servicesString.split(","));
// return new StarbucksStore(null, name, zipCode, city, street, products, services, location);
// }
//
// private Point getLocationPoint(final Double longtitudeRead, final Double latitudeRead) {
//
// final int longtitudeCompareMax = MAX_Y.compareTo(longtitudeRead);
// final int longtitudeCompareMin = MIN_Y.compareTo(longtitudeRead);
//
// final int latitudeCompareMax = MAX_X.compareTo(latitudeRead);
// final int latitudeCompareMin = MIN_X.compareTo(latitudeRead);
//
// final Double longtitude;
// final Double latitude;
//
// if (longtitudeCompareMax < 0) {
// longtitude = MAX_Y;
// } else if (longtitudeCompareMin > 0) {
// longtitude = MIN_Y;
// } else {
// longtitude = longtitudeRead;
// }
//
// if (latitudeCompareMax < 0) {
// latitude = MAX_X;
// } else if (latitudeCompareMin > 0) {
// latitude = MIN_X;
// } else {
// latitude = latitudeRead;
// }
// return new Point(latitude, longtitude);
// }
// }
//
//
// }
|
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.tuxdevelop.spring.data.solr.demo.util.SolrInitializer;
import javax.annotation.PostConstruct;
|
package org.tuxdevelop.spring.data.solr.demo;
@SpringBootApplication
@EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
public class StarbucksJaxRSApplication {
@Autowired
|
// Path: spring-data-solr-demo-common/src/main/java/org/tuxdevelop/spring/data/solr/demo/util/SolrInitializer.java
// @Slf4j
// @Component
// public class SolrInitializer {
//
// private static final String LONGTITUDE = "Longitude";
// private static final String LATITUDE = "Latitude";
// private static final String ZIP_CODE = "Zip";
// private static final String NAME = "Name";
// private static final String CITY = "City";
// private static final String STREET_ADDRESS = "Street Address";
// private static final String FEATURES_PRODUCTS = "Features - Products";
// private static final String FEATURES_SERVICES = "Features - Service";
//
// private static final Double MAX_X = 180.0;
// private static final Double MIN_X = -180.0;
//
// private static final Double MAX_Y = 90.0;
// private static final Double MIN_Y = -90.0;
//
// @Autowired
// private StarbucksStoreRepository starbucksStoreRepository;
//
// public void importStarbucks() throws Exception {
// final List<List<StarbucksStore>> stores = importStores();
// for (List<StarbucksStore> starbucksStoreList : stores) {
// try {
// starbucksStoreRepository.save(starbucksStoreList);
// } catch (UncategorizedSolrException e) {
// log.error(e.getMessage());
// }
// }
//
// }
//
// private List<List<StarbucksStore>> importStores() throws Exception {
// final ClassPathResource resource = new ClassPathResource("starbucks.csv");
// final Scanner scanner = new Scanner(resource.getInputStream());
// final String line = scanner.nextLine();
// scanner.close();
//
// final FlatFileItemReader<StarbucksStore> itemReader = new FlatFileItemReader<StarbucksStore>();
// itemReader.setResource(resource);
//
// // DelimitedLineTokenizer defaults to comma as its delimiter
// final DelimitedLineTokenizer tokenizer = new DelimitedLineTokenizer();
// tokenizer.setNames(line.split(","));
// tokenizer.setStrict(false);
//
// final DefaultLineMapper<StarbucksStore> lineMapper = new DefaultLineMapper<StarbucksStore>();
// lineMapper.setLineTokenizer(tokenizer);
// lineMapper.setFieldSetMapper(StoreFieldSetMapper.INSTANCE);
// itemReader.setLineMapper(lineMapper);
// itemReader.setRecordSeparatorPolicy(new DefaultRecordSeparatorPolicy());
// itemReader.setLinesToSkip(1);
// itemReader.open(new ExecutionContext());
// final List<List<StarbucksStore>> stores = new LinkedList<>();
// List<StarbucksStore> starbucksStoreList = new LinkedList<>();
// StarbucksStore starbucksStore;
// int id = 1;
// int currentCount = 1;
// do {
// starbucksStore = itemReader.read();
// if (starbucksStore != null) {
// starbucksStore.setId(String.valueOf(id));
// starbucksStoreList.add(starbucksStore);
// id++;
// currentCount++;
// }
// if (currentCount == 1000) {
// stores.add(new LinkedList<>(starbucksStoreList));
// currentCount = 1;
// starbucksStoreList = new LinkedList<>();
// }
// } while (starbucksStore != null);
//
// return stores;
// }
//
// private enum StoreFieldSetMapper implements FieldSetMapper<StarbucksStore> {
//
// INSTANCE;
//
// @Override
// public StarbucksStore mapFieldSet(FieldSet fields) throws BindException {
// final Double longtitudeRead = fields.readDouble(LONGTITUDE);
// final Double latitudeRead = fields.readDouble(LATITUDE);
// final Point location = getLocationPoint(longtitudeRead, latitudeRead);
//
// final String name = fields.readString(NAME);
// final String zipCode = fields.readString(ZIP_CODE);
// final String city = fields.readString(CITY);
// final String street = fields.readString(STREET_ADDRESS);
// final String productsString = fields.readString(FEATURES_PRODUCTS);
// final Collection<String> products = Arrays.asList(productsString.split(","));
// final String servicesString = fields.readString(FEATURES_SERVICES);
// final Collection<String> services = Arrays.asList(servicesString.split(","));
// return new StarbucksStore(null, name, zipCode, city, street, products, services, location);
// }
//
// private Point getLocationPoint(final Double longtitudeRead, final Double latitudeRead) {
//
// final int longtitudeCompareMax = MAX_Y.compareTo(longtitudeRead);
// final int longtitudeCompareMin = MIN_Y.compareTo(longtitudeRead);
//
// final int latitudeCompareMax = MAX_X.compareTo(latitudeRead);
// final int latitudeCompareMin = MIN_X.compareTo(latitudeRead);
//
// final Double longtitude;
// final Double latitude;
//
// if (longtitudeCompareMax < 0) {
// longtitude = MAX_Y;
// } else if (longtitudeCompareMin > 0) {
// longtitude = MIN_Y;
// } else {
// longtitude = longtitudeRead;
// }
//
// if (latitudeCompareMax < 0) {
// latitude = MAX_X;
// } else if (latitudeCompareMin > 0) {
// latitude = MIN_X;
// } else {
// latitude = latitudeRead;
// }
// return new Point(latitude, longtitude);
// }
// }
//
//
// }
// Path: spring-data-solr-demo-jaxrs/src/main/java/org/tuxdevelop/spring/data/solr/demo/StarbucksJaxRSApplication.java
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.solr.repository.config.EnableSolrRepositories;
import org.tuxdevelop.spring.data.solr.demo.util.SolrInitializer;
import javax.annotation.PostConstruct;
package org.tuxdevelop.spring.data.solr.demo;
@SpringBootApplication
@EnableSolrRepositories(basePackages = "org.tuxdevelop.spring.data.solr.demo.repository")
public class StarbucksJaxRSApplication {
@Autowired
|
private SolrInitializer solrInitializer;
|
CompEvol/sampled-ancestors
|
src/beast/evolution/speciation/SABirthDeathModel.java
|
// Path: src/beast/evolution/tree/TreeWOffset.java
// public class TreeWOffset extends CalculationNode {
//
// public Input<Tree> treeInput = new Input<Tree> ("tree", "tree topology", Validate.REQUIRED);
// public Input<Double> offsetInput = new Input<Double>("offset", "Starting offset to present, default 0", 0.0);
//
// Tree tree;
// Double oldOffset, offset;
// Double[] oldHeights, leaves_heights;
// int oldMin_leaf, min_leaf;
// private boolean stored = false;
//
// @Override
// public void initAndValidate() {
// tree = treeInput.get();
// offset = offsetInput.get();
//
// leaves_heights = new Double[tree.getLeafNodeCount()];
// for(int i = 0; i < tree.getLeafNodeCount(); i++) {
// double h = tree.getNode(i).getHeight();
// if(h == 0) min_leaf = i;
// leaves_heights[i] = h + offset;
// }
// }
//
// public double getHeightOfNode(int nr) {
// return tree.getNode(nr).getHeight() + offset;
// }
//
// public void setHeightOfLeaf(int nr, double height) {
// store();
//
// double oldOffset = offset;
// if(height < offset) {
// offset = height;
// min_leaf = nr;
// }
// leaves_heights[nr] = height;
// // if we increased the height of the minimum leaf then which one it is may have changed
// if(height > offset && nr == min_leaf) {
// offset = height;
// for(int i = 0; i < leaves_heights.length; i++) {
// if(leaves_heights[i] < offset) {
// min_leaf = i;
// offset = leaves_heights[i];
// }
// }
// }
// // if offset has changed then all heights need to be updated to keep true heights the same
// if(Math.abs(oldOffset - offset) > 0) {
// for(Node n : tree.getNodesAsArray()) n.setHeight(n.getHeight() + oldOffset - offset);
// }
// }
//
// public double getOffset() {
// return offset;
// }
//
// public Tree getTree() {
// return tree;
// }
//
// public void setHeightOfNode(int nr, double height) {
// Node n = tree.getNode(nr);
// if(n.isLeaf()) this.setHeightOfLeaf(nr, height);
// n.setHeight(height - offset);
// }
//
// // for testing purposes
// public double getStoredHeightOfLeaf(int nr) {
// return leaves_heights[nr];
// }
//
// /* This entire section is to work around the fact that this class is modified DURING the operator proposal of SampledNodeDateRandomWalker
// * whereas Beast2 assumes that only state nodes are modified, and that calculation nodes are only updated afterwards
// * So, using the default mechanic will store/restore the modified state not the original one
// * There is probably a better way to do this
// */
//
// @Override
// public void store() {
// super.store();
// if(stored) return;
// oldMin_leaf = min_leaf;
// oldOffset = offset;
// oldHeights = leaves_heights.clone();
// stored = true;
// }
//
// @Override
// public void restore() {
// super.restore();
// min_leaf = oldMin_leaf;
// offset = oldOffset;
// leaves_heights = oldHeights.clone();
// stored = false;
// }
//
// @Override
// public void accept() {
// super.accept();
// stored = false;
// }
// }
|
import beast.core.*;
import beast.core.parameter.IntegerParameter;
import beast.core.parameter.RealParameter;
import beast.core.util.Log;
import beast.evolution.alignment.Taxon;
import beast.evolution.operators.*;
import beast.evolution.tree.Node;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeDistribution;
import beast.evolution.tree.TreeInterface;
import beast.evolution.tree.TreeWOffset;
import java.util.List;
|
package beast.evolution.speciation;
/**
* @author Alexandra Gavryushkina
*/
//The tree density is from: Tanja Stadler et al. "Estimating the Basic Reproductive Number from Viral Sequence Data"
@Description("Calculate tree density under Birth Death Sampling Through Time Model for Epidemics " +
"that is the BDM where an individual is sampled at a time with a constant rate psi" +
" and where an individual becomes noninfectious immediately after the sampling" +
"with a constant probability r")
@Citation(value = "Gavryushkina A, Welch D, Stadler T, Drummond AJ (2014) \n" +
"Bayesian inference of sampled ancestor trees for epidemiology and fossil calibration. \n" +
"PLoS Comput Biol 10(12): e1003919. doi:10.1371/journal.pcbi.1003919",
year = 2014, firstAuthorSurname = "Gavryushkina", DOI="10.1371/journal.pcbi.1003919")
public class SABirthDeathModel extends TreeDistribution {
|
// Path: src/beast/evolution/tree/TreeWOffset.java
// public class TreeWOffset extends CalculationNode {
//
// public Input<Tree> treeInput = new Input<Tree> ("tree", "tree topology", Validate.REQUIRED);
// public Input<Double> offsetInput = new Input<Double>("offset", "Starting offset to present, default 0", 0.0);
//
// Tree tree;
// Double oldOffset, offset;
// Double[] oldHeights, leaves_heights;
// int oldMin_leaf, min_leaf;
// private boolean stored = false;
//
// @Override
// public void initAndValidate() {
// tree = treeInput.get();
// offset = offsetInput.get();
//
// leaves_heights = new Double[tree.getLeafNodeCount()];
// for(int i = 0; i < tree.getLeafNodeCount(); i++) {
// double h = tree.getNode(i).getHeight();
// if(h == 0) min_leaf = i;
// leaves_heights[i] = h + offset;
// }
// }
//
// public double getHeightOfNode(int nr) {
// return tree.getNode(nr).getHeight() + offset;
// }
//
// public void setHeightOfLeaf(int nr, double height) {
// store();
//
// double oldOffset = offset;
// if(height < offset) {
// offset = height;
// min_leaf = nr;
// }
// leaves_heights[nr] = height;
// // if we increased the height of the minimum leaf then which one it is may have changed
// if(height > offset && nr == min_leaf) {
// offset = height;
// for(int i = 0; i < leaves_heights.length; i++) {
// if(leaves_heights[i] < offset) {
// min_leaf = i;
// offset = leaves_heights[i];
// }
// }
// }
// // if offset has changed then all heights need to be updated to keep true heights the same
// if(Math.abs(oldOffset - offset) > 0) {
// for(Node n : tree.getNodesAsArray()) n.setHeight(n.getHeight() + oldOffset - offset);
// }
// }
//
// public double getOffset() {
// return offset;
// }
//
// public Tree getTree() {
// return tree;
// }
//
// public void setHeightOfNode(int nr, double height) {
// Node n = tree.getNode(nr);
// if(n.isLeaf()) this.setHeightOfLeaf(nr, height);
// n.setHeight(height - offset);
// }
//
// // for testing purposes
// public double getStoredHeightOfLeaf(int nr) {
// return leaves_heights[nr];
// }
//
// /* This entire section is to work around the fact that this class is modified DURING the operator proposal of SampledNodeDateRandomWalker
// * whereas Beast2 assumes that only state nodes are modified, and that calculation nodes are only updated afterwards
// * So, using the default mechanic will store/restore the modified state not the original one
// * There is probably a better way to do this
// */
//
// @Override
// public void store() {
// super.store();
// if(stored) return;
// oldMin_leaf = min_leaf;
// oldOffset = offset;
// oldHeights = leaves_heights.clone();
// stored = true;
// }
//
// @Override
// public void restore() {
// super.restore();
// min_leaf = oldMin_leaf;
// offset = oldOffset;
// leaves_heights = oldHeights.clone();
// stored = false;
// }
//
// @Override
// public void accept() {
// super.accept();
// stored = false;
// }
// }
// Path: src/beast/evolution/speciation/SABirthDeathModel.java
import beast.core.*;
import beast.core.parameter.IntegerParameter;
import beast.core.parameter.RealParameter;
import beast.core.util.Log;
import beast.evolution.alignment.Taxon;
import beast.evolution.operators.*;
import beast.evolution.tree.Node;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeDistribution;
import beast.evolution.tree.TreeInterface;
import beast.evolution.tree.TreeWOffset;
import java.util.List;
package beast.evolution.speciation;
/**
* @author Alexandra Gavryushkina
*/
//The tree density is from: Tanja Stadler et al. "Estimating the Basic Reproductive Number from Viral Sequence Data"
@Description("Calculate tree density under Birth Death Sampling Through Time Model for Epidemics " +
"that is the BDM where an individual is sampled at a time with a constant rate psi" +
" and where an individual becomes noninfectious immediately after the sampling" +
"with a constant probability r")
@Citation(value = "Gavryushkina A, Welch D, Stadler T, Drummond AJ (2014) \n" +
"Bayesian inference of sampled ancestor trees for epidemiology and fossil calibration. \n" +
"PLoS Comput Biol 10(12): e1003919. doi:10.1371/journal.pcbi.1003919",
year = 2014, firstAuthorSurname = "Gavryushkina", DOI="10.1371/journal.pcbi.1003919")
public class SABirthDeathModel extends TreeDistribution {
|
public Input<TreeWOffset> treeWOffsetInput =
|
CompEvol/sampled-ancestors
|
src/beast/evolution/operators/SampledNodeDateRandomWalker.java
|
// Path: src/beast/evolution/tree/SamplingDate.java
// public class SamplingDate extends BEASTObject {
// public final Input<Taxon> taxonInput = new Input<Taxon>("taxon", "Name of the taxon for which the sampling date distribution is specified.",
// Input.Validate.REQUIRED);
//
// public Input<String> upperInput = new Input<>("upper", "Upper bound for the taxon sampling date");
// public Input<String> lowerInput = new Input<>("lower", "Lower bound for the taxon sampling date");
//
// private double upper, lower;
//
// @Override
// public void initAndValidate() {
// upper=Double.parseDouble(upperInput.get());
// lower=Double.parseDouble(lowerInput.get());
// if (upper < 0 || lower < 0 || upper < lower) {
// throw new IllegalArgumentException("Upper and lower inputs of samplingDate should be both positive and upper should be greater than lower.");
// }
// }
//
// public double getUpper() {
// return upper;
// }
//
// public double getLower() {
// return lower;
// }
//
// public double getRandomFromTheRange() {
// return lower + Randomizer.nextDouble()*(upper - lower);
// }
//
// }
//
// Path: src/beast/evolution/tree/TreeWOffset.java
// public class TreeWOffset extends CalculationNode {
//
// public Input<Tree> treeInput = new Input<Tree> ("tree", "tree topology", Validate.REQUIRED);
// public Input<Double> offsetInput = new Input<Double>("offset", "Starting offset to present, default 0", 0.0);
//
// Tree tree;
// Double oldOffset, offset;
// Double[] oldHeights, leaves_heights;
// int oldMin_leaf, min_leaf;
// private boolean stored = false;
//
// @Override
// public void initAndValidate() {
// tree = treeInput.get();
// offset = offsetInput.get();
//
// leaves_heights = new Double[tree.getLeafNodeCount()];
// for(int i = 0; i < tree.getLeafNodeCount(); i++) {
// double h = tree.getNode(i).getHeight();
// if(h == 0) min_leaf = i;
// leaves_heights[i] = h + offset;
// }
// }
//
// public double getHeightOfNode(int nr) {
// return tree.getNode(nr).getHeight() + offset;
// }
//
// public void setHeightOfLeaf(int nr, double height) {
// store();
//
// double oldOffset = offset;
// if(height < offset) {
// offset = height;
// min_leaf = nr;
// }
// leaves_heights[nr] = height;
// // if we increased the height of the minimum leaf then which one it is may have changed
// if(height > offset && nr == min_leaf) {
// offset = height;
// for(int i = 0; i < leaves_heights.length; i++) {
// if(leaves_heights[i] < offset) {
// min_leaf = i;
// offset = leaves_heights[i];
// }
// }
// }
// // if offset has changed then all heights need to be updated to keep true heights the same
// if(Math.abs(oldOffset - offset) > 0) {
// for(Node n : tree.getNodesAsArray()) n.setHeight(n.getHeight() + oldOffset - offset);
// }
// }
//
// public double getOffset() {
// return offset;
// }
//
// public Tree getTree() {
// return tree;
// }
//
// public void setHeightOfNode(int nr, double height) {
// Node n = tree.getNode(nr);
// if(n.isLeaf()) this.setHeightOfLeaf(nr, height);
// n.setHeight(height - offset);
// }
//
// // for testing purposes
// public double getStoredHeightOfLeaf(int nr) {
// return leaves_heights[nr];
// }
//
// /* This entire section is to work around the fact that this class is modified DURING the operator proposal of SampledNodeDateRandomWalker
// * whereas Beast2 assumes that only state nodes are modified, and that calculation nodes are only updated afterwards
// * So, using the default mechanic will store/restore the modified state not the original one
// * There is probably a better way to do this
// */
//
// @Override
// public void store() {
// super.store();
// if(stored) return;
// oldMin_leaf = min_leaf;
// oldOffset = offset;
// oldHeights = leaves_heights.clone();
// stored = true;
// }
//
// @Override
// public void restore() {
// super.restore();
// min_leaf = oldMin_leaf;
// offset = oldOffset;
// leaves_heights = oldHeights.clone();
// stored = false;
// }
//
// @Override
// public void accept() {
// super.accept();
// stored = false;
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import beast.core.Description;
import beast.core.Input;
import beast.evolution.tree.Node;
import beast.evolution.tree.SamplingDate;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeWOffset;
import beast.util.Randomizer;
|
package beast.evolution.operators;
@Description("Randomly select a sampled node and shifts the date of the node within a given window")
public class SampledNodeDateRandomWalker extends TipDatesRandomWalker {
|
// Path: src/beast/evolution/tree/SamplingDate.java
// public class SamplingDate extends BEASTObject {
// public final Input<Taxon> taxonInput = new Input<Taxon>("taxon", "Name of the taxon for which the sampling date distribution is specified.",
// Input.Validate.REQUIRED);
//
// public Input<String> upperInput = new Input<>("upper", "Upper bound for the taxon sampling date");
// public Input<String> lowerInput = new Input<>("lower", "Lower bound for the taxon sampling date");
//
// private double upper, lower;
//
// @Override
// public void initAndValidate() {
// upper=Double.parseDouble(upperInput.get());
// lower=Double.parseDouble(lowerInput.get());
// if (upper < 0 || lower < 0 || upper < lower) {
// throw new IllegalArgumentException("Upper and lower inputs of samplingDate should be both positive and upper should be greater than lower.");
// }
// }
//
// public double getUpper() {
// return upper;
// }
//
// public double getLower() {
// return lower;
// }
//
// public double getRandomFromTheRange() {
// return lower + Randomizer.nextDouble()*(upper - lower);
// }
//
// }
//
// Path: src/beast/evolution/tree/TreeWOffset.java
// public class TreeWOffset extends CalculationNode {
//
// public Input<Tree> treeInput = new Input<Tree> ("tree", "tree topology", Validate.REQUIRED);
// public Input<Double> offsetInput = new Input<Double>("offset", "Starting offset to present, default 0", 0.0);
//
// Tree tree;
// Double oldOffset, offset;
// Double[] oldHeights, leaves_heights;
// int oldMin_leaf, min_leaf;
// private boolean stored = false;
//
// @Override
// public void initAndValidate() {
// tree = treeInput.get();
// offset = offsetInput.get();
//
// leaves_heights = new Double[tree.getLeafNodeCount()];
// for(int i = 0; i < tree.getLeafNodeCount(); i++) {
// double h = tree.getNode(i).getHeight();
// if(h == 0) min_leaf = i;
// leaves_heights[i] = h + offset;
// }
// }
//
// public double getHeightOfNode(int nr) {
// return tree.getNode(nr).getHeight() + offset;
// }
//
// public void setHeightOfLeaf(int nr, double height) {
// store();
//
// double oldOffset = offset;
// if(height < offset) {
// offset = height;
// min_leaf = nr;
// }
// leaves_heights[nr] = height;
// // if we increased the height of the minimum leaf then which one it is may have changed
// if(height > offset && nr == min_leaf) {
// offset = height;
// for(int i = 0; i < leaves_heights.length; i++) {
// if(leaves_heights[i] < offset) {
// min_leaf = i;
// offset = leaves_heights[i];
// }
// }
// }
// // if offset has changed then all heights need to be updated to keep true heights the same
// if(Math.abs(oldOffset - offset) > 0) {
// for(Node n : tree.getNodesAsArray()) n.setHeight(n.getHeight() + oldOffset - offset);
// }
// }
//
// public double getOffset() {
// return offset;
// }
//
// public Tree getTree() {
// return tree;
// }
//
// public void setHeightOfNode(int nr, double height) {
// Node n = tree.getNode(nr);
// if(n.isLeaf()) this.setHeightOfLeaf(nr, height);
// n.setHeight(height - offset);
// }
//
// // for testing purposes
// public double getStoredHeightOfLeaf(int nr) {
// return leaves_heights[nr];
// }
//
// /* This entire section is to work around the fact that this class is modified DURING the operator proposal of SampledNodeDateRandomWalker
// * whereas Beast2 assumes that only state nodes are modified, and that calculation nodes are only updated afterwards
// * So, using the default mechanic will store/restore the modified state not the original one
// * There is probably a better way to do this
// */
//
// @Override
// public void store() {
// super.store();
// if(stored) return;
// oldMin_leaf = min_leaf;
// oldOffset = offset;
// oldHeights = leaves_heights.clone();
// stored = true;
// }
//
// @Override
// public void restore() {
// super.restore();
// min_leaf = oldMin_leaf;
// offset = oldOffset;
// leaves_heights = oldHeights.clone();
// stored = false;
// }
//
// @Override
// public void accept() {
// super.accept();
// stored = false;
// }
// }
// Path: src/beast/evolution/operators/SampledNodeDateRandomWalker.java
import java.util.ArrayList;
import java.util.List;
import beast.core.Description;
import beast.core.Input;
import beast.evolution.tree.Node;
import beast.evolution.tree.SamplingDate;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeWOffset;
import beast.util.Randomizer;
package beast.evolution.operators;
@Description("Randomly select a sampled node and shifts the date of the node within a given window")
public class SampledNodeDateRandomWalker extends TipDatesRandomWalker {
|
public Input<TreeWOffset> treeWOffsetInput =
|
CompEvol/sampled-ancestors
|
src/beast/evolution/operators/SampledNodeDateRandomWalker.java
|
// Path: src/beast/evolution/tree/SamplingDate.java
// public class SamplingDate extends BEASTObject {
// public final Input<Taxon> taxonInput = new Input<Taxon>("taxon", "Name of the taxon for which the sampling date distribution is specified.",
// Input.Validate.REQUIRED);
//
// public Input<String> upperInput = new Input<>("upper", "Upper bound for the taxon sampling date");
// public Input<String> lowerInput = new Input<>("lower", "Lower bound for the taxon sampling date");
//
// private double upper, lower;
//
// @Override
// public void initAndValidate() {
// upper=Double.parseDouble(upperInput.get());
// lower=Double.parseDouble(lowerInput.get());
// if (upper < 0 || lower < 0 || upper < lower) {
// throw new IllegalArgumentException("Upper and lower inputs of samplingDate should be both positive and upper should be greater than lower.");
// }
// }
//
// public double getUpper() {
// return upper;
// }
//
// public double getLower() {
// return lower;
// }
//
// public double getRandomFromTheRange() {
// return lower + Randomizer.nextDouble()*(upper - lower);
// }
//
// }
//
// Path: src/beast/evolution/tree/TreeWOffset.java
// public class TreeWOffset extends CalculationNode {
//
// public Input<Tree> treeInput = new Input<Tree> ("tree", "tree topology", Validate.REQUIRED);
// public Input<Double> offsetInput = new Input<Double>("offset", "Starting offset to present, default 0", 0.0);
//
// Tree tree;
// Double oldOffset, offset;
// Double[] oldHeights, leaves_heights;
// int oldMin_leaf, min_leaf;
// private boolean stored = false;
//
// @Override
// public void initAndValidate() {
// tree = treeInput.get();
// offset = offsetInput.get();
//
// leaves_heights = new Double[tree.getLeafNodeCount()];
// for(int i = 0; i < tree.getLeafNodeCount(); i++) {
// double h = tree.getNode(i).getHeight();
// if(h == 0) min_leaf = i;
// leaves_heights[i] = h + offset;
// }
// }
//
// public double getHeightOfNode(int nr) {
// return tree.getNode(nr).getHeight() + offset;
// }
//
// public void setHeightOfLeaf(int nr, double height) {
// store();
//
// double oldOffset = offset;
// if(height < offset) {
// offset = height;
// min_leaf = nr;
// }
// leaves_heights[nr] = height;
// // if we increased the height of the minimum leaf then which one it is may have changed
// if(height > offset && nr == min_leaf) {
// offset = height;
// for(int i = 0; i < leaves_heights.length; i++) {
// if(leaves_heights[i] < offset) {
// min_leaf = i;
// offset = leaves_heights[i];
// }
// }
// }
// // if offset has changed then all heights need to be updated to keep true heights the same
// if(Math.abs(oldOffset - offset) > 0) {
// for(Node n : tree.getNodesAsArray()) n.setHeight(n.getHeight() + oldOffset - offset);
// }
// }
//
// public double getOffset() {
// return offset;
// }
//
// public Tree getTree() {
// return tree;
// }
//
// public void setHeightOfNode(int nr, double height) {
// Node n = tree.getNode(nr);
// if(n.isLeaf()) this.setHeightOfLeaf(nr, height);
// n.setHeight(height - offset);
// }
//
// // for testing purposes
// public double getStoredHeightOfLeaf(int nr) {
// return leaves_heights[nr];
// }
//
// /* This entire section is to work around the fact that this class is modified DURING the operator proposal of SampledNodeDateRandomWalker
// * whereas Beast2 assumes that only state nodes are modified, and that calculation nodes are only updated afterwards
// * So, using the default mechanic will store/restore the modified state not the original one
// * There is probably a better way to do this
// */
//
// @Override
// public void store() {
// super.store();
// if(stored) return;
// oldMin_leaf = min_leaf;
// oldOffset = offset;
// oldHeights = leaves_heights.clone();
// stored = true;
// }
//
// @Override
// public void restore() {
// super.restore();
// min_leaf = oldMin_leaf;
// offset = oldOffset;
// leaves_heights = oldHeights.clone();
// stored = false;
// }
//
// @Override
// public void accept() {
// super.accept();
// stored = false;
// }
// }
|
import java.util.ArrayList;
import java.util.List;
import beast.core.Description;
import beast.core.Input;
import beast.evolution.tree.Node;
import beast.evolution.tree.SamplingDate;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeWOffset;
import beast.util.Randomizer;
|
package beast.evolution.operators;
@Description("Randomly select a sampled node and shifts the date of the node within a given window")
public class SampledNodeDateRandomWalker extends TipDatesRandomWalker {
public Input<TreeWOffset> treeWOffsetInput =
new Input<TreeWOffset>("treeWOffset", "Optional fully extinct tree", (TreeWOffset)null);
|
// Path: src/beast/evolution/tree/SamplingDate.java
// public class SamplingDate extends BEASTObject {
// public final Input<Taxon> taxonInput = new Input<Taxon>("taxon", "Name of the taxon for which the sampling date distribution is specified.",
// Input.Validate.REQUIRED);
//
// public Input<String> upperInput = new Input<>("upper", "Upper bound for the taxon sampling date");
// public Input<String> lowerInput = new Input<>("lower", "Lower bound for the taxon sampling date");
//
// private double upper, lower;
//
// @Override
// public void initAndValidate() {
// upper=Double.parseDouble(upperInput.get());
// lower=Double.parseDouble(lowerInput.get());
// if (upper < 0 || lower < 0 || upper < lower) {
// throw new IllegalArgumentException("Upper and lower inputs of samplingDate should be both positive and upper should be greater than lower.");
// }
// }
//
// public double getUpper() {
// return upper;
// }
//
// public double getLower() {
// return lower;
// }
//
// public double getRandomFromTheRange() {
// return lower + Randomizer.nextDouble()*(upper - lower);
// }
//
// }
//
// Path: src/beast/evolution/tree/TreeWOffset.java
// public class TreeWOffset extends CalculationNode {
//
// public Input<Tree> treeInput = new Input<Tree> ("tree", "tree topology", Validate.REQUIRED);
// public Input<Double> offsetInput = new Input<Double>("offset", "Starting offset to present, default 0", 0.0);
//
// Tree tree;
// Double oldOffset, offset;
// Double[] oldHeights, leaves_heights;
// int oldMin_leaf, min_leaf;
// private boolean stored = false;
//
// @Override
// public void initAndValidate() {
// tree = treeInput.get();
// offset = offsetInput.get();
//
// leaves_heights = new Double[tree.getLeafNodeCount()];
// for(int i = 0; i < tree.getLeafNodeCount(); i++) {
// double h = tree.getNode(i).getHeight();
// if(h == 0) min_leaf = i;
// leaves_heights[i] = h + offset;
// }
// }
//
// public double getHeightOfNode(int nr) {
// return tree.getNode(nr).getHeight() + offset;
// }
//
// public void setHeightOfLeaf(int nr, double height) {
// store();
//
// double oldOffset = offset;
// if(height < offset) {
// offset = height;
// min_leaf = nr;
// }
// leaves_heights[nr] = height;
// // if we increased the height of the minimum leaf then which one it is may have changed
// if(height > offset && nr == min_leaf) {
// offset = height;
// for(int i = 0; i < leaves_heights.length; i++) {
// if(leaves_heights[i] < offset) {
// min_leaf = i;
// offset = leaves_heights[i];
// }
// }
// }
// // if offset has changed then all heights need to be updated to keep true heights the same
// if(Math.abs(oldOffset - offset) > 0) {
// for(Node n : tree.getNodesAsArray()) n.setHeight(n.getHeight() + oldOffset - offset);
// }
// }
//
// public double getOffset() {
// return offset;
// }
//
// public Tree getTree() {
// return tree;
// }
//
// public void setHeightOfNode(int nr, double height) {
// Node n = tree.getNode(nr);
// if(n.isLeaf()) this.setHeightOfLeaf(nr, height);
// n.setHeight(height - offset);
// }
//
// // for testing purposes
// public double getStoredHeightOfLeaf(int nr) {
// return leaves_heights[nr];
// }
//
// /* This entire section is to work around the fact that this class is modified DURING the operator proposal of SampledNodeDateRandomWalker
// * whereas Beast2 assumes that only state nodes are modified, and that calculation nodes are only updated afterwards
// * So, using the default mechanic will store/restore the modified state not the original one
// * There is probably a better way to do this
// */
//
// @Override
// public void store() {
// super.store();
// if(stored) return;
// oldMin_leaf = min_leaf;
// oldOffset = offset;
// oldHeights = leaves_heights.clone();
// stored = true;
// }
//
// @Override
// public void restore() {
// super.restore();
// min_leaf = oldMin_leaf;
// offset = oldOffset;
// leaves_heights = oldHeights.clone();
// stored = false;
// }
//
// @Override
// public void accept() {
// super.accept();
// stored = false;
// }
// }
// Path: src/beast/evolution/operators/SampledNodeDateRandomWalker.java
import java.util.ArrayList;
import java.util.List;
import beast.core.Description;
import beast.core.Input;
import beast.evolution.tree.Node;
import beast.evolution.tree.SamplingDate;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeWOffset;
import beast.util.Randomizer;
package beast.evolution.operators;
@Description("Randomly select a sampled node and shifts the date of the node within a given window")
public class SampledNodeDateRandomWalker extends TipDatesRandomWalker {
public Input<TreeWOffset> treeWOffsetInput =
new Input<TreeWOffset>("treeWOffset", "Optional fully extinct tree", (TreeWOffset)null);
|
public Input<List<SamplingDate>> samplingDatesInput = new Input<>("samplingDates",
|
CompEvol/sampled-ancestors
|
src/test/beast/evolution/operators/TreeDimensionJumpTest.java
|
// Path: src/beast/evolution/operators/TreeDimensionJump.java
// @Description("Implements a narrow move between trees of different dimensions (number of nodes in trees)." +
// "It takes a random sampled node which is either a leaf with the younger sibling" +
// "or a sampled internal node. In the first case, the leaf becomes a sampled internal node by replacing its " +
// "parent (the height of the leaf remains unchanged). In the second case, the sampled internal node becomes " +
// "a leaf by inserting a new parent node at a height which is uniformly chosen on the interval " +
// " between the sampled node height and its old parent height.")
// public class TreeDimensionJump extends TreeOperator {
//
// public Input<IntegerParameter> categoriesInput = new Input<IntegerParameter>("rateCategories", "rate category per branch");
//
// public Input<RealParameter> rInput =
// new Input<RealParameter>("removalProbability", "The probability of an individual to be removed from the process immediately after the sampling");
//
// @Override
// public void initAndValidate() {
// }
//
// @Override
// public double proposal() {
//
// double newHeight, newRange, oldRange;
// int categoryCount = 1;
// if (categoriesInput.get() != null) {
//
// categoryCount = categoriesInput.get().getUpper() - categoriesInput.get().getLower() +1;
// }
//
// Tree tree = treeInput.get();
//
// int leafNodeCount = tree.getLeafNodeCount();
//
// Node leaf = tree.getNode(Randomizer.nextInt(leafNodeCount));
// Node parent = leaf.getParent();
//
// if (leaf.isDirectAncestor()) {
// oldRange = (double) 1;
// if (parent.isRoot()) {
// final double randomNumber = Randomizer.nextExponential(1);
// newHeight = parent.getHeight() + randomNumber;
// newRange = Math.exp(randomNumber);
// } else {
// newRange = parent.getParent().getHeight() - parent.getHeight();
// newHeight = parent.getHeight() + Randomizer.nextDouble() * newRange;
// }
//
// if (categoriesInput.get() != null) {
// int index = leaf.getNr();
// int newValue = Randomizer.nextInt(categoryCount) + categoriesInput.get().getLower(); // from 0 to n-1, n must > 0,
// categoriesInput.get().setValue(index, newValue);
// }
// } else {
// newRange = (double) 1;
// //make sure that the branch where a new sampled node to appear is not above that sampled node
// if (getOtherChild(parent, leaf).getHeight() >= leaf.getHeight()) {
// return Double.NEGATIVE_INFINITY;
// }
// if (parent.isRoot()) {
// oldRange = Math.exp(parent.getHeight() - leaf.getHeight());
// } else {
// oldRange = parent.getParent().getHeight() - leaf.getHeight();
// }
// newHeight = leaf.getHeight();
// if (categoriesInput.get() != null) {
// int index = leaf.getNr();
// categoriesInput.get().setValue(index, -1);
// }
// }
// parent.setHeight(newHeight);
//
// //make sure that either there are no direct ancestors or r<1
// if ((rInput.get() != null) && (tree.getDirectAncestorNodeCount() > 0 && rInput.get().getValue() == 1)) {
// return Double.NEGATIVE_INFINITY;
// }
//
// return Math.log(newRange/oldRange);
// }
// }
|
import beast.evolution.operators.TreeDimensionJump;
import beast.evolution.tree.Node;
import beast.evolution.tree.Tree;
import junit.framework.TestCase;
import org.junit.Test;
|
package test.beast.evolution.operators;
/**
* @author Alexandra Gavryushkina
*/
public class TreeDimensionJumpTest extends TestCase {
@Test
public void testOperator1() throws Exception {
Tree tree;
int taxaSize = 3;
// make a caterpillar
Node left = new Node();
left.setNr(0);
left.setHeight(0.0);
for (int i = 1; i < taxaSize; i++) {
Node right = new Node();
right.setNr(i);
right.setHeight(i);
Node parent = new Node();
parent.setNr(taxaSize + i - 1);
parent.setHeight(i);
left.setParent(parent);
parent.addChild(left);
right.setParent(parent);
parent.addChild(right);
left = parent;
}
tree = new Tree(left);
System.out.println("Tree was = " + tree.getRoot().toShortNewick(false));
|
// Path: src/beast/evolution/operators/TreeDimensionJump.java
// @Description("Implements a narrow move between trees of different dimensions (number of nodes in trees)." +
// "It takes a random sampled node which is either a leaf with the younger sibling" +
// "or a sampled internal node. In the first case, the leaf becomes a sampled internal node by replacing its " +
// "parent (the height of the leaf remains unchanged). In the second case, the sampled internal node becomes " +
// "a leaf by inserting a new parent node at a height which is uniformly chosen on the interval " +
// " between the sampled node height and its old parent height.")
// public class TreeDimensionJump extends TreeOperator {
//
// public Input<IntegerParameter> categoriesInput = new Input<IntegerParameter>("rateCategories", "rate category per branch");
//
// public Input<RealParameter> rInput =
// new Input<RealParameter>("removalProbability", "The probability of an individual to be removed from the process immediately after the sampling");
//
// @Override
// public void initAndValidate() {
// }
//
// @Override
// public double proposal() {
//
// double newHeight, newRange, oldRange;
// int categoryCount = 1;
// if (categoriesInput.get() != null) {
//
// categoryCount = categoriesInput.get().getUpper() - categoriesInput.get().getLower() +1;
// }
//
// Tree tree = treeInput.get();
//
// int leafNodeCount = tree.getLeafNodeCount();
//
// Node leaf = tree.getNode(Randomizer.nextInt(leafNodeCount));
// Node parent = leaf.getParent();
//
// if (leaf.isDirectAncestor()) {
// oldRange = (double) 1;
// if (parent.isRoot()) {
// final double randomNumber = Randomizer.nextExponential(1);
// newHeight = parent.getHeight() + randomNumber;
// newRange = Math.exp(randomNumber);
// } else {
// newRange = parent.getParent().getHeight() - parent.getHeight();
// newHeight = parent.getHeight() + Randomizer.nextDouble() * newRange;
// }
//
// if (categoriesInput.get() != null) {
// int index = leaf.getNr();
// int newValue = Randomizer.nextInt(categoryCount) + categoriesInput.get().getLower(); // from 0 to n-1, n must > 0,
// categoriesInput.get().setValue(index, newValue);
// }
// } else {
// newRange = (double) 1;
// //make sure that the branch where a new sampled node to appear is not above that sampled node
// if (getOtherChild(parent, leaf).getHeight() >= leaf.getHeight()) {
// return Double.NEGATIVE_INFINITY;
// }
// if (parent.isRoot()) {
// oldRange = Math.exp(parent.getHeight() - leaf.getHeight());
// } else {
// oldRange = parent.getParent().getHeight() - leaf.getHeight();
// }
// newHeight = leaf.getHeight();
// if (categoriesInput.get() != null) {
// int index = leaf.getNr();
// categoriesInput.get().setValue(index, -1);
// }
// }
// parent.setHeight(newHeight);
//
// //make sure that either there are no direct ancestors or r<1
// if ((rInput.get() != null) && (tree.getDirectAncestorNodeCount() > 0 && rInput.get().getValue() == 1)) {
// return Double.NEGATIVE_INFINITY;
// }
//
// return Math.log(newRange/oldRange);
// }
// }
// Path: src/test/beast/evolution/operators/TreeDimensionJumpTest.java
import beast.evolution.operators.TreeDimensionJump;
import beast.evolution.tree.Node;
import beast.evolution.tree.Tree;
import junit.framework.TestCase;
import org.junit.Test;
package test.beast.evolution.operators;
/**
* @author Alexandra Gavryushkina
*/
public class TreeDimensionJumpTest extends TestCase {
@Test
public void testOperator1() throws Exception {
Tree tree;
int taxaSize = 3;
// make a caterpillar
Node left = new Node();
left.setNr(0);
left.setHeight(0.0);
for (int i = 1; i < taxaSize; i++) {
Node right = new Node();
right.setNr(i);
right.setHeight(i);
Node parent = new Node();
parent.setNr(taxaSize + i - 1);
parent.setHeight(i);
left.setParent(parent);
parent.addChild(left);
right.setParent(parent);
parent.addChild(right);
left = parent;
}
tree = new Tree(left);
System.out.println("Tree was = " + tree.getRoot().toShortNewick(false));
|
TreeDimensionJump operator = new TreeDimensionJump();
|
CompEvol/sampled-ancestors
|
src/test/beast/evolution/tree/TreeWOffsetTest.java
|
// Path: src/beast/evolution/tree/TreeWOffset.java
// public class TreeWOffset extends CalculationNode {
//
// public Input<Tree> treeInput = new Input<Tree> ("tree", "tree topology", Validate.REQUIRED);
// public Input<Double> offsetInput = new Input<Double>("offset", "Starting offset to present, default 0", 0.0);
//
// Tree tree;
// Double oldOffset, offset;
// Double[] oldHeights, leaves_heights;
// int oldMin_leaf, min_leaf;
// private boolean stored = false;
//
// @Override
// public void initAndValidate() {
// tree = treeInput.get();
// offset = offsetInput.get();
//
// leaves_heights = new Double[tree.getLeafNodeCount()];
// for(int i = 0; i < tree.getLeafNodeCount(); i++) {
// double h = tree.getNode(i).getHeight();
// if(h == 0) min_leaf = i;
// leaves_heights[i] = h + offset;
// }
// }
//
// public double getHeightOfNode(int nr) {
// return tree.getNode(nr).getHeight() + offset;
// }
//
// public void setHeightOfLeaf(int nr, double height) {
// store();
//
// double oldOffset = offset;
// if(height < offset) {
// offset = height;
// min_leaf = nr;
// }
// leaves_heights[nr] = height;
// // if we increased the height of the minimum leaf then which one it is may have changed
// if(height > offset && nr == min_leaf) {
// offset = height;
// for(int i = 0; i < leaves_heights.length; i++) {
// if(leaves_heights[i] < offset) {
// min_leaf = i;
// offset = leaves_heights[i];
// }
// }
// }
// // if offset has changed then all heights need to be updated to keep true heights the same
// if(Math.abs(oldOffset - offset) > 0) {
// for(Node n : tree.getNodesAsArray()) n.setHeight(n.getHeight() + oldOffset - offset);
// }
// }
//
// public double getOffset() {
// return offset;
// }
//
// public Tree getTree() {
// return tree;
// }
//
// public void setHeightOfNode(int nr, double height) {
// Node n = tree.getNode(nr);
// if(n.isLeaf()) this.setHeightOfLeaf(nr, height);
// n.setHeight(height - offset);
// }
//
// // for testing purposes
// public double getStoredHeightOfLeaf(int nr) {
// return leaves_heights[nr];
// }
//
// /* This entire section is to work around the fact that this class is modified DURING the operator proposal of SampledNodeDateRandomWalker
// * whereas Beast2 assumes that only state nodes are modified, and that calculation nodes are only updated afterwards
// * So, using the default mechanic will store/restore the modified state not the original one
// * There is probably a better way to do this
// */
//
// @Override
// public void store() {
// super.store();
// if(stored) return;
// oldMin_leaf = min_leaf;
// oldOffset = offset;
// oldHeights = leaves_heights.clone();
// stored = true;
// }
//
// @Override
// public void restore() {
// super.restore();
// min_leaf = oldMin_leaf;
// offset = oldOffset;
// leaves_heights = oldHeights.clone();
// stored = false;
// }
//
// @Override
// public void accept() {
// super.accept();
// stored = false;
// }
// }
|
import org.junit.Test;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeWOffset;
import beast.util.ZeroBranchSATreeParser;
import junit.framework.TestCase;
|
package test.beast.evolution.tree;
public class TreeWOffsetTest extends TestCase {
@Test
public void testTree() throws Exception {
Tree tree = new ZeroBranchSATreeParser("((t1:1.5,t2:0.5):0.5)3:0.0", true, true, 1);
|
// Path: src/beast/evolution/tree/TreeWOffset.java
// public class TreeWOffset extends CalculationNode {
//
// public Input<Tree> treeInput = new Input<Tree> ("tree", "tree topology", Validate.REQUIRED);
// public Input<Double> offsetInput = new Input<Double>("offset", "Starting offset to present, default 0", 0.0);
//
// Tree tree;
// Double oldOffset, offset;
// Double[] oldHeights, leaves_heights;
// int oldMin_leaf, min_leaf;
// private boolean stored = false;
//
// @Override
// public void initAndValidate() {
// tree = treeInput.get();
// offset = offsetInput.get();
//
// leaves_heights = new Double[tree.getLeafNodeCount()];
// for(int i = 0; i < tree.getLeafNodeCount(); i++) {
// double h = tree.getNode(i).getHeight();
// if(h == 0) min_leaf = i;
// leaves_heights[i] = h + offset;
// }
// }
//
// public double getHeightOfNode(int nr) {
// return tree.getNode(nr).getHeight() + offset;
// }
//
// public void setHeightOfLeaf(int nr, double height) {
// store();
//
// double oldOffset = offset;
// if(height < offset) {
// offset = height;
// min_leaf = nr;
// }
// leaves_heights[nr] = height;
// // if we increased the height of the minimum leaf then which one it is may have changed
// if(height > offset && nr == min_leaf) {
// offset = height;
// for(int i = 0; i < leaves_heights.length; i++) {
// if(leaves_heights[i] < offset) {
// min_leaf = i;
// offset = leaves_heights[i];
// }
// }
// }
// // if offset has changed then all heights need to be updated to keep true heights the same
// if(Math.abs(oldOffset - offset) > 0) {
// for(Node n : tree.getNodesAsArray()) n.setHeight(n.getHeight() + oldOffset - offset);
// }
// }
//
// public double getOffset() {
// return offset;
// }
//
// public Tree getTree() {
// return tree;
// }
//
// public void setHeightOfNode(int nr, double height) {
// Node n = tree.getNode(nr);
// if(n.isLeaf()) this.setHeightOfLeaf(nr, height);
// n.setHeight(height - offset);
// }
//
// // for testing purposes
// public double getStoredHeightOfLeaf(int nr) {
// return leaves_heights[nr];
// }
//
// /* This entire section is to work around the fact that this class is modified DURING the operator proposal of SampledNodeDateRandomWalker
// * whereas Beast2 assumes that only state nodes are modified, and that calculation nodes are only updated afterwards
// * So, using the default mechanic will store/restore the modified state not the original one
// * There is probably a better way to do this
// */
//
// @Override
// public void store() {
// super.store();
// if(stored) return;
// oldMin_leaf = min_leaf;
// oldOffset = offset;
// oldHeights = leaves_heights.clone();
// stored = true;
// }
//
// @Override
// public void restore() {
// super.restore();
// min_leaf = oldMin_leaf;
// offset = oldOffset;
// leaves_heights = oldHeights.clone();
// stored = false;
// }
//
// @Override
// public void accept() {
// super.accept();
// stored = false;
// }
// }
// Path: src/test/beast/evolution/tree/TreeWOffsetTest.java
import org.junit.Test;
import beast.evolution.tree.Tree;
import beast.evolution.tree.TreeWOffset;
import beast.util.ZeroBranchSATreeParser;
import junit.framework.TestCase;
package test.beast.evolution.tree;
public class TreeWOffsetTest extends TestCase {
@Test
public void testTree() throws Exception {
Tree tree = new ZeroBranchSATreeParser("((t1:1.5,t2:0.5):0.5)3:0.0", true, true, 1);
|
TreeWOffset treewoffset = new TreeWOffset();
|
vbauer/herald
|
src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
|
// Path: src/main/java/com/github/vbauer/herald/injector/LoggerInjector.java
// public final class LoggerInjector {
//
// private static final Collection<LogFactory> LOG_FACTORIES = loadLogFactories();
//
//
// private LoggerInjector() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void inject(final Object... beans) {
// if (beans != null) {
// for (final Object bean : beans) {
// inject(bean);
// }
// }
// }
//
// public static <T> T inject(final T bean) {
// if (bean != null) {
// final Class<?> beanClass = bean.getClass();
// final Field[] declaredFields = beanClass.getDeclaredFields();
//
// for (final Field field : declaredFields) {
// if (needToInjectLogger(beanClass, field)) {
// injectLogger(bean, field);
// }
// }
// }
// return bean;
// }
//
//
// /*
// * Internal API.
// */
//
// private static boolean needToInjectLogger(final Class<?> beanClass, final Field field) {
// final boolean hasAnnotation = beanClass.getAnnotation(Log.class) != null;
// if (hasAnnotation) {
// final Class<?> fieldType = field.getType();
// return LogFactoryDetector.hasCompatible(LOG_FACTORIES, fieldType);
// }
// return field.getAnnotation(Log.class) != null;
// }
//
// private static void injectLogger(final Object bean, final Field field) {
// final boolean isAccessible = field.isAccessible();
// ReflectionUtils.setAccessible(field, true);
//
// // Read context parameters.
// final Class<?> beanClass = bean.getClass();
// final Class<?> loggerClass = field.getType();
// final Log annotation = ReflectionUtils.findAnnotation(Log.class, beanClass, field);
//
// final boolean required = annotation.required();
// final String loggerName = annotation.value();
//
// try {
// final Object logger = createLogger(beanClass, loggerClass, loggerName);
// field.set(bean, logger);
// } catch (final Throwable ex) {
// if (required) {
// ReflectionUtils.handleReflectionException(ex);
// }
// } finally {
// ReflectionUtils.setAccessible(field, isAccessible);
// }
// }
//
// private static Object createLogger(
// final Class<?> beanClass, final Class<?> loggerClass, final String loggerName
// ) {
// // Find corresponding logger factory.
// final LogFactory logFactory =
// LogFactoryDetector.findCompatible(LOG_FACTORIES, loggerClass);
//
// if (logFactory == null) {
// throw new MissedLogFactoryException(loggerClass);
// }
//
// // Create logger.
// final Object logger = !loggerName.isEmpty()
// ? logFactory.createLogger(loggerName) : logFactory.createLogger(beanClass);
//
// if (logger == null) {
// throw new LoggerInstantiationException(logFactory);
// }
// return logger;
// }
//
// private static Collection<LogFactory> loadLogFactories() {
// return ServiceLoaderUtils.load(LogFactory.class);
// }
//
// }
|
import com.github.vbauer.herald.injector.LoggerInjector;
import org.springframework.beans.factory.config.BeanPostProcessor;
|
package com.github.vbauer.herald.ext.spring;
/**
* Spring {@link BeanPostProcessor} which injects initialized loggers in beans.
*
* @author Vladislav Bauer
*/
public class LogBeanPostProcessor implements BeanPostProcessor {
/**
* {@inheritDoc}
*/
@Override
public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
|
// Path: src/main/java/com/github/vbauer/herald/injector/LoggerInjector.java
// public final class LoggerInjector {
//
// private static final Collection<LogFactory> LOG_FACTORIES = loadLogFactories();
//
//
// private LoggerInjector() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void inject(final Object... beans) {
// if (beans != null) {
// for (final Object bean : beans) {
// inject(bean);
// }
// }
// }
//
// public static <T> T inject(final T bean) {
// if (bean != null) {
// final Class<?> beanClass = bean.getClass();
// final Field[] declaredFields = beanClass.getDeclaredFields();
//
// for (final Field field : declaredFields) {
// if (needToInjectLogger(beanClass, field)) {
// injectLogger(bean, field);
// }
// }
// }
// return bean;
// }
//
//
// /*
// * Internal API.
// */
//
// private static boolean needToInjectLogger(final Class<?> beanClass, final Field field) {
// final boolean hasAnnotation = beanClass.getAnnotation(Log.class) != null;
// if (hasAnnotation) {
// final Class<?> fieldType = field.getType();
// return LogFactoryDetector.hasCompatible(LOG_FACTORIES, fieldType);
// }
// return field.getAnnotation(Log.class) != null;
// }
//
// private static void injectLogger(final Object bean, final Field field) {
// final boolean isAccessible = field.isAccessible();
// ReflectionUtils.setAccessible(field, true);
//
// // Read context parameters.
// final Class<?> beanClass = bean.getClass();
// final Class<?> loggerClass = field.getType();
// final Log annotation = ReflectionUtils.findAnnotation(Log.class, beanClass, field);
//
// final boolean required = annotation.required();
// final String loggerName = annotation.value();
//
// try {
// final Object logger = createLogger(beanClass, loggerClass, loggerName);
// field.set(bean, logger);
// } catch (final Throwable ex) {
// if (required) {
// ReflectionUtils.handleReflectionException(ex);
// }
// } finally {
// ReflectionUtils.setAccessible(field, isAccessible);
// }
// }
//
// private static Object createLogger(
// final Class<?> beanClass, final Class<?> loggerClass, final String loggerName
// ) {
// // Find corresponding logger factory.
// final LogFactory logFactory =
// LogFactoryDetector.findCompatible(LOG_FACTORIES, loggerClass);
//
// if (logFactory == null) {
// throw new MissedLogFactoryException(loggerClass);
// }
//
// // Create logger.
// final Object logger = !loggerName.isEmpty()
// ? logFactory.createLogger(loggerName) : logFactory.createLogger(beanClass);
//
// if (logger == null) {
// throw new LoggerInstantiationException(logFactory);
// }
// return logger;
// }
//
// private static Collection<LogFactory> loadLogFactories() {
// return ServiceLoaderUtils.load(LogFactory.class);
// }
//
// }
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
import com.github.vbauer.herald.injector.LoggerInjector;
import org.springframework.beans.factory.config.BeanPostProcessor;
package com.github.vbauer.herald.ext.spring;
/**
* Spring {@link BeanPostProcessor} which injects initialized loggers in beans.
*
* @author Vladislav Bauer
*/
public class LogBeanPostProcessor implements BeanPostProcessor {
/**
* {@inheritDoc}
*/
@Override
public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
|
return LoggerInjector.inject(bean);
|
vbauer/herald
|
src/main/java/com/github/vbauer/herald/logger/impl/SimpleLogFactory.java
|
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ReflectionUtils.java
// public final class ReflectionUtils {
//
// private ReflectionUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static boolean isAssignableFrom(final String className, final Class<?> from) {
// try {
// final Class<?> clazz = Class.forName(className);
// return clazz.isAssignableFrom(from);
// } catch (final Throwable ex) {
// return false;
// }
// }
//
// @SuppressWarnings("unchecked")
// public static <I, O> O invokeStatic(final String className, final String methodName, final I argument) {
// try {
// final Class<?> clazz = Class.forName(className);
// final Class<?> argumentClass = argument.getClass();
//
// final Method method = clazz.getDeclaredMethod(methodName, argumentClass);
// return (O) method.invoke(null, argument);
// } catch (final Exception ex) {
// return handleReflectionException(ex);
// }
// }
//
// public static <T> T handleReflectionException(final Throwable ex) {
// if (ex instanceof RuntimeException) {
// throw (RuntimeException) ex;
// } else if (ex instanceof Error) {
// throw (Error) ex;
// }
// throw new RuntimeException(ex);
// }
//
// public static <T extends Annotation> T findAnnotation(
// final Class<T> annotationClass, final Class<?> beanClass, final Field field
// ) {
// final T fieldAnnotation = field.getAnnotation(annotationClass);
// return fieldAnnotation == null ? beanClass.getAnnotation(annotationClass) : fieldAnnotation;
// }
//
// public static boolean setAccessible(final AccessibleObject object, final boolean accessible) {
// try {
// object.setAccessible(accessible);
// return true;
// } catch (final Throwable ignored) {
// // Ignored.
// return false;
// }
// }
//
// }
|
import com.github.vbauer.herald.logger.LogFactory;
import com.github.vbauer.herald.util.ReflectionUtils;
|
package com.github.vbauer.herald.logger.impl;
/**
* @author Vladislav Bauer
*/
public abstract class SimpleLogFactory implements LogFactory {
private final String loggerClassName;
private final String loggerFactoryClassName;
private final String loggerFactoryMethod;
protected SimpleLogFactory(
final String loggerClassName,
final String loggerFactoryClassName, final String loggerFactoryMethod
) {
this.loggerClassName = loggerClassName;
this.loggerFactoryClassName = loggerFactoryClassName;
this.loggerFactoryMethod = loggerFactoryMethod;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isCompatible(final Class<?> loggerClass) {
|
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ReflectionUtils.java
// public final class ReflectionUtils {
//
// private ReflectionUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static boolean isAssignableFrom(final String className, final Class<?> from) {
// try {
// final Class<?> clazz = Class.forName(className);
// return clazz.isAssignableFrom(from);
// } catch (final Throwable ex) {
// return false;
// }
// }
//
// @SuppressWarnings("unchecked")
// public static <I, O> O invokeStatic(final String className, final String methodName, final I argument) {
// try {
// final Class<?> clazz = Class.forName(className);
// final Class<?> argumentClass = argument.getClass();
//
// final Method method = clazz.getDeclaredMethod(methodName, argumentClass);
// return (O) method.invoke(null, argument);
// } catch (final Exception ex) {
// return handleReflectionException(ex);
// }
// }
//
// public static <T> T handleReflectionException(final Throwable ex) {
// if (ex instanceof RuntimeException) {
// throw (RuntimeException) ex;
// } else if (ex instanceof Error) {
// throw (Error) ex;
// }
// throw new RuntimeException(ex);
// }
//
// public static <T extends Annotation> T findAnnotation(
// final Class<T> annotationClass, final Class<?> beanClass, final Field field
// ) {
// final T fieldAnnotation = field.getAnnotation(annotationClass);
// return fieldAnnotation == null ? beanClass.getAnnotation(annotationClass) : fieldAnnotation;
// }
//
// public static boolean setAccessible(final AccessibleObject object, final boolean accessible) {
// try {
// object.setAccessible(accessible);
// return true;
// } catch (final Throwable ignored) {
// // Ignored.
// return false;
// }
// }
//
// }
// Path: src/main/java/com/github/vbauer/herald/logger/impl/SimpleLogFactory.java
import com.github.vbauer.herald.logger.LogFactory;
import com.github.vbauer.herald.util.ReflectionUtils;
package com.github.vbauer.herald.logger.impl;
/**
* @author Vladislav Bauer
*/
public abstract class SimpleLogFactory implements LogFactory {
private final String loggerClassName;
private final String loggerFactoryClassName;
private final String loggerFactoryMethod;
protected SimpleLogFactory(
final String loggerClassName,
final String loggerFactoryClassName, final String loggerFactoryMethod
) {
this.loggerClassName = loggerClassName;
this.loggerFactoryClassName = loggerFactoryClassName;
this.loggerFactoryMethod = loggerFactoryMethod;
}
/**
* {@inheritDoc}
*/
@Override
public boolean isCompatible(final Class<?> loggerClass) {
|
return ReflectionUtils.isAssignableFrom(loggerClassName, loggerClass);
|
vbauer/herald
|
src/main/java/com/github/vbauer/herald/injector/LogFactoryDetector.java
|
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
|
import com.github.vbauer.herald.logger.LogFactory;
import java.util.Collection;
|
package com.github.vbauer.herald.injector;
/**
* @author Vladislav Bauer
*/
public final class LogFactoryDetector {
private LogFactoryDetector() {
throw new UnsupportedOperationException();
}
|
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
// Path: src/main/java/com/github/vbauer/herald/injector/LogFactoryDetector.java
import com.github.vbauer.herald.logger.LogFactory;
import java.util.Collection;
package com.github.vbauer.herald.injector;
/**
* @author Vladislav Bauer
*/
public final class LogFactoryDetector {
private LogFactoryDetector() {
throw new UnsupportedOperationException();
}
|
public static boolean hasCompatible(final Collection<LogFactory> factories, final Class<?> loggerClass) {
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/context/SpringBootTestContext.java
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogAutoConfiguration.java
// @Configuration
// public class LogAutoConfiguration {
//
// /**
// * Create {@link LogBeanPostProcessor} and register it in context if missed.
// *
// * @return create {@link LogBeanPostProcessor}
// */
// @Bean
// @ConditionalOnMissingBean(LogBeanPostProcessor.class)
// public LogBeanPostProcessor logBeanPostProcessor() {
// return new LogBeanPostProcessor();
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.LogAutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
|
package com.github.vbauer.herald.ext.spring.context;
/**
* @author Vladislav Bauer
*/
@Configuration
@ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogAutoConfiguration.java
// @Configuration
// public class LogAutoConfiguration {
//
// /**
// * Create {@link LogBeanPostProcessor} and register it in context if missed.
// *
// * @return create {@link LogBeanPostProcessor}
// */
// @Bean
// @ConditionalOnMissingBean(LogBeanPostProcessor.class)
// public LogBeanPostProcessor logBeanPostProcessor() {
// return new LogBeanPostProcessor();
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringBootTestContext.java
import com.github.vbauer.herald.ext.spring.LogAutoConfiguration;
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
package com.github.vbauer.herald.ext.spring.context;
/**
* @author Vladislav Bauer
*/
@Configuration
@ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
|
@ImportAutoConfiguration(LogAutoConfiguration.class)
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/SpringBootRunnerTest.java
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringBootTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// @ImportAutoConfiguration(LogAutoConfiguration.class)
// public class SpringBootTestContext {
// }
|
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.context.SpringBootTestContext;
import org.junit.Test;
import org.springframework.boot.Banner;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
public class SpringBootRunnerTest extends BasicTest {
@Test
public void checkAppRunner() {
final ApplicationContext context = new SpringApplicationBuilder()
.headless(true)
.logStartupInfo(false)
.bannerMode(Banner.Mode.OFF)
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringBootTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// @ImportAutoConfiguration(LogAutoConfiguration.class)
// public class SpringBootTestContext {
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/SpringBootRunnerTest.java
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.context.SpringBootTestContext;
import org.junit.Test;
import org.springframework.boot.Banner;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ApplicationContext;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
public class SpringBootRunnerTest extends BasicTest {
@Test
public void checkAppRunner() {
final ApplicationContext context = new SpringApplicationBuilder()
.headless(true)
.logStartupInfo(false)
.bannerMode(Banner.Mode.OFF)
|
.sources(SpringBootTestContext.class)
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
// public final class ClassLogBeanChecker {
//
// private ClassLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final ClassLogBean bean) {
// assertThat(ClassLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// assertThat(bean.getNotLogger(), equalTo(ClassLogBean.DEF_NOT_LOGGER_VALUE));
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
// public final class LogBeanChecker {
//
// private LogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final LogBean bean) {
// assertThat(LogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
// public final class NamedLogBeanChecker {
//
// private NamedLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final NamedLogBean bean) {
// assertThat(NamedLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import com.github.vbauer.herald.logger.checker.ClassLogBeanChecker;
import com.github.vbauer.herald.logger.checker.LogBeanChecker;
import com.github.vbauer.herald.logger.checker.NamedLogBeanChecker;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.ext.spring.bean;
/**
* @author Vladislav Bauer
*/
@Component
public class CheckerBean {
@Inject
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
// public final class ClassLogBeanChecker {
//
// private ClassLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final ClassLogBean bean) {
// assertThat(ClassLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// assertThat(bean.getNotLogger(), equalTo(ClassLogBean.DEF_NOT_LOGGER_VALUE));
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
// public final class LogBeanChecker {
//
// private LogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final LogBean bean) {
// assertThat(LogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
// public final class NamedLogBeanChecker {
//
// private NamedLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final NamedLogBean bean) {
// assertThat(NamedLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import com.github.vbauer.herald.logger.checker.ClassLogBeanChecker;
import com.github.vbauer.herald.logger.checker.LogBeanChecker;
import com.github.vbauer.herald.logger.checker.NamedLogBeanChecker;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.ext.spring.bean;
/**
* @author Vladislav Bauer
*/
@Component
public class CheckerBean {
@Inject
|
private LogBeanPostProcessor logBeanPostProcessor;
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
// public final class ClassLogBeanChecker {
//
// private ClassLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final ClassLogBean bean) {
// assertThat(ClassLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// assertThat(bean.getNotLogger(), equalTo(ClassLogBean.DEF_NOT_LOGGER_VALUE));
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
// public final class LogBeanChecker {
//
// private LogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final LogBean bean) {
// assertThat(LogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
// public final class NamedLogBeanChecker {
//
// private NamedLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final NamedLogBean bean) {
// assertThat(NamedLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import com.github.vbauer.herald.logger.checker.ClassLogBeanChecker;
import com.github.vbauer.herald.logger.checker.LogBeanChecker;
import com.github.vbauer.herald.logger.checker.NamedLogBeanChecker;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
|
@Inject
public CheckerBean(
final ClassLogBean classLogBean,
final LogBean logBean,
final NamedLogBean namedLogBean
) {
this.classLogBean = classLogBean;
this.logBean = logBean;
this.namedLogBean = namedLogBean;
}
public void checkBeans() {
checkBeans(classLogBean, logBean, namedLogBean);
}
public void checkPostProcessor() {
checkBeans(
checkPostProcessor(new ClassLogBean()),
checkPostProcessor(new LogBean()),
checkPostProcessor(new NamedLogBean())
);
}
private void checkBeans(
final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
) {
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
// public final class ClassLogBeanChecker {
//
// private ClassLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final ClassLogBean bean) {
// assertThat(ClassLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// assertThat(bean.getNotLogger(), equalTo(ClassLogBean.DEF_NOT_LOGGER_VALUE));
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
// public final class LogBeanChecker {
//
// private LogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final LogBean bean) {
// assertThat(LogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
// public final class NamedLogBeanChecker {
//
// private NamedLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final NamedLogBean bean) {
// assertThat(NamedLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import com.github.vbauer.herald.logger.checker.ClassLogBeanChecker;
import com.github.vbauer.herald.logger.checker.LogBeanChecker;
import com.github.vbauer.herald.logger.checker.NamedLogBeanChecker;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
@Inject
public CheckerBean(
final ClassLogBean classLogBean,
final LogBean logBean,
final NamedLogBean namedLogBean
) {
this.classLogBean = classLogBean;
this.logBean = logBean;
this.namedLogBean = namedLogBean;
}
public void checkBeans() {
checkBeans(classLogBean, logBean, namedLogBean);
}
public void checkPostProcessor() {
checkBeans(
checkPostProcessor(new ClassLogBean()),
checkPostProcessor(new LogBean()),
checkPostProcessor(new NamedLogBean())
);
}
private void checkBeans(
final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
) {
|
ClassLogBeanChecker.check(classLogBean);
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
// public final class ClassLogBeanChecker {
//
// private ClassLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final ClassLogBean bean) {
// assertThat(ClassLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// assertThat(bean.getNotLogger(), equalTo(ClassLogBean.DEF_NOT_LOGGER_VALUE));
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
// public final class LogBeanChecker {
//
// private LogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final LogBean bean) {
// assertThat(LogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
// public final class NamedLogBeanChecker {
//
// private NamedLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final NamedLogBean bean) {
// assertThat(NamedLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import com.github.vbauer.herald.logger.checker.ClassLogBeanChecker;
import com.github.vbauer.herald.logger.checker.LogBeanChecker;
import com.github.vbauer.herald.logger.checker.NamedLogBeanChecker;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
|
@Inject
public CheckerBean(
final ClassLogBean classLogBean,
final LogBean logBean,
final NamedLogBean namedLogBean
) {
this.classLogBean = classLogBean;
this.logBean = logBean;
this.namedLogBean = namedLogBean;
}
public void checkBeans() {
checkBeans(classLogBean, logBean, namedLogBean);
}
public void checkPostProcessor() {
checkBeans(
checkPostProcessor(new ClassLogBean()),
checkPostProcessor(new LogBean()),
checkPostProcessor(new NamedLogBean())
);
}
private void checkBeans(
final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
) {
ClassLogBeanChecker.check(classLogBean);
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
// public final class ClassLogBeanChecker {
//
// private ClassLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final ClassLogBean bean) {
// assertThat(ClassLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// assertThat(bean.getNotLogger(), equalTo(ClassLogBean.DEF_NOT_LOGGER_VALUE));
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
// public final class LogBeanChecker {
//
// private LogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final LogBean bean) {
// assertThat(LogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
// public final class NamedLogBeanChecker {
//
// private NamedLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final NamedLogBean bean) {
// assertThat(NamedLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import com.github.vbauer.herald.logger.checker.ClassLogBeanChecker;
import com.github.vbauer.herald.logger.checker.LogBeanChecker;
import com.github.vbauer.herald.logger.checker.NamedLogBeanChecker;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
@Inject
public CheckerBean(
final ClassLogBean classLogBean,
final LogBean logBean,
final NamedLogBean namedLogBean
) {
this.classLogBean = classLogBean;
this.logBean = logBean;
this.namedLogBean = namedLogBean;
}
public void checkBeans() {
checkBeans(classLogBean, logBean, namedLogBean);
}
public void checkPostProcessor() {
checkBeans(
checkPostProcessor(new ClassLogBean()),
checkPostProcessor(new LogBean()),
checkPostProcessor(new NamedLogBean())
);
}
private void checkBeans(
final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
) {
ClassLogBeanChecker.check(classLogBean);
|
LogBeanChecker.check(logBean);
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
// public final class ClassLogBeanChecker {
//
// private ClassLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final ClassLogBean bean) {
// assertThat(ClassLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// assertThat(bean.getNotLogger(), equalTo(ClassLogBean.DEF_NOT_LOGGER_VALUE));
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
// public final class LogBeanChecker {
//
// private LogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final LogBean bean) {
// assertThat(LogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
// public final class NamedLogBeanChecker {
//
// private NamedLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final NamedLogBean bean) {
// assertThat(NamedLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import com.github.vbauer.herald.logger.checker.ClassLogBeanChecker;
import com.github.vbauer.herald.logger.checker.LogBeanChecker;
import com.github.vbauer.herald.logger.checker.NamedLogBeanChecker;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
|
@Inject
public CheckerBean(
final ClassLogBean classLogBean,
final LogBean logBean,
final NamedLogBean namedLogBean
) {
this.classLogBean = classLogBean;
this.logBean = logBean;
this.namedLogBean = namedLogBean;
}
public void checkBeans() {
checkBeans(classLogBean, logBean, namedLogBean);
}
public void checkPostProcessor() {
checkBeans(
checkPostProcessor(new ClassLogBean()),
checkPostProcessor(new LogBean()),
checkPostProcessor(new NamedLogBean())
);
}
private void checkBeans(
final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
) {
ClassLogBeanChecker.check(classLogBean);
LogBeanChecker.check(logBean);
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
// public final class ClassLogBeanChecker {
//
// private ClassLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final ClassLogBean bean) {
// assertThat(ClassLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// assertThat(bean.getNotLogger(), equalTo(ClassLogBean.DEF_NOT_LOGGER_VALUE));
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
// public final class LogBeanChecker {
//
// private LogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final LogBean bean) {
// assertThat(LogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
// public final class NamedLogBeanChecker {
//
// private NamedLogBeanChecker() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void check(final NamedLogBean bean) {
// assertThat(NamedLogBean.getStaticJavaUtilLogger(), notNullValue());
// assertThat(bean.getJavaUtilLogger(), notNullValue());
// assertThat(bean.getCommonsLoggingLogger(), notNullValue());
// assertThat(bean.getLogbackLogger(), notNullValue());
// assertThat(bean.getSlf4jLogger(), notNullValue());
// assertThat(bean.getSlf4jExtLogger(), notNullValue());
// assertThat(bean.getLog4jLogger(), notNullValue());
// assertThat(bean.getLog4j2Logger(), notNullValue());
// assertThat(bean.getJBossLogger(), notNullValue());
// assertThat(bean.getSyslog4jLogger(), notNullValue());
// assertThat(bean.getSyslog4jGraylogLogger(), notNullValue());
// assertThat(bean.getFluentLogger(), notNullValue());
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import com.github.vbauer.herald.logger.checker.ClassLogBeanChecker;
import com.github.vbauer.herald.logger.checker.LogBeanChecker;
import com.github.vbauer.herald.logger.checker.NamedLogBeanChecker;
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;
@Inject
public CheckerBean(
final ClassLogBean classLogBean,
final LogBean logBean,
final NamedLogBean namedLogBean
) {
this.classLogBean = classLogBean;
this.logBean = logBean;
this.namedLogBean = namedLogBean;
}
public void checkBeans() {
checkBeans(classLogBean, logBean, namedLogBean);
}
public void checkPostProcessor() {
checkBeans(
checkPostProcessor(new ClassLogBean()),
checkPostProcessor(new LogBean()),
checkPostProcessor(new NamedLogBean())
);
}
private void checkBeans(
final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
) {
ClassLogBeanChecker.check(classLogBean);
LogBeanChecker.check(logBean);
|
NamedLogBeanChecker.check(namedLogBean);
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/exception/HeraldExceptionTest.java
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/impl/JavaUtilLogFactory.java
// @SuppressWarnings("all")
// @JService(LogFactory.class)
// public class JavaUtilLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "java.util.logging.Logger";
// public static final String FACTORY_CLASS_NAME = LOGGER_CLASS_NAME;
// public static final String FACTORY_METHOD_NAME = "getLogger";
//
//
// public JavaUtilLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(clazz.getSimpleName());
// }
//
// }
|
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.logger.impl.JavaUtilLogFactory;
import org.junit.Test;
import java.lang.reflect.Modifier;
import java.util.logging.Logger;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.exception;
/**
* @author Vladislav Bauer
*/
public class HeraldExceptionTest extends BasicTest {
@Test
public void testHeraldException() {
final int modifiers = HeraldException.class.getModifiers();
assertThat(Modifier.isAbstract(modifiers), equalTo(true));
assertThat(Modifier.isPublic(modifiers), equalTo(true));
try {
throw new HeraldException() {
private static final long serialVersionUID = 1L;
};
} catch (final HeraldException ex) {
checkMessage(ex);
}
}
@Test
public void testMissedLogFactoryException() {
final Class<Logger> loggerClass = Logger.class;
try {
throw new MissedLogFactoryException(loggerClass);
} catch (final MissedLogFactoryException ex) {
assertThat(loggerClass.isAssignableFrom(ex.getLoggerClass()), equalTo(true));
checkMessage(ex);
}
}
@Test
public void testLoggerInstantiationException() {
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/impl/JavaUtilLogFactory.java
// @SuppressWarnings("all")
// @JService(LogFactory.class)
// public class JavaUtilLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "java.util.logging.Logger";
// public static final String FACTORY_CLASS_NAME = LOGGER_CLASS_NAME;
// public static final String FACTORY_METHOD_NAME = "getLogger";
//
//
// public JavaUtilLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(clazz.getSimpleName());
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/exception/HeraldExceptionTest.java
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.logger.impl.JavaUtilLogFactory;
import org.junit.Test;
import java.lang.reflect.Modifier;
import java.util.logging.Logger;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.exception;
/**
* @author Vladislav Bauer
*/
public class HeraldExceptionTest extends BasicTest {
@Test
public void testHeraldException() {
final int modifiers = HeraldException.class.getModifiers();
assertThat(Modifier.isAbstract(modifiers), equalTo(true));
assertThat(Modifier.isPublic(modifiers), equalTo(true));
try {
throw new HeraldException() {
private static final long serialVersionUID = 1L;
};
} catch (final HeraldException ex) {
checkMessage(ex);
}
}
@Test
public void testMissedLogFactoryException() {
final Class<Logger> loggerClass = Logger.class;
try {
throw new MissedLogFactoryException(loggerClass);
} catch (final MissedLogFactoryException ex) {
assertThat(loggerClass.isAssignableFrom(ex.getLoggerClass()), equalTo(true));
checkMessage(ex);
}
}
@Test
public void testLoggerInstantiationException() {
|
final JavaUtilLogFactory logFactory = new JavaUtilLogFactory();
|
vbauer/herald
|
src/main/java/com/github/vbauer/herald/ext/guice/LogModule.java
|
// Path: src/main/java/com/github/vbauer/herald/injector/LoggerInjector.java
// public final class LoggerInjector {
//
// private static final Collection<LogFactory> LOG_FACTORIES = loadLogFactories();
//
//
// private LoggerInjector() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void inject(final Object... beans) {
// if (beans != null) {
// for (final Object bean : beans) {
// inject(bean);
// }
// }
// }
//
// public static <T> T inject(final T bean) {
// if (bean != null) {
// final Class<?> beanClass = bean.getClass();
// final Field[] declaredFields = beanClass.getDeclaredFields();
//
// for (final Field field : declaredFields) {
// if (needToInjectLogger(beanClass, field)) {
// injectLogger(bean, field);
// }
// }
// }
// return bean;
// }
//
//
// /*
// * Internal API.
// */
//
// private static boolean needToInjectLogger(final Class<?> beanClass, final Field field) {
// final boolean hasAnnotation = beanClass.getAnnotation(Log.class) != null;
// if (hasAnnotation) {
// final Class<?> fieldType = field.getType();
// return LogFactoryDetector.hasCompatible(LOG_FACTORIES, fieldType);
// }
// return field.getAnnotation(Log.class) != null;
// }
//
// private static void injectLogger(final Object bean, final Field field) {
// final boolean isAccessible = field.isAccessible();
// ReflectionUtils.setAccessible(field, true);
//
// // Read context parameters.
// final Class<?> beanClass = bean.getClass();
// final Class<?> loggerClass = field.getType();
// final Log annotation = ReflectionUtils.findAnnotation(Log.class, beanClass, field);
//
// final boolean required = annotation.required();
// final String loggerName = annotation.value();
//
// try {
// final Object logger = createLogger(beanClass, loggerClass, loggerName);
// field.set(bean, logger);
// } catch (final Throwable ex) {
// if (required) {
// ReflectionUtils.handleReflectionException(ex);
// }
// } finally {
// ReflectionUtils.setAccessible(field, isAccessible);
// }
// }
//
// private static Object createLogger(
// final Class<?> beanClass, final Class<?> loggerClass, final String loggerName
// ) {
// // Find corresponding logger factory.
// final LogFactory logFactory =
// LogFactoryDetector.findCompatible(LOG_FACTORIES, loggerClass);
//
// if (logFactory == null) {
// throw new MissedLogFactoryException(loggerClass);
// }
//
// // Create logger.
// final Object logger = !loggerName.isEmpty()
// ? logFactory.createLogger(loggerName) : logFactory.createLogger(beanClass);
//
// if (logger == null) {
// throw new LoggerInstantiationException(logFactory);
// }
// return logger;
// }
//
// private static Collection<LogFactory> loadLogFactories() {
// return ServiceLoaderUtils.load(LogFactory.class);
// }
//
// }
|
import com.github.vbauer.herald.injector.LoggerInjector;
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.matcher.Matcher;
import com.google.inject.matcher.Matchers;
import com.google.inject.spi.InjectionListener;
import com.google.inject.spi.TypeEncounter;
import com.google.inject.spi.TypeListener;
|
package com.github.vbauer.herald.ext.guice;
/**
* Guice {@link AbstractModule} which injects initialized loggers in beans.
*
* @author Vladislav Bauer
*/
public class LogModule extends AbstractModule {
private final Matcher<Object> typeMatcher;
public LogModule() {
this(Matchers.any());
}
public LogModule(final Matcher<Object> typeMatcher) {
this.typeMatcher = typeMatcher;
}
/**
* {@inheritDoc}
*/
@Override
protected void configure() {
bindListener(typeMatcher, createTypeListener());
}
private TypeListener createTypeListener() {
return new TypeListener() {
@Override
public <I> void hear(final TypeLiteral<I> typeLiteral, final TypeEncounter<I> typeEncounter) {
|
// Path: src/main/java/com/github/vbauer/herald/injector/LoggerInjector.java
// public final class LoggerInjector {
//
// private static final Collection<LogFactory> LOG_FACTORIES = loadLogFactories();
//
//
// private LoggerInjector() {
// throw new UnsupportedOperationException();
// }
//
//
// public static void inject(final Object... beans) {
// if (beans != null) {
// for (final Object bean : beans) {
// inject(bean);
// }
// }
// }
//
// public static <T> T inject(final T bean) {
// if (bean != null) {
// final Class<?> beanClass = bean.getClass();
// final Field[] declaredFields = beanClass.getDeclaredFields();
//
// for (final Field field : declaredFields) {
// if (needToInjectLogger(beanClass, field)) {
// injectLogger(bean, field);
// }
// }
// }
// return bean;
// }
//
//
// /*
// * Internal API.
// */
//
// private static boolean needToInjectLogger(final Class<?> beanClass, final Field field) {
// final boolean hasAnnotation = beanClass.getAnnotation(Log.class) != null;
// if (hasAnnotation) {
// final Class<?> fieldType = field.getType();
// return LogFactoryDetector.hasCompatible(LOG_FACTORIES, fieldType);
// }
// return field.getAnnotation(Log.class) != null;
// }
//
// private static void injectLogger(final Object bean, final Field field) {
// final boolean isAccessible = field.isAccessible();
// ReflectionUtils.setAccessible(field, true);
//
// // Read context parameters.
// final Class<?> beanClass = bean.getClass();
// final Class<?> loggerClass = field.getType();
// final Log annotation = ReflectionUtils.findAnnotation(Log.class, beanClass, field);
//
// final boolean required = annotation.required();
// final String loggerName = annotation.value();
//
// try {
// final Object logger = createLogger(beanClass, loggerClass, loggerName);
// field.set(bean, logger);
// } catch (final Throwable ex) {
// if (required) {
// ReflectionUtils.handleReflectionException(ex);
// }
// } finally {
// ReflectionUtils.setAccessible(field, isAccessible);
// }
// }
//
// private static Object createLogger(
// final Class<?> beanClass, final Class<?> loggerClass, final String loggerName
// ) {
// // Find corresponding logger factory.
// final LogFactory logFactory =
// LogFactoryDetector.findCompatible(LOG_FACTORIES, loggerClass);
//
// if (logFactory == null) {
// throw new MissedLogFactoryException(loggerClass);
// }
//
// // Create logger.
// final Object logger = !loggerName.isEmpty()
// ? logFactory.createLogger(loggerName) : logFactory.createLogger(beanClass);
//
// if (logger == null) {
// throw new LoggerInstantiationException(logFactory);
// }
// return logger;
// }
//
// private static Collection<LogFactory> loadLogFactories() {
// return ServiceLoaderUtils.load(LogFactory.class);
// }
//
// }
// Path: src/main/java/com/github/vbauer/herald/ext/guice/LogModule.java
import com.github.vbauer.herald.injector.LoggerInjector;
import com.google.inject.AbstractModule;
import com.google.inject.TypeLiteral;
import com.google.inject.matcher.Matcher;
import com.google.inject.matcher.Matchers;
import com.google.inject.spi.InjectionListener;
import com.google.inject.spi.TypeEncounter;
import com.google.inject.spi.TypeListener;
package com.github.vbauer.herald.ext.guice;
/**
* Guice {@link AbstractModule} which injects initialized loggers in beans.
*
* @author Vladislav Bauer
*/
public class LogModule extends AbstractModule {
private final Matcher<Object> typeMatcher;
public LogModule() {
this(Matchers.any());
}
public LogModule(final Matcher<Object> typeMatcher) {
this.typeMatcher = typeMatcher;
}
/**
* {@inheritDoc}
*/
@Override
protected void configure() {
bindListener(typeMatcher, createTypeListener());
}
private TypeListener createTypeListener() {
return new TypeListener() {
@Override
public <I> void hear(final TypeLiteral<I> typeLiteral, final TypeEncounter<I> typeEncounter) {
|
typeEncounter.register((InjectionListener<I>) LoggerInjector::inject);
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/bean/NamedLogBean.java
|
// Path: src/main/java/com/github/vbauer/herald/logger/impl/Syslog4jGraylogLogFactory.java
// @SuppressWarnings("all")
// @JService(LogFactory.class)
// public class Syslog4jGraylogLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "org.graylog2.syslog4j.SyslogIF";
// public static final String FACTORY_CLASS_NAME = "org.graylog2.syslog4j.Syslog";
// public static final String FACTORY_METHOD_NAME = "getInstance";
//
// public static final String DEFAULT_PROTOCOL = "udp";
//
//
// public Syslog4jGraylogLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * Create SyslogIF client using {@value #DEFAULT_PROTOCOL}.
// *
// * @param clazz parameters is not used
// * @return logger
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(DEFAULT_PROTOCOL);
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/impl/Syslog4jLogFactory.java
// @JService(LogFactory.class)
// public class Syslog4jLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "org.productivity.java.syslog4j.SyslogIF";
// public static final String FACTORY_CLASS_NAME = "org.productivity.java.syslog4j.Syslog";
// public static final String FACTORY_METHOD_NAME = "getInstance";
//
// public static final String DEFAULT_PROTOCOL = "udp";
//
//
// public Syslog4jLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * Create SyslogIF client using {@value #DEFAULT_PROTOCOL}.
// *
// * @param clazz parameters is not used
// * @return logger
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(DEFAULT_PROTOCOL);
// }
//
//
// }
|
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.logger.impl.Syslog4jGraylogLogFactory;
import com.github.vbauer.herald.logger.impl.Syslog4jLogFactory;
import org.springframework.stereotype.Component;
|
package com.github.vbauer.herald.ext.spring.bean;
/**
* @author Vladislav Bauer
*/
@Component
@SuppressWarnings("all")
public class NamedLogBean {
private static final String LOGGER_NAME = "logger";
@Log(LOGGER_NAME)
private static java.util.logging.Logger staticJavaUtilLogger;
@Log(LOGGER_NAME)
private java.util.logging.Logger javaUtilLogger;
@Log(LOGGER_NAME)
private org.apache.commons.logging.Log commonsLoggingLogger;
@Log(LOGGER_NAME)
private ch.qos.logback.classic.Logger logbackLogger;
@Log(LOGGER_NAME)
private org.slf4j.Logger slf4jLogger;
@Log(LOGGER_NAME)
private org.apache.log4j.Logger log4jLogger;
@Log(LOGGER_NAME)
private org.slf4j.ext.XLogger slf4jExtLogger;
@Log(LOGGER_NAME)
private org.apache.logging.log4j.Logger log4j2Logger;
@Log(LOGGER_NAME)
private org.jboss.logging.Logger jbossLogger;
|
// Path: src/main/java/com/github/vbauer/herald/logger/impl/Syslog4jGraylogLogFactory.java
// @SuppressWarnings("all")
// @JService(LogFactory.class)
// public class Syslog4jGraylogLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "org.graylog2.syslog4j.SyslogIF";
// public static final String FACTORY_CLASS_NAME = "org.graylog2.syslog4j.Syslog";
// public static final String FACTORY_METHOD_NAME = "getInstance";
//
// public static final String DEFAULT_PROTOCOL = "udp";
//
//
// public Syslog4jGraylogLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * Create SyslogIF client using {@value #DEFAULT_PROTOCOL}.
// *
// * @param clazz parameters is not used
// * @return logger
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(DEFAULT_PROTOCOL);
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/impl/Syslog4jLogFactory.java
// @JService(LogFactory.class)
// public class Syslog4jLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "org.productivity.java.syslog4j.SyslogIF";
// public static final String FACTORY_CLASS_NAME = "org.productivity.java.syslog4j.Syslog";
// public static final String FACTORY_METHOD_NAME = "getInstance";
//
// public static final String DEFAULT_PROTOCOL = "udp";
//
//
// public Syslog4jLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * Create SyslogIF client using {@value #DEFAULT_PROTOCOL}.
// *
// * @param clazz parameters is not used
// * @return logger
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(DEFAULT_PROTOCOL);
// }
//
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/NamedLogBean.java
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.logger.impl.Syslog4jGraylogLogFactory;
import com.github.vbauer.herald.logger.impl.Syslog4jLogFactory;
import org.springframework.stereotype.Component;
package com.github.vbauer.herald.ext.spring.bean;
/**
* @author Vladislav Bauer
*/
@Component
@SuppressWarnings("all")
public class NamedLogBean {
private static final String LOGGER_NAME = "logger";
@Log(LOGGER_NAME)
private static java.util.logging.Logger staticJavaUtilLogger;
@Log(LOGGER_NAME)
private java.util.logging.Logger javaUtilLogger;
@Log(LOGGER_NAME)
private org.apache.commons.logging.Log commonsLoggingLogger;
@Log(LOGGER_NAME)
private ch.qos.logback.classic.Logger logbackLogger;
@Log(LOGGER_NAME)
private org.slf4j.Logger slf4jLogger;
@Log(LOGGER_NAME)
private org.apache.log4j.Logger log4jLogger;
@Log(LOGGER_NAME)
private org.slf4j.ext.XLogger slf4jExtLogger;
@Log(LOGGER_NAME)
private org.apache.logging.log4j.Logger log4j2Logger;
@Log(LOGGER_NAME)
private org.jboss.logging.Logger jbossLogger;
|
@Log(Syslog4jLogFactory.DEFAULT_PROTOCOL)
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/bean/NamedLogBean.java
|
// Path: src/main/java/com/github/vbauer/herald/logger/impl/Syslog4jGraylogLogFactory.java
// @SuppressWarnings("all")
// @JService(LogFactory.class)
// public class Syslog4jGraylogLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "org.graylog2.syslog4j.SyslogIF";
// public static final String FACTORY_CLASS_NAME = "org.graylog2.syslog4j.Syslog";
// public static final String FACTORY_METHOD_NAME = "getInstance";
//
// public static final String DEFAULT_PROTOCOL = "udp";
//
//
// public Syslog4jGraylogLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * Create SyslogIF client using {@value #DEFAULT_PROTOCOL}.
// *
// * @param clazz parameters is not used
// * @return logger
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(DEFAULT_PROTOCOL);
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/impl/Syslog4jLogFactory.java
// @JService(LogFactory.class)
// public class Syslog4jLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "org.productivity.java.syslog4j.SyslogIF";
// public static final String FACTORY_CLASS_NAME = "org.productivity.java.syslog4j.Syslog";
// public static final String FACTORY_METHOD_NAME = "getInstance";
//
// public static final String DEFAULT_PROTOCOL = "udp";
//
//
// public Syslog4jLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * Create SyslogIF client using {@value #DEFAULT_PROTOCOL}.
// *
// * @param clazz parameters is not used
// * @return logger
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(DEFAULT_PROTOCOL);
// }
//
//
// }
|
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.logger.impl.Syslog4jGraylogLogFactory;
import com.github.vbauer.herald.logger.impl.Syslog4jLogFactory;
import org.springframework.stereotype.Component;
|
package com.github.vbauer.herald.ext.spring.bean;
/**
* @author Vladislav Bauer
*/
@Component
@SuppressWarnings("all")
public class NamedLogBean {
private static final String LOGGER_NAME = "logger";
@Log(LOGGER_NAME)
private static java.util.logging.Logger staticJavaUtilLogger;
@Log(LOGGER_NAME)
private java.util.logging.Logger javaUtilLogger;
@Log(LOGGER_NAME)
private org.apache.commons.logging.Log commonsLoggingLogger;
@Log(LOGGER_NAME)
private ch.qos.logback.classic.Logger logbackLogger;
@Log(LOGGER_NAME)
private org.slf4j.Logger slf4jLogger;
@Log(LOGGER_NAME)
private org.apache.log4j.Logger log4jLogger;
@Log(LOGGER_NAME)
private org.slf4j.ext.XLogger slf4jExtLogger;
@Log(LOGGER_NAME)
private org.apache.logging.log4j.Logger log4j2Logger;
@Log(LOGGER_NAME)
private org.jboss.logging.Logger jbossLogger;
@Log(Syslog4jLogFactory.DEFAULT_PROTOCOL)
private org.productivity.java.syslog4j.SyslogIF syslog4jLogger;
|
// Path: src/main/java/com/github/vbauer/herald/logger/impl/Syslog4jGraylogLogFactory.java
// @SuppressWarnings("all")
// @JService(LogFactory.class)
// public class Syslog4jGraylogLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "org.graylog2.syslog4j.SyslogIF";
// public static final String FACTORY_CLASS_NAME = "org.graylog2.syslog4j.Syslog";
// public static final String FACTORY_METHOD_NAME = "getInstance";
//
// public static final String DEFAULT_PROTOCOL = "udp";
//
//
// public Syslog4jGraylogLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * Create SyslogIF client using {@value #DEFAULT_PROTOCOL}.
// *
// * @param clazz parameters is not used
// * @return logger
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(DEFAULT_PROTOCOL);
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/impl/Syslog4jLogFactory.java
// @JService(LogFactory.class)
// public class Syslog4jLogFactory extends SimpleLogFactory {
//
// public static final String LOGGER_CLASS_NAME = "org.productivity.java.syslog4j.SyslogIF";
// public static final String FACTORY_CLASS_NAME = "org.productivity.java.syslog4j.Syslog";
// public static final String FACTORY_METHOD_NAME = "getInstance";
//
// public static final String DEFAULT_PROTOCOL = "udp";
//
//
// public Syslog4jLogFactory() {
// super(LOGGER_CLASS_NAME, FACTORY_CLASS_NAME, FACTORY_METHOD_NAME);
// }
//
//
// /**
// * Create SyslogIF client using {@value #DEFAULT_PROTOCOL}.
// *
// * @param clazz parameters is not used
// * @return logger
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLogger(DEFAULT_PROTOCOL);
// }
//
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/NamedLogBean.java
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.logger.impl.Syslog4jGraylogLogFactory;
import com.github.vbauer.herald.logger.impl.Syslog4jLogFactory;
import org.springframework.stereotype.Component;
package com.github.vbauer.herald.ext.spring.bean;
/**
* @author Vladislav Bauer
*/
@Component
@SuppressWarnings("all")
public class NamedLogBean {
private static final String LOGGER_NAME = "logger";
@Log(LOGGER_NAME)
private static java.util.logging.Logger staticJavaUtilLogger;
@Log(LOGGER_NAME)
private java.util.logging.Logger javaUtilLogger;
@Log(LOGGER_NAME)
private org.apache.commons.logging.Log commonsLoggingLogger;
@Log(LOGGER_NAME)
private ch.qos.logback.classic.Logger logbackLogger;
@Log(LOGGER_NAME)
private org.slf4j.Logger slf4jLogger;
@Log(LOGGER_NAME)
private org.apache.log4j.Logger log4jLogger;
@Log(LOGGER_NAME)
private org.slf4j.ext.XLogger slf4jExtLogger;
@Log(LOGGER_NAME)
private org.apache.logging.log4j.Logger log4j2Logger;
@Log(LOGGER_NAME)
private org.jboss.logging.Logger jbossLogger;
@Log(Syslog4jLogFactory.DEFAULT_PROTOCOL)
private org.productivity.java.syslog4j.SyslogIF syslog4jLogger;
|
@Log(Syslog4jGraylogLogFactory.DEFAULT_PROTOCOL)
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/logger/empty/NullLogFactory.java
|
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/impl/SimpleLogFactory.java
// public abstract class SimpleLogFactory implements LogFactory {
//
// private final String loggerClassName;
// private final String loggerFactoryClassName;
// private final String loggerFactoryMethod;
//
//
// protected SimpleLogFactory(
// final String loggerClassName,
// final String loggerFactoryClassName, final String loggerFactoryMethod
// ) {
// this.loggerClassName = loggerClassName;
// this.loggerFactoryClassName = loggerFactoryClassName;
// this.loggerFactoryMethod = loggerFactoryMethod;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean isCompatible(final Class<?> loggerClass) {
// return ReflectionUtils.isAssignableFrom(loggerClassName, loggerClass);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLoggerObject(clazz);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object createLogger(final String name) {
// return createLoggerObject(name);
// }
//
//
// private Object createLoggerObject(final Object id) {
// return ReflectionUtils.invokeStatic(
// loggerFactoryClassName,
// loggerFactoryMethod,
// id
// );
// }
//
// }
|
import com.github.vbauer.herald.logger.LogFactory;
import com.github.vbauer.herald.logger.impl.SimpleLogFactory;
import com.github.vbauer.jackdaw.annotation.JService;
|
package com.github.vbauer.herald.logger.empty;
/**
* @author Vladislav Bauer
*/
@SuppressWarnings("all")
@JService(LogFactory.class)
|
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/impl/SimpleLogFactory.java
// public abstract class SimpleLogFactory implements LogFactory {
//
// private final String loggerClassName;
// private final String loggerFactoryClassName;
// private final String loggerFactoryMethod;
//
//
// protected SimpleLogFactory(
// final String loggerClassName,
// final String loggerFactoryClassName, final String loggerFactoryMethod
// ) {
// this.loggerClassName = loggerClassName;
// this.loggerFactoryClassName = loggerFactoryClassName;
// this.loggerFactoryMethod = loggerFactoryMethod;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public boolean isCompatible(final Class<?> loggerClass) {
// return ReflectionUtils.isAssignableFrom(loggerClassName, loggerClass);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object createLogger(final Class<?> clazz) {
// return createLoggerObject(clazz);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object createLogger(final String name) {
// return createLoggerObject(name);
// }
//
//
// private Object createLoggerObject(final Object id) {
// return ReflectionUtils.invokeStatic(
// loggerFactoryClassName,
// loggerFactoryMethod,
// id
// );
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/logger/empty/NullLogFactory.java
import com.github.vbauer.herald.logger.LogFactory;
import com.github.vbauer.herald.logger.impl.SimpleLogFactory;
import com.github.vbauer.jackdaw.annotation.JService;
package com.github.vbauer.herald.logger.empty;
/**
* @author Vladislav Bauer
*/
@SuppressWarnings("all")
@JService(LogFactory.class)
|
public class NullLogFactory extends SimpleLogFactory {
|
vbauer/herald
|
src/main/java/com/github/vbauer/herald/injector/LoggerInjector.java
|
// Path: src/main/java/com/github/vbauer/herald/exception/LoggerInstantiationException.java
// @SuppressWarnings("serial")
// public class LoggerInstantiationException extends HeraldException {
//
// private final LogFactory loggerFactory;
//
//
// public LoggerInstantiationException(final LogFactory loggerFactory) {
// this.loggerFactory = loggerFactory;
// }
//
//
// /**
// * Get logger factory, see {@link LogFactory}.
// *
// * @return logger factory
// */
// public LogFactory getLoggerFactory() {
// return loggerFactory;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getMessage() {
// return String.format("Can't create logger using factory %s", getLoggerFactory());
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/exception/MissedLogFactoryException.java
// @SuppressWarnings("serial")
// public class MissedLogFactoryException extends HeraldException {
//
// private final Class<?> loggerClass;
//
//
// public MissedLogFactoryException(final Class<?> loggerClass) {
// this.loggerClass = loggerClass;
// }
//
//
// /**
// * Get logger class.
// *
// * @return logger class
// */
// public Class<?> getLoggerClass() {
// return loggerClass;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getMessage() {
// return String.format("Can not find log factory for logger %s", getLoggerClass());
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ReflectionUtils.java
// public final class ReflectionUtils {
//
// private ReflectionUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static boolean isAssignableFrom(final String className, final Class<?> from) {
// try {
// final Class<?> clazz = Class.forName(className);
// return clazz.isAssignableFrom(from);
// } catch (final Throwable ex) {
// return false;
// }
// }
//
// @SuppressWarnings("unchecked")
// public static <I, O> O invokeStatic(final String className, final String methodName, final I argument) {
// try {
// final Class<?> clazz = Class.forName(className);
// final Class<?> argumentClass = argument.getClass();
//
// final Method method = clazz.getDeclaredMethod(methodName, argumentClass);
// return (O) method.invoke(null, argument);
// } catch (final Exception ex) {
// return handleReflectionException(ex);
// }
// }
//
// public static <T> T handleReflectionException(final Throwable ex) {
// if (ex instanceof RuntimeException) {
// throw (RuntimeException) ex;
// } else if (ex instanceof Error) {
// throw (Error) ex;
// }
// throw new RuntimeException(ex);
// }
//
// public static <T extends Annotation> T findAnnotation(
// final Class<T> annotationClass, final Class<?> beanClass, final Field field
// ) {
// final T fieldAnnotation = field.getAnnotation(annotationClass);
// return fieldAnnotation == null ? beanClass.getAnnotation(annotationClass) : fieldAnnotation;
// }
//
// public static boolean setAccessible(final AccessibleObject object, final boolean accessible) {
// try {
// object.setAccessible(accessible);
// return true;
// } catch (final Throwable ignored) {
// // Ignored.
// return false;
// }
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ServiceLoaderUtils.java
// public final class ServiceLoaderUtils {
//
// private ServiceLoaderUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static <T> Collection<T> load(final Class<T> beanClass) {
// final ServiceLoader<T> serviceLoader = ServiceLoader.load(beanClass);
// final Iterator<T> iterator = serviceLoader.iterator();
//
// final List<T> result = new ArrayList<>();
// while (iterator.hasNext()) {
// result.add(iterator.next());
// }
// return result;
// }
//
// }
|
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.exception.LoggerInstantiationException;
import com.github.vbauer.herald.exception.MissedLogFactoryException;
import com.github.vbauer.herald.logger.LogFactory;
import com.github.vbauer.herald.util.ReflectionUtils;
import com.github.vbauer.herald.util.ServiceLoaderUtils;
import java.lang.reflect.Field;
import java.util.Collection;
|
final String loggerName = annotation.value();
try {
final Object logger = createLogger(beanClass, loggerClass, loggerName);
field.set(bean, logger);
} catch (final Throwable ex) {
if (required) {
ReflectionUtils.handleReflectionException(ex);
}
} finally {
ReflectionUtils.setAccessible(field, isAccessible);
}
}
private static Object createLogger(
final Class<?> beanClass, final Class<?> loggerClass, final String loggerName
) {
// Find corresponding logger factory.
final LogFactory logFactory =
LogFactoryDetector.findCompatible(LOG_FACTORIES, loggerClass);
if (logFactory == null) {
throw new MissedLogFactoryException(loggerClass);
}
// Create logger.
final Object logger = !loggerName.isEmpty()
? logFactory.createLogger(loggerName) : logFactory.createLogger(beanClass);
if (logger == null) {
|
// Path: src/main/java/com/github/vbauer/herald/exception/LoggerInstantiationException.java
// @SuppressWarnings("serial")
// public class LoggerInstantiationException extends HeraldException {
//
// private final LogFactory loggerFactory;
//
//
// public LoggerInstantiationException(final LogFactory loggerFactory) {
// this.loggerFactory = loggerFactory;
// }
//
//
// /**
// * Get logger factory, see {@link LogFactory}.
// *
// * @return logger factory
// */
// public LogFactory getLoggerFactory() {
// return loggerFactory;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getMessage() {
// return String.format("Can't create logger using factory %s", getLoggerFactory());
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/exception/MissedLogFactoryException.java
// @SuppressWarnings("serial")
// public class MissedLogFactoryException extends HeraldException {
//
// private final Class<?> loggerClass;
//
//
// public MissedLogFactoryException(final Class<?> loggerClass) {
// this.loggerClass = loggerClass;
// }
//
//
// /**
// * Get logger class.
// *
// * @return logger class
// */
// public Class<?> getLoggerClass() {
// return loggerClass;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getMessage() {
// return String.format("Can not find log factory for logger %s", getLoggerClass());
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ReflectionUtils.java
// public final class ReflectionUtils {
//
// private ReflectionUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static boolean isAssignableFrom(final String className, final Class<?> from) {
// try {
// final Class<?> clazz = Class.forName(className);
// return clazz.isAssignableFrom(from);
// } catch (final Throwable ex) {
// return false;
// }
// }
//
// @SuppressWarnings("unchecked")
// public static <I, O> O invokeStatic(final String className, final String methodName, final I argument) {
// try {
// final Class<?> clazz = Class.forName(className);
// final Class<?> argumentClass = argument.getClass();
//
// final Method method = clazz.getDeclaredMethod(methodName, argumentClass);
// return (O) method.invoke(null, argument);
// } catch (final Exception ex) {
// return handleReflectionException(ex);
// }
// }
//
// public static <T> T handleReflectionException(final Throwable ex) {
// if (ex instanceof RuntimeException) {
// throw (RuntimeException) ex;
// } else if (ex instanceof Error) {
// throw (Error) ex;
// }
// throw new RuntimeException(ex);
// }
//
// public static <T extends Annotation> T findAnnotation(
// final Class<T> annotationClass, final Class<?> beanClass, final Field field
// ) {
// final T fieldAnnotation = field.getAnnotation(annotationClass);
// return fieldAnnotation == null ? beanClass.getAnnotation(annotationClass) : fieldAnnotation;
// }
//
// public static boolean setAccessible(final AccessibleObject object, final boolean accessible) {
// try {
// object.setAccessible(accessible);
// return true;
// } catch (final Throwable ignored) {
// // Ignored.
// return false;
// }
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ServiceLoaderUtils.java
// public final class ServiceLoaderUtils {
//
// private ServiceLoaderUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static <T> Collection<T> load(final Class<T> beanClass) {
// final ServiceLoader<T> serviceLoader = ServiceLoader.load(beanClass);
// final Iterator<T> iterator = serviceLoader.iterator();
//
// final List<T> result = new ArrayList<>();
// while (iterator.hasNext()) {
// result.add(iterator.next());
// }
// return result;
// }
//
// }
// Path: src/main/java/com/github/vbauer/herald/injector/LoggerInjector.java
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.exception.LoggerInstantiationException;
import com.github.vbauer.herald.exception.MissedLogFactoryException;
import com.github.vbauer.herald.logger.LogFactory;
import com.github.vbauer.herald.util.ReflectionUtils;
import com.github.vbauer.herald.util.ServiceLoaderUtils;
import java.lang.reflect.Field;
import java.util.Collection;
final String loggerName = annotation.value();
try {
final Object logger = createLogger(beanClass, loggerClass, loggerName);
field.set(bean, logger);
} catch (final Throwable ex) {
if (required) {
ReflectionUtils.handleReflectionException(ex);
}
} finally {
ReflectionUtils.setAccessible(field, isAccessible);
}
}
private static Object createLogger(
final Class<?> beanClass, final Class<?> loggerClass, final String loggerName
) {
// Find corresponding logger factory.
final LogFactory logFactory =
LogFactoryDetector.findCompatible(LOG_FACTORIES, loggerClass);
if (logFactory == null) {
throw new MissedLogFactoryException(loggerClass);
}
// Create logger.
final Object logger = !loggerName.isEmpty()
? logFactory.createLogger(loggerName) : logFactory.createLogger(beanClass);
if (logger == null) {
|
throw new LoggerInstantiationException(logFactory);
|
vbauer/herald
|
src/main/java/com/github/vbauer/herald/injector/LoggerInjector.java
|
// Path: src/main/java/com/github/vbauer/herald/exception/LoggerInstantiationException.java
// @SuppressWarnings("serial")
// public class LoggerInstantiationException extends HeraldException {
//
// private final LogFactory loggerFactory;
//
//
// public LoggerInstantiationException(final LogFactory loggerFactory) {
// this.loggerFactory = loggerFactory;
// }
//
//
// /**
// * Get logger factory, see {@link LogFactory}.
// *
// * @return logger factory
// */
// public LogFactory getLoggerFactory() {
// return loggerFactory;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getMessage() {
// return String.format("Can't create logger using factory %s", getLoggerFactory());
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/exception/MissedLogFactoryException.java
// @SuppressWarnings("serial")
// public class MissedLogFactoryException extends HeraldException {
//
// private final Class<?> loggerClass;
//
//
// public MissedLogFactoryException(final Class<?> loggerClass) {
// this.loggerClass = loggerClass;
// }
//
//
// /**
// * Get logger class.
// *
// * @return logger class
// */
// public Class<?> getLoggerClass() {
// return loggerClass;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getMessage() {
// return String.format("Can not find log factory for logger %s", getLoggerClass());
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ReflectionUtils.java
// public final class ReflectionUtils {
//
// private ReflectionUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static boolean isAssignableFrom(final String className, final Class<?> from) {
// try {
// final Class<?> clazz = Class.forName(className);
// return clazz.isAssignableFrom(from);
// } catch (final Throwable ex) {
// return false;
// }
// }
//
// @SuppressWarnings("unchecked")
// public static <I, O> O invokeStatic(final String className, final String methodName, final I argument) {
// try {
// final Class<?> clazz = Class.forName(className);
// final Class<?> argumentClass = argument.getClass();
//
// final Method method = clazz.getDeclaredMethod(methodName, argumentClass);
// return (O) method.invoke(null, argument);
// } catch (final Exception ex) {
// return handleReflectionException(ex);
// }
// }
//
// public static <T> T handleReflectionException(final Throwable ex) {
// if (ex instanceof RuntimeException) {
// throw (RuntimeException) ex;
// } else if (ex instanceof Error) {
// throw (Error) ex;
// }
// throw new RuntimeException(ex);
// }
//
// public static <T extends Annotation> T findAnnotation(
// final Class<T> annotationClass, final Class<?> beanClass, final Field field
// ) {
// final T fieldAnnotation = field.getAnnotation(annotationClass);
// return fieldAnnotation == null ? beanClass.getAnnotation(annotationClass) : fieldAnnotation;
// }
//
// public static boolean setAccessible(final AccessibleObject object, final boolean accessible) {
// try {
// object.setAccessible(accessible);
// return true;
// } catch (final Throwable ignored) {
// // Ignored.
// return false;
// }
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ServiceLoaderUtils.java
// public final class ServiceLoaderUtils {
//
// private ServiceLoaderUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static <T> Collection<T> load(final Class<T> beanClass) {
// final ServiceLoader<T> serviceLoader = ServiceLoader.load(beanClass);
// final Iterator<T> iterator = serviceLoader.iterator();
//
// final List<T> result = new ArrayList<>();
// while (iterator.hasNext()) {
// result.add(iterator.next());
// }
// return result;
// }
//
// }
|
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.exception.LoggerInstantiationException;
import com.github.vbauer.herald.exception.MissedLogFactoryException;
import com.github.vbauer.herald.logger.LogFactory;
import com.github.vbauer.herald.util.ReflectionUtils;
import com.github.vbauer.herald.util.ServiceLoaderUtils;
import java.lang.reflect.Field;
import java.util.Collection;
|
if (required) {
ReflectionUtils.handleReflectionException(ex);
}
} finally {
ReflectionUtils.setAccessible(field, isAccessible);
}
}
private static Object createLogger(
final Class<?> beanClass, final Class<?> loggerClass, final String loggerName
) {
// Find corresponding logger factory.
final LogFactory logFactory =
LogFactoryDetector.findCompatible(LOG_FACTORIES, loggerClass);
if (logFactory == null) {
throw new MissedLogFactoryException(loggerClass);
}
// Create logger.
final Object logger = !loggerName.isEmpty()
? logFactory.createLogger(loggerName) : logFactory.createLogger(beanClass);
if (logger == null) {
throw new LoggerInstantiationException(logFactory);
}
return logger;
}
private static Collection<LogFactory> loadLogFactories() {
|
// Path: src/main/java/com/github/vbauer/herald/exception/LoggerInstantiationException.java
// @SuppressWarnings("serial")
// public class LoggerInstantiationException extends HeraldException {
//
// private final LogFactory loggerFactory;
//
//
// public LoggerInstantiationException(final LogFactory loggerFactory) {
// this.loggerFactory = loggerFactory;
// }
//
//
// /**
// * Get logger factory, see {@link LogFactory}.
// *
// * @return logger factory
// */
// public LogFactory getLoggerFactory() {
// return loggerFactory;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getMessage() {
// return String.format("Can't create logger using factory %s", getLoggerFactory());
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/exception/MissedLogFactoryException.java
// @SuppressWarnings("serial")
// public class MissedLogFactoryException extends HeraldException {
//
// private final Class<?> loggerClass;
//
//
// public MissedLogFactoryException(final Class<?> loggerClass) {
// this.loggerClass = loggerClass;
// }
//
//
// /**
// * Get logger class.
// *
// * @return logger class
// */
// public Class<?> getLoggerClass() {
// return loggerClass;
// }
//
//
// /**
// * {@inheritDoc}
// */
// @Override
// public String getMessage() {
// return String.format("Can not find log factory for logger %s", getLoggerClass());
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ReflectionUtils.java
// public final class ReflectionUtils {
//
// private ReflectionUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static boolean isAssignableFrom(final String className, final Class<?> from) {
// try {
// final Class<?> clazz = Class.forName(className);
// return clazz.isAssignableFrom(from);
// } catch (final Throwable ex) {
// return false;
// }
// }
//
// @SuppressWarnings("unchecked")
// public static <I, O> O invokeStatic(final String className, final String methodName, final I argument) {
// try {
// final Class<?> clazz = Class.forName(className);
// final Class<?> argumentClass = argument.getClass();
//
// final Method method = clazz.getDeclaredMethod(methodName, argumentClass);
// return (O) method.invoke(null, argument);
// } catch (final Exception ex) {
// return handleReflectionException(ex);
// }
// }
//
// public static <T> T handleReflectionException(final Throwable ex) {
// if (ex instanceof RuntimeException) {
// throw (RuntimeException) ex;
// } else if (ex instanceof Error) {
// throw (Error) ex;
// }
// throw new RuntimeException(ex);
// }
//
// public static <T extends Annotation> T findAnnotation(
// final Class<T> annotationClass, final Class<?> beanClass, final Field field
// ) {
// final T fieldAnnotation = field.getAnnotation(annotationClass);
// return fieldAnnotation == null ? beanClass.getAnnotation(annotationClass) : fieldAnnotation;
// }
//
// public static boolean setAccessible(final AccessibleObject object, final boolean accessible) {
// try {
// object.setAccessible(accessible);
// return true;
// } catch (final Throwable ignored) {
// // Ignored.
// return false;
// }
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/util/ServiceLoaderUtils.java
// public final class ServiceLoaderUtils {
//
// private ServiceLoaderUtils() {
// throw new UnsupportedOperationException();
// }
//
//
// public static <T> Collection<T> load(final Class<T> beanClass) {
// final ServiceLoader<T> serviceLoader = ServiceLoader.load(beanClass);
// final Iterator<T> iterator = serviceLoader.iterator();
//
// final List<T> result = new ArrayList<>();
// while (iterator.hasNext()) {
// result.add(iterator.next());
// }
// return result;
// }
//
// }
// Path: src/main/java/com/github/vbauer/herald/injector/LoggerInjector.java
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.exception.LoggerInstantiationException;
import com.github.vbauer.herald.exception.MissedLogFactoryException;
import com.github.vbauer.herald.logger.LogFactory;
import com.github.vbauer.herald.util.ReflectionUtils;
import com.github.vbauer.herald.util.ServiceLoaderUtils;
import java.lang.reflect.Field;
import java.util.Collection;
if (required) {
ReflectionUtils.handleReflectionException(ex);
}
} finally {
ReflectionUtils.setAccessible(field, isAccessible);
}
}
private static Object createLogger(
final Class<?> beanClass, final Class<?> loggerClass, final String loggerName
) {
// Find corresponding logger factory.
final LogFactory logFactory =
LogFactoryDetector.findCompatible(LOG_FACTORIES, loggerClass);
if (logFactory == null) {
throw new MissedLogFactoryException(loggerClass);
}
// Create logger.
final Object logger = !loggerName.isEmpty()
? logFactory.createLogger(loggerName) : logFactory.createLogger(beanClass);
if (logger == null) {
throw new LoggerInstantiationException(logFactory);
}
return logger;
}
private static Collection<LogFactory> loadLogFactories() {
|
return ServiceLoaderUtils.load(LogFactory.class);
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/util/ServiceLoaderUtilsTest.java
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
|
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.logger.LogFactory;
import org.junit.Test;
import java.util.Collection;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.util;
/**
* @author Vladislav Bauer
*/
public class ServiceLoaderUtilsTest extends BasicTest {
private static final int REAL_LOGGERS_COUNT = 11;
private static final int TEST_LOGGERS_COUNT = 1;
private static final int LOGGERS_COUNT = REAL_LOGGERS_COUNT + TEST_LOGGERS_COUNT;
@Test
public void testConstructorContract() throws Exception {
checkUtilConstructorContract(ServiceLoaderUtils.class);
}
@Test
public void testLoad() {
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
// Path: src/test/java/com/github/vbauer/herald/util/ServiceLoaderUtilsTest.java
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.logger.LogFactory;
import org.junit.Test;
import java.util.Collection;
import static org.hamcrest.Matchers.hasSize;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.util;
/**
* @author Vladislav Bauer
*/
public class ServiceLoaderUtilsTest extends BasicTest {
private static final int REAL_LOGGERS_COUNT = 11;
private static final int TEST_LOGGERS_COUNT = 1;
private static final int LOGGERS_COUNT = REAL_LOGGERS_COUNT + TEST_LOGGERS_COUNT;
@Test
public void testConstructorContract() throws Exception {
checkUtilConstructorContract(ServiceLoaderUtils.class);
}
@Test
public void testLoad() {
|
final Collection<LogFactory> factories = ServiceLoaderUtils.load(LogFactory.class);
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
|
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/ClassLogBean.java
// @Log
// @Component
// @SuppressWarnings("all")
// public class ClassLogBean {
//
// public static final int DEF_NOT_LOGGER_VALUE = 5;
//
//
// private static java.util.logging.Logger staticJavaUtilLogger;
//
// private java.util.logging.Logger javaUtilLogger;
//
// private org.apache.commons.logging.Log commonsLoggingLogger;
//
// private ch.qos.logback.classic.Logger logbackLogger;
//
// private org.slf4j.Logger slf4jLogger;
//
// private org.slf4j.ext.XLogger slf4jExtLogger;
//
// private org.apache.log4j.Logger log4jLogger;
//
// private org.apache.logging.log4j.Logger log4j2Logger;
//
// private org.jboss.logging.Logger jbossLogger;
//
// private org.productivity.java.syslog4j.SyslogIF syslog4jLogger;
//
// private org.graylog2.syslog4j.SyslogIF syslog4jGraylogLogger;
//
// private org.fluentd.logger.FluentLogger fluentLogger;
//
// private int notLogger = DEF_NOT_LOGGER_VALUE;
//
//
// public static java.util.logging.Logger getStaticJavaUtilLogger() {
// return staticJavaUtilLogger;
// }
//
// public java.util.logging.Logger getJavaUtilLogger() {
// return javaUtilLogger;
// }
//
// public org.apache.commons.logging.Log getCommonsLoggingLogger() {
// return commonsLoggingLogger;
// }
//
// public ch.qos.logback.classic.Logger getLogbackLogger() {
// return logbackLogger;
// }
//
// public org.slf4j.Logger getSlf4jLogger() {
// return slf4jLogger;
// }
//
// public org.slf4j.ext.XLogger getSlf4jExtLogger() {
// return slf4jExtLogger;
// }
//
// public org.apache.log4j.Logger getLog4jLogger() {
// return log4jLogger;
// }
//
// public org.apache.logging.log4j.Logger getLog4j2Logger() {
// return log4j2Logger;
// }
//
// public org.jboss.logging.Logger getJBossLogger() {
// return jbossLogger;
// }
//
// public org.productivity.java.syslog4j.SyslogIF getSyslog4jLogger() {
// return syslog4jLogger;
// }
//
// public org.graylog2.syslog4j.SyslogIF getSyslog4jGraylogLogger() {
// return syslog4jGraylogLogger;
// }
//
// public org.fluentd.logger.FluentLogger getFluentLogger() {
// return fluentLogger;
// }
//
// public int getNotLogger() {
// return notLogger;
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.bean.ClassLogBean;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.logger.checker;
/**
* @author Vladislav Bauer
*/
public final class ClassLogBeanChecker {
private ClassLogBeanChecker() {
throw new UnsupportedOperationException();
}
|
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/ClassLogBean.java
// @Log
// @Component
// @SuppressWarnings("all")
// public class ClassLogBean {
//
// public static final int DEF_NOT_LOGGER_VALUE = 5;
//
//
// private static java.util.logging.Logger staticJavaUtilLogger;
//
// private java.util.logging.Logger javaUtilLogger;
//
// private org.apache.commons.logging.Log commonsLoggingLogger;
//
// private ch.qos.logback.classic.Logger logbackLogger;
//
// private org.slf4j.Logger slf4jLogger;
//
// private org.slf4j.ext.XLogger slf4jExtLogger;
//
// private org.apache.log4j.Logger log4jLogger;
//
// private org.apache.logging.log4j.Logger log4j2Logger;
//
// private org.jboss.logging.Logger jbossLogger;
//
// private org.productivity.java.syslog4j.SyslogIF syslog4jLogger;
//
// private org.graylog2.syslog4j.SyslogIF syslog4jGraylogLogger;
//
// private org.fluentd.logger.FluentLogger fluentLogger;
//
// private int notLogger = DEF_NOT_LOGGER_VALUE;
//
//
// public static java.util.logging.Logger getStaticJavaUtilLogger() {
// return staticJavaUtilLogger;
// }
//
// public java.util.logging.Logger getJavaUtilLogger() {
// return javaUtilLogger;
// }
//
// public org.apache.commons.logging.Log getCommonsLoggingLogger() {
// return commonsLoggingLogger;
// }
//
// public ch.qos.logback.classic.Logger getLogbackLogger() {
// return logbackLogger;
// }
//
// public org.slf4j.Logger getSlf4jLogger() {
// return slf4jLogger;
// }
//
// public org.slf4j.ext.XLogger getSlf4jExtLogger() {
// return slf4jExtLogger;
// }
//
// public org.apache.log4j.Logger getLog4jLogger() {
// return log4jLogger;
// }
//
// public org.apache.logging.log4j.Logger getLog4j2Logger() {
// return log4j2Logger;
// }
//
// public org.jboss.logging.Logger getJBossLogger() {
// return jbossLogger;
// }
//
// public org.productivity.java.syslog4j.SyslogIF getSyslog4jLogger() {
// return syslog4jLogger;
// }
//
// public org.graylog2.syslog4j.SyslogIF getSyslog4jGraylogLogger() {
// return syslog4jGraylogLogger;
// }
//
// public org.fluentd.logger.FluentLogger getFluentLogger() {
// return fluentLogger;
// }
//
// public int getNotLogger() {
// return notLogger;
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/logger/checker/ClassLogBeanChecker.java
import com.github.vbauer.herald.ext.spring.bean.ClassLogBean;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.logger.checker;
/**
* @author Vladislav Bauer
*/
public final class ClassLogBeanChecker {
private ClassLogBeanChecker() {
throw new UnsupportedOperationException();
}
|
public static void check(final ClassLogBean bean) {
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/SpringBootTest.java
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringBootTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// @ImportAutoConfiguration(LogAutoConfiguration.class)
// public class SpringBootTestContext {
// }
|
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.github.vbauer.herald.ext.spring.context.SpringBootTestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
@ContextConfiguration(classes = SpringBootTestContext.class)
@RunWith(SpringJUnit4ClassRunner.class)
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringBootTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// @ImportAutoConfiguration(LogAutoConfiguration.class)
// public class SpringBootTestContext {
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/SpringBootTest.java
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.github.vbauer.herald.ext.spring.context.SpringBootTestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
@ContextConfiguration(classes = SpringBootTestContext.class)
@RunWith(SpringJUnit4ClassRunner.class)
|
public class SpringBootTest extends BasicTest {
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/SpringBootTest.java
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringBootTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// @ImportAutoConfiguration(LogAutoConfiguration.class)
// public class SpringBootTestContext {
// }
|
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.github.vbauer.herald.ext.spring.context.SpringBootTestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
@ContextConfiguration(classes = SpringBootTestContext.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class SpringBootTest extends BasicTest {
@Autowired
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringBootTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// @ImportAutoConfiguration(LogAutoConfiguration.class)
// public class SpringBootTestContext {
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/SpringBootTest.java
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.github.vbauer.herald.ext.spring.context.SpringBootTestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
@ContextConfiguration(classes = SpringBootTestContext.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class SpringBootTest extends BasicTest {
@Autowired
|
private CheckerBean checkerBean;
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/context/SpringTestContext.java
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
|
package com.github.vbauer.herald.ext.spring.context;
/**
* @author Vladislav Bauer
*/
@Configuration
@ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
public class SpringTestContext {
@Bean
|
// Path: src/main/java/com/github/vbauer/herald/ext/spring/LogBeanPostProcessor.java
// public class LogBeanPostProcessor implements BeanPostProcessor {
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessBeforeInitialization(final Object bean, final String beanName) {
// return LoggerInjector.inject(bean);
// }
//
// /**
// * {@inheritDoc}
// */
// @Override
// public Object postProcessAfterInitialization(final Object bean, final String beanName) {
// return bean;
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringTestContext.java
import com.github.vbauer.herald.ext.spring.LogBeanPostProcessor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
package com.github.vbauer.herald.ext.spring.context;
/**
* @author Vladislav Bauer
*/
@Configuration
@ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
public class SpringTestContext {
@Bean
|
public LogBeanPostProcessor logBeanPostProcessor() {
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/guice/LogModuleTest.java
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
|
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.Test;
|
package com.github.vbauer.herald.ext.guice;
/**
* @author Vladislav Bauer
*/
public class LogModuleTest extends BasicTest {
@Test
public void testBeans() {
final Injector injector = Guice.createInjector(new LogModule());
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/guice/LogModuleTest.java
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.google.inject.Guice;
import com.google.inject.Injector;
import org.junit.Test;
package com.github.vbauer.herald.ext.guice;
/**
* @author Vladislav Bauer
*/
public class LogModuleTest extends BasicTest {
@Test
public void testBeans() {
final Injector injector = Guice.createInjector(new LogModule());
|
final CheckerBean bean = injector.getInstance(CheckerBean.class);
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/SpringTest.java
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// public class SpringTestContext {
//
// @Bean
// public LogBeanPostProcessor logBeanPostProcessor() {
// return new LogBeanPostProcessor();
// }
//
// }
|
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.github.vbauer.herald.ext.spring.context.SpringTestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
@ContextConfiguration(classes = SpringTestContext.class)
@RunWith(SpringJUnit4ClassRunner.class)
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// public class SpringTestContext {
//
// @Bean
// public LogBeanPostProcessor logBeanPostProcessor() {
// return new LogBeanPostProcessor();
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/SpringTest.java
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.github.vbauer.herald.ext.spring.context.SpringTestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
@ContextConfiguration(classes = SpringTestContext.class)
@RunWith(SpringJUnit4ClassRunner.class)
|
public class SpringTest extends BasicTest {
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/SpringTest.java
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// public class SpringTestContext {
//
// @Bean
// public LogBeanPostProcessor logBeanPostProcessor() {
// return new LogBeanPostProcessor();
// }
//
// }
|
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.github.vbauer.herald.ext.spring.context.SpringTestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
@ContextConfiguration(classes = SpringTestContext.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class SpringTest extends BasicTest {
@Autowired
|
// Path: src/test/java/com/github/vbauer/herald/core/BasicTest.java
// @RunWith(BlockJUnit4ClassRunner.class)
// public abstract class BasicTest {
//
// protected final void checkUtilConstructorContract(final Class<?> utilClass) {
// PrivateConstructorChecker
// .forClass(utilClass)
// .expectedTypeOfException(UnsupportedOperationException.class)
// .check();
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/CheckerBean.java
// @Component
// public class CheckerBean {
//
// @Inject
// private LogBeanPostProcessor logBeanPostProcessor;
//
// private final ClassLogBean classLogBean;
// private final LogBean logBean;
// private final NamedLogBean namedLogBean;
//
//
// @Inject
// public CheckerBean(
// final ClassLogBean classLogBean,
// final LogBean logBean,
// final NamedLogBean namedLogBean
// ) {
// this.classLogBean = classLogBean;
// this.logBean = logBean;
// this.namedLogBean = namedLogBean;
// }
//
//
// public void checkBeans() {
// checkBeans(classLogBean, logBean, namedLogBean);
// }
//
// public void checkPostProcessor() {
// checkBeans(
// checkPostProcessor(new ClassLogBean()),
// checkPostProcessor(new LogBean()),
// checkPostProcessor(new NamedLogBean())
// );
// }
//
//
// private void checkBeans(
// final ClassLogBean classLogBean, final LogBean logBean, final NamedLogBean namedLogBean
// ) {
// ClassLogBeanChecker.check(classLogBean);
// LogBeanChecker.check(logBean);
// NamedLogBeanChecker.check(namedLogBean);
// }
//
// @SuppressWarnings("unchecked")
// private <T> T checkPostProcessor(final T bean) {
// final T before = (T) logBeanPostProcessor.postProcessBeforeInitialization(bean, null);
// assertThat(before, equalTo(bean));
//
// final T after = (T) logBeanPostProcessor.postProcessAfterInitialization(bean, null);
// assertThat(after, equalTo(bean));
//
// return bean;
// }
//
// }
//
// Path: src/test/java/com/github/vbauer/herald/ext/spring/context/SpringTestContext.java
// @Configuration
// @ComponentScan(basePackages = "com.github.vbauer.herald.ext.spring.bean")
// public class SpringTestContext {
//
// @Bean
// public LogBeanPostProcessor logBeanPostProcessor() {
// return new LogBeanPostProcessor();
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/SpringTest.java
import com.github.vbauer.herald.core.BasicTest;
import com.github.vbauer.herald.ext.spring.bean.CheckerBean;
import com.github.vbauer.herald.ext.spring.context.SpringTestContext;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
package com.github.vbauer.herald.ext.spring;
/**
* @author Vladislav Bauer
*/
@ContextConfiguration(classes = SpringTestContext.class)
@RunWith(SpringJUnit4ClassRunner.class)
public class SpringTest extends BasicTest {
@Autowired
|
private CheckerBean checkerBean;
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
|
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/LogBean.java
// @Component
// @SuppressWarnings("all")
// public class LogBean {
//
// @Log
// private static java.util.logging.Logger staticJavaUtilLogger;
//
// @Log
// private java.util.logging.Logger javaUtilLogger;
//
// @Log
// private org.apache.commons.logging.Log commonsLoggingLogger;
//
// @Log
// private ch.qos.logback.classic.Logger logbackLogger;
//
// @Log
// private org.slf4j.Logger slf4jLogger;
//
// @Log
// private org.slf4j.ext.XLogger slf4jExtLogger;
//
// @Log
// private org.apache.log4j.Logger log4jLogger;
//
// @Log
// private org.apache.logging.log4j.Logger log4j2Logger;
//
// @Log
// private org.jboss.logging.Logger jbossLogger;
//
// @Log
// private org.productivity.java.syslog4j.SyslogIF syslog4jLogger;
//
// @Log
// private org.graylog2.syslog4j.SyslogIF syslog4jGraylogLogger;
//
// @Log
// private org.fluentd.logger.FluentLogger fluentLogger;
//
//
// public static java.util.logging.Logger getStaticJavaUtilLogger() {
// return staticJavaUtilLogger;
// }
//
// public java.util.logging.Logger getJavaUtilLogger() {
// return javaUtilLogger;
// }
//
// public org.apache.commons.logging.Log getCommonsLoggingLogger() {
// return commonsLoggingLogger;
// }
//
// public ch.qos.logback.classic.Logger getLogbackLogger() {
// return logbackLogger;
// }
//
// public org.slf4j.Logger getSlf4jLogger() {
// return slf4jLogger;
// }
//
// public org.slf4j.ext.XLogger getSlf4jExtLogger() {
// return slf4jExtLogger;
// }
//
// public org.apache.log4j.Logger getLog4jLogger() {
// return log4jLogger;
// }
//
// public org.apache.logging.log4j.Logger getLog4j2Logger() {
// return log4j2Logger;
// }
//
// public org.jboss.logging.Logger getJBossLogger() {
// return jbossLogger;
// }
//
// public org.productivity.java.syslog4j.SyslogIF getSyslog4jLogger() {
// return syslog4jLogger;
// }
//
// public org.graylog2.syslog4j.SyslogIF getSyslog4jGraylogLogger() {
// return syslog4jGraylogLogger;
// }
//
// public org.fluentd.logger.FluentLogger getFluentLogger() {
// return fluentLogger;
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.bean.LogBean;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.logger.checker;
/**
* @author Vladislav Bauer
*/
public final class LogBeanChecker {
private LogBeanChecker() {
throw new UnsupportedOperationException();
}
|
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/LogBean.java
// @Component
// @SuppressWarnings("all")
// public class LogBean {
//
// @Log
// private static java.util.logging.Logger staticJavaUtilLogger;
//
// @Log
// private java.util.logging.Logger javaUtilLogger;
//
// @Log
// private org.apache.commons.logging.Log commonsLoggingLogger;
//
// @Log
// private ch.qos.logback.classic.Logger logbackLogger;
//
// @Log
// private org.slf4j.Logger slf4jLogger;
//
// @Log
// private org.slf4j.ext.XLogger slf4jExtLogger;
//
// @Log
// private org.apache.log4j.Logger log4jLogger;
//
// @Log
// private org.apache.logging.log4j.Logger log4j2Logger;
//
// @Log
// private org.jboss.logging.Logger jbossLogger;
//
// @Log
// private org.productivity.java.syslog4j.SyslogIF syslog4jLogger;
//
// @Log
// private org.graylog2.syslog4j.SyslogIF syslog4jGraylogLogger;
//
// @Log
// private org.fluentd.logger.FluentLogger fluentLogger;
//
//
// public static java.util.logging.Logger getStaticJavaUtilLogger() {
// return staticJavaUtilLogger;
// }
//
// public java.util.logging.Logger getJavaUtilLogger() {
// return javaUtilLogger;
// }
//
// public org.apache.commons.logging.Log getCommonsLoggingLogger() {
// return commonsLoggingLogger;
// }
//
// public ch.qos.logback.classic.Logger getLogbackLogger() {
// return logbackLogger;
// }
//
// public org.slf4j.Logger getSlf4jLogger() {
// return slf4jLogger;
// }
//
// public org.slf4j.ext.XLogger getSlf4jExtLogger() {
// return slf4jExtLogger;
// }
//
// public org.apache.log4j.Logger getLog4jLogger() {
// return log4jLogger;
// }
//
// public org.apache.logging.log4j.Logger getLog4j2Logger() {
// return log4j2Logger;
// }
//
// public org.jboss.logging.Logger getJBossLogger() {
// return jbossLogger;
// }
//
// public org.productivity.java.syslog4j.SyslogIF getSyslog4jLogger() {
// return syslog4jLogger;
// }
//
// public org.graylog2.syslog4j.SyslogIF getSyslog4jGraylogLogger() {
// return syslog4jGraylogLogger;
// }
//
// public org.fluentd.logger.FluentLogger getFluentLogger() {
// return fluentLogger;
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/logger/checker/LogBeanChecker.java
import com.github.vbauer.herald.ext.spring.bean.LogBean;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.logger.checker;
/**
* @author Vladislav Bauer
*/
public final class LogBeanChecker {
private LogBeanChecker() {
throw new UnsupportedOperationException();
}
|
public static void check(final LogBean bean) {
|
vbauer/herald
|
src/main/java/com/github/vbauer/herald/exception/LoggerInstantiationException.java
|
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
|
import com.github.vbauer.herald.logger.LogFactory;
|
package com.github.vbauer.herald.exception;
/**
* An exception class for situations when we do not have possibility to create logger.
* Some problems were occurred during logger creation.
*
* @author Vladislav Bauer
*/
@SuppressWarnings("serial")
public class LoggerInstantiationException extends HeraldException {
|
// Path: src/main/java/com/github/vbauer/herald/logger/LogFactory.java
// public interface LogFactory {
//
// /**
// * Check if logger class is compatible with the log factory.
// *
// * @param loggerClass logger class
// * @return true if compatible and false - otherwise
// */
// boolean isCompatible(Class<?> loggerClass);
//
// /**
// * Create logger with the given name (as configuration parameter).
// *
// * @param name logger name
// * @return logger instance
// */
// Object createLogger(String name);
//
// /**
// * Create logger with the given class (as configuration parameter).
// *
// * @param clazz class
// * @return logger instance
// */
// Object createLogger(Class<?> clazz);
//
// }
// Path: src/main/java/com/github/vbauer/herald/exception/LoggerInstantiationException.java
import com.github.vbauer.herald.logger.LogFactory;
package com.github.vbauer.herald.exception;
/**
* An exception class for situations when we do not have possibility to create logger.
* Some problems were occurred during logger creation.
*
* @author Vladislav Bauer
*/
@SuppressWarnings("serial")
public class LoggerInstantiationException extends HeraldException {
|
private final LogFactory loggerFactory;
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/ext/spring/bean/NullLoggerBean.java
|
// Path: src/test/java/com/github/vbauer/herald/logger/empty/NullLogger.java
// @SuppressWarnings("all")
// public class NullLogger {
//
// public static NullLogger getLogger(final Class<?> clazz) {
// return null;
// }
//
// public static NullLogger getLogger(final String name) {
// return null;
// }
//
// }
|
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.logger.empty.NullLogger;
|
package com.github.vbauer.herald.ext.spring.bean;
/**
* @author Vladislav Bauer
*/
public class NullLoggerBean {
@Log
|
// Path: src/test/java/com/github/vbauer/herald/logger/empty/NullLogger.java
// @SuppressWarnings("all")
// public class NullLogger {
//
// public static NullLogger getLogger(final Class<?> clazz) {
// return null;
// }
//
// public static NullLogger getLogger(final String name) {
// return null;
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/NullLoggerBean.java
import com.github.vbauer.herald.annotation.Log;
import com.github.vbauer.herald.logger.empty.NullLogger;
package com.github.vbauer.herald.ext.spring.bean;
/**
* @author Vladislav Bauer
*/
public class NullLoggerBean {
@Log
|
private NullLogger logger;
|
vbauer/herald
|
src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
|
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/NamedLogBean.java
// @Component
// @SuppressWarnings("all")
// public class NamedLogBean {
//
// private static final String LOGGER_NAME = "logger";
//
//
// @Log(LOGGER_NAME)
// private static java.util.logging.Logger staticJavaUtilLogger;
//
// @Log(LOGGER_NAME)
// private java.util.logging.Logger javaUtilLogger;
//
// @Log(LOGGER_NAME)
// private org.apache.commons.logging.Log commonsLoggingLogger;
//
// @Log(LOGGER_NAME)
// private ch.qos.logback.classic.Logger logbackLogger;
//
// @Log(LOGGER_NAME)
// private org.slf4j.Logger slf4jLogger;
//
// @Log(LOGGER_NAME)
// private org.apache.log4j.Logger log4jLogger;
//
// @Log(LOGGER_NAME)
// private org.slf4j.ext.XLogger slf4jExtLogger;
//
// @Log(LOGGER_NAME)
// private org.apache.logging.log4j.Logger log4j2Logger;
//
// @Log(LOGGER_NAME)
// private org.jboss.logging.Logger jbossLogger;
//
// @Log(Syslog4jLogFactory.DEFAULT_PROTOCOL)
// private org.productivity.java.syslog4j.SyslogIF syslog4jLogger;
//
// @Log(Syslog4jGraylogLogFactory.DEFAULT_PROTOCOL)
// private org.graylog2.syslog4j.SyslogIF syslog4jGraylogLogger;
//
// @Log(LOGGER_NAME)
// private org.fluentd.logger.FluentLogger fluentLogger;
//
//
// public static java.util.logging.Logger getStaticJavaUtilLogger() {
// return staticJavaUtilLogger;
// }
//
// public java.util.logging.Logger getJavaUtilLogger() {
// return javaUtilLogger;
// }
//
// public org.apache.commons.logging.Log getCommonsLoggingLogger() {
// return commonsLoggingLogger;
// }
//
// public ch.qos.logback.classic.Logger getLogbackLogger() {
// return logbackLogger;
// }
//
// public org.slf4j.Logger getSlf4jLogger() {
// return slf4jLogger;
// }
//
// public org.slf4j.ext.XLogger getSlf4jExtLogger() {
// return slf4jExtLogger;
// }
//
// public org.apache.log4j.Logger getLog4jLogger() {
// return log4jLogger;
// }
//
// public org.apache.logging.log4j.Logger getLog4j2Logger() {
// return log4j2Logger;
// }
//
// public org.jboss.logging.Logger getJBossLogger() {
// return jbossLogger;
// }
//
// public org.productivity.java.syslog4j.SyslogIF getSyslog4jLogger() {
// return syslog4jLogger;
// }
//
// public org.graylog2.syslog4j.SyslogIF getSyslog4jGraylogLogger() {
// return syslog4jGraylogLogger;
// }
//
// public org.fluentd.logger.FluentLogger getFluentLogger() {
// return fluentLogger;
// }
//
// }
|
import com.github.vbauer.herald.ext.spring.bean.NamedLogBean;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
|
package com.github.vbauer.herald.logger.checker;
/**
* @author Vladislav Bauer
*/
public final class NamedLogBeanChecker {
private NamedLogBeanChecker() {
throw new UnsupportedOperationException();
}
|
// Path: src/test/java/com/github/vbauer/herald/ext/spring/bean/NamedLogBean.java
// @Component
// @SuppressWarnings("all")
// public class NamedLogBean {
//
// private static final String LOGGER_NAME = "logger";
//
//
// @Log(LOGGER_NAME)
// private static java.util.logging.Logger staticJavaUtilLogger;
//
// @Log(LOGGER_NAME)
// private java.util.logging.Logger javaUtilLogger;
//
// @Log(LOGGER_NAME)
// private org.apache.commons.logging.Log commonsLoggingLogger;
//
// @Log(LOGGER_NAME)
// private ch.qos.logback.classic.Logger logbackLogger;
//
// @Log(LOGGER_NAME)
// private org.slf4j.Logger slf4jLogger;
//
// @Log(LOGGER_NAME)
// private org.apache.log4j.Logger log4jLogger;
//
// @Log(LOGGER_NAME)
// private org.slf4j.ext.XLogger slf4jExtLogger;
//
// @Log(LOGGER_NAME)
// private org.apache.logging.log4j.Logger log4j2Logger;
//
// @Log(LOGGER_NAME)
// private org.jboss.logging.Logger jbossLogger;
//
// @Log(Syslog4jLogFactory.DEFAULT_PROTOCOL)
// private org.productivity.java.syslog4j.SyslogIF syslog4jLogger;
//
// @Log(Syslog4jGraylogLogFactory.DEFAULT_PROTOCOL)
// private org.graylog2.syslog4j.SyslogIF syslog4jGraylogLogger;
//
// @Log(LOGGER_NAME)
// private org.fluentd.logger.FluentLogger fluentLogger;
//
//
// public static java.util.logging.Logger getStaticJavaUtilLogger() {
// return staticJavaUtilLogger;
// }
//
// public java.util.logging.Logger getJavaUtilLogger() {
// return javaUtilLogger;
// }
//
// public org.apache.commons.logging.Log getCommonsLoggingLogger() {
// return commonsLoggingLogger;
// }
//
// public ch.qos.logback.classic.Logger getLogbackLogger() {
// return logbackLogger;
// }
//
// public org.slf4j.Logger getSlf4jLogger() {
// return slf4jLogger;
// }
//
// public org.slf4j.ext.XLogger getSlf4jExtLogger() {
// return slf4jExtLogger;
// }
//
// public org.apache.log4j.Logger getLog4jLogger() {
// return log4jLogger;
// }
//
// public org.apache.logging.log4j.Logger getLog4j2Logger() {
// return log4j2Logger;
// }
//
// public org.jboss.logging.Logger getJBossLogger() {
// return jbossLogger;
// }
//
// public org.productivity.java.syslog4j.SyslogIF getSyslog4jLogger() {
// return syslog4jLogger;
// }
//
// public org.graylog2.syslog4j.SyslogIF getSyslog4jGraylogLogger() {
// return syslog4jGraylogLogger;
// }
//
// public org.fluentd.logger.FluentLogger getFluentLogger() {
// return fluentLogger;
// }
//
// }
// Path: src/test/java/com/github/vbauer/herald/logger/checker/NamedLogBeanChecker.java
import com.github.vbauer.herald.ext.spring.bean.NamedLogBean;
import static org.hamcrest.Matchers.notNullValue;
import static org.junit.Assert.assertThat;
package com.github.vbauer.herald.logger.checker;
/**
* @author Vladislav Bauer
*/
public final class NamedLogBeanChecker {
private NamedLogBeanChecker() {
throw new UnsupportedOperationException();
}
|
public static void check(final NamedLogBean bean) {
|
jimmyfm/krut
|
src/main/java/net/sourceforge/krut/ui/KrutSettings.java
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
|
import java.awt.Rectangle;
import net.sourceforge.krut.Settings;
|
package net.sourceforge.krut.ui;
/**
* This is a class that is used to display many user interface functions. In
* earlier versions of the program, most of the user interface functions were
* handled through free-floating windows. These windows were then collected
* inside the GUI created by this class. Because of this, there are both user
* manageable settings for the program handled directly by this class, and also
* several settings handled by other classes, which in turn are displayed
* through this class.
*
* @since 18. december 2006, 22:52
* @author Jonas
*/
public class KrutSettings extends javax.swing.JFrame {
/** If the present KrutSettings window is properly initiated,
* vCMBItem holds the Record Video checkbox from the main
* Krut window Menu. This parameter is used for easy access
* in case the Record Video checkbox from the present
* KrutSetting window is changed.
*/
public javax.swing.JCheckBoxMenuItem vCBMItem;
/** If the present KrutSettings window is properly initiated,
* aCMBItem holds the Record Audio checkbox from the main
* Krut window Menu. This parameter is used for easy access
* in case the Record Audio checkbox from the present
* KrutSetting window is changed.
*/
public javax.swing.JCheckBoxMenuItem aCBMItem;
/** If the present KrutSettings window is properly initiated,
* mCMBItem holds the Record Mouse Pointer checkbox from the main
* Krut window Menu. This parameter is used for easy access
* in case the Record Mouse Pointer checkbox from the present
* KrutSetting window is changed.
*/
public javax.swing.JCheckBoxMenuItem mCBMItem;
/** How often we sample for the mouse position in ms.
* The sampling is done in startMouseTimer. */
public int mouseSampleDelay = 100;
/** True if the setting window is initiated, false if not
*/
public boolean isInited = false;
/** Mouse postition in stored here when CTRL is pressed */
private java.awt.Point mouseStartPos;
/** This is used to store the current mouse position
* in startMouseTimer. */
private java.awt.Point mousePos;
/** This is a flag to keep track of whether the capture size
* is being changed. */
private boolean ctrlDown = false;
/** This is a flag to keep track of whether the capture size
* is being changed. */
private boolean capButtonPressed = false;
/** Times used to track the mouse position for both
* the mouse position window, and the capture size
* window */
public javax.swing.Timer mouseTimer;
/** Creates new form KrutSettings */
public KrutSettings(int startFps, int startEncQuality,
boolean startStereo, boolean startSixteen, int startFrequency) {
initComponents();
soundQuery1.init(startFrequency, startStereo, startSixteen);
qualitySlider1.init(startEncQuality);
fPSQuery1.init(startFps);
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
// Path: src/main/java/net/sourceforge/krut/ui/KrutSettings.java
import java.awt.Rectangle;
import net.sourceforge.krut.Settings;
package net.sourceforge.krut.ui;
/**
* This is a class that is used to display many user interface functions. In
* earlier versions of the program, most of the user interface functions were
* handled through free-floating windows. These windows were then collected
* inside the GUI created by this class. Because of this, there are both user
* manageable settings for the program handled directly by this class, and also
* several settings handled by other classes, which in turn are displayed
* through this class.
*
* @since 18. december 2006, 22:52
* @author Jonas
*/
public class KrutSettings extends javax.swing.JFrame {
/** If the present KrutSettings window is properly initiated,
* vCMBItem holds the Record Video checkbox from the main
* Krut window Menu. This parameter is used for easy access
* in case the Record Video checkbox from the present
* KrutSetting window is changed.
*/
public javax.swing.JCheckBoxMenuItem vCBMItem;
/** If the present KrutSettings window is properly initiated,
* aCMBItem holds the Record Audio checkbox from the main
* Krut window Menu. This parameter is used for easy access
* in case the Record Audio checkbox from the present
* KrutSetting window is changed.
*/
public javax.swing.JCheckBoxMenuItem aCBMItem;
/** If the present KrutSettings window is properly initiated,
* mCMBItem holds the Record Mouse Pointer checkbox from the main
* Krut window Menu. This parameter is used for easy access
* in case the Record Mouse Pointer checkbox from the present
* KrutSetting window is changed.
*/
public javax.swing.JCheckBoxMenuItem mCBMItem;
/** How often we sample for the mouse position in ms.
* The sampling is done in startMouseTimer. */
public int mouseSampleDelay = 100;
/** True if the setting window is initiated, false if not
*/
public boolean isInited = false;
/** Mouse postition in stored here when CTRL is pressed */
private java.awt.Point mouseStartPos;
/** This is used to store the current mouse position
* in startMouseTimer. */
private java.awt.Point mousePos;
/** This is a flag to keep track of whether the capture size
* is being changed. */
private boolean ctrlDown = false;
/** This is a flag to keep track of whether the capture size
* is being changed. */
private boolean capButtonPressed = false;
/** Times used to track the mouse position for both
* the mouse position window, and the capture size
* window */
public javax.swing.Timer mouseTimer;
/** Creates new form KrutSettings */
public KrutSettings(int startFps, int startEncQuality,
boolean startStereo, boolean startSixteen, int startFrequency) {
initComponents();
soundQuery1.init(startFrequency, startStereo, startSixteen);
qualitySlider1.init(startEncQuality);
fPSQuery1.init(startFps);
|
Rectangle capRect = Settings.getCaptureRect();
|
jimmyfm/krut
|
src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
//
// public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// return new JPEGImageEncoder(jpgBytes);
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
//
// private float encQuality;
// private boolean b;
//
// public void setQuality(float encQuality, boolean b) {
// this.encQuality = encQuality;
// this.b = b;
// }
//
// public float getEncQuality() {
// return this.encQuality;
// }
//
// public boolean getB() {
// return this.b;
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
//
// private final OutputStream out;
// private JPEGEncodeParam JPEGEncodeParam;
//
// public JPEGImageEncoder(OutputStream out) {
// this.out = out;
// }
//
// public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// return new JPEGEncodeParam();
// }
//
// public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// this.JPEGEncodeParam = JPEGEncodeParam;
// }
//
// public void encode(BufferedImage image) {
// try {
// ImageIO.write(image, "jpeg", this.out);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// return JPEGEncodeParam;
// }
// }
|
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
|
private BufferedOutputStream fileBuffer;
private DataOutputStream jpgBytes;
/** Used directly as output file, this file is used to save
* frames into after recording is finished, in the run() method. */
private File dumpFile;
/** Used in the run() method to keep capture in sync.
* syncTime can be set needs to be set in the setSyncTime() method.
* This must be done before recording is started. */
private double syncTime;
/** Used in the run() method to keep capture in sync. */
private long currentTime;
/** Variables used by many methods */
/** myRuntime is used to check available memory. */
private Runtime myRuntime;
/** The robot used for screen caputure. */
private Robot robot;
/** The BufferedImage used to store captured frames. */
private BufferedImage image;
private Graphics2D imageGraphics;
/** Used to get the fps value for method startDumper.
* Also used to calculate time in method setFps. */
private int fps;
/** The average size of captured and encoded images.
* Used to get an estimate of the number of frames
* that can be stored in memory. */
private double avgSize = Double.MAX_VALUE;
/** The Encoder, used to
* encode captured images. */
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
//
// public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// return new JPEGImageEncoder(jpgBytes);
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
//
// private float encQuality;
// private boolean b;
//
// public void setQuality(float encQuality, boolean b) {
// this.encQuality = encQuality;
// this.b = b;
// }
//
// public float getEncQuality() {
// return this.encQuality;
// }
//
// public boolean getB() {
// return this.b;
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
//
// private final OutputStream out;
// private JPEGEncodeParam JPEGEncodeParam;
//
// public JPEGImageEncoder(OutputStream out) {
// this.out = out;
// }
//
// public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// return new JPEGEncodeParam();
// }
//
// public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// this.JPEGEncodeParam = JPEGEncodeParam;
// }
//
// public void encode(BufferedImage image) {
// try {
// ImageIO.write(image, "jpeg", this.out);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// return JPEGEncodeParam;
// }
// }
// Path: src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
private BufferedOutputStream fileBuffer;
private DataOutputStream jpgBytes;
/** Used directly as output file, this file is used to save
* frames into after recording is finished, in the run() method. */
private File dumpFile;
/** Used in the run() method to keep capture in sync.
* syncTime can be set needs to be set in the setSyncTime() method.
* This must be done before recording is started. */
private double syncTime;
/** Used in the run() method to keep capture in sync. */
private long currentTime;
/** Variables used by many methods */
/** myRuntime is used to check available memory. */
private Runtime myRuntime;
/** The robot used for screen caputure. */
private Robot robot;
/** The BufferedImage used to store captured frames. */
private BufferedImage image;
private Graphics2D imageGraphics;
/** Used to get the fps value for method startDumper.
* Also used to calculate time in method setFps. */
private int fps;
/** The average size of captured and encoded images.
* Used to get an estimate of the number of frames
* that can be stored in memory. */
private double avgSize = Double.MAX_VALUE;
/** The Encoder, used to
* encode captured images. */
|
private JPEGImageEncoder encoder;
|
jimmyfm/krut
|
src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
//
// public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// return new JPEGImageEncoder(jpgBytes);
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
//
// private float encQuality;
// private boolean b;
//
// public void setQuality(float encQuality, boolean b) {
// this.encQuality = encQuality;
// this.b = b;
// }
//
// public float getEncQuality() {
// return this.encQuality;
// }
//
// public boolean getB() {
// return this.b;
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
//
// private final OutputStream out;
// private JPEGEncodeParam JPEGEncodeParam;
//
// public JPEGImageEncoder(OutputStream out) {
// this.out = out;
// }
//
// public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// return new JPEGEncodeParam();
// }
//
// public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// this.JPEGEncodeParam = JPEGEncodeParam;
// }
//
// public void encode(BufferedImage image) {
// try {
// ImageIO.write(image, "jpeg", this.out);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// return JPEGEncodeParam;
// }
// }
|
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
|
* frames into after recording is finished, in the run() method. */
private File dumpFile;
/** Used in the run() method to keep capture in sync.
* syncTime can be set needs to be set in the setSyncTime() method.
* This must be done before recording is started. */
private double syncTime;
/** Used in the run() method to keep capture in sync. */
private long currentTime;
/** Variables used by many methods */
/** myRuntime is used to check available memory. */
private Runtime myRuntime;
/** The robot used for screen caputure. */
private Robot robot;
/** The BufferedImage used to store captured frames. */
private BufferedImage image;
private Graphics2D imageGraphics;
/** Used to get the fps value for method startDumper.
* Also used to calculate time in method setFps. */
private int fps;
/** The average size of captured and encoded images.
* Used to get an estimate of the number of frames
* that can be stored in memory. */
private double avgSize = Double.MAX_VALUE;
/** The Encoder, used to
* encode captured images. */
private JPEGImageEncoder encoder;
/** The Encoder parameters, used to
* encode captured images. */
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
//
// public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// return new JPEGImageEncoder(jpgBytes);
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
//
// private float encQuality;
// private boolean b;
//
// public void setQuality(float encQuality, boolean b) {
// this.encQuality = encQuality;
// this.b = b;
// }
//
// public float getEncQuality() {
// return this.encQuality;
// }
//
// public boolean getB() {
// return this.b;
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
//
// private final OutputStream out;
// private JPEGEncodeParam JPEGEncodeParam;
//
// public JPEGImageEncoder(OutputStream out) {
// this.out = out;
// }
//
// public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// return new JPEGEncodeParam();
// }
//
// public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// this.JPEGEncodeParam = JPEGEncodeParam;
// }
//
// public void encode(BufferedImage image) {
// try {
// ImageIO.write(image, "jpeg", this.out);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// return JPEGEncodeParam;
// }
// }
// Path: src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
* frames into after recording is finished, in the run() method. */
private File dumpFile;
/** Used in the run() method to keep capture in sync.
* syncTime can be set needs to be set in the setSyncTime() method.
* This must be done before recording is started. */
private double syncTime;
/** Used in the run() method to keep capture in sync. */
private long currentTime;
/** Variables used by many methods */
/** myRuntime is used to check available memory. */
private Runtime myRuntime;
/** The robot used for screen caputure. */
private Robot robot;
/** The BufferedImage used to store captured frames. */
private BufferedImage image;
private Graphics2D imageGraphics;
/** Used to get the fps value for method startDumper.
* Also used to calculate time in method setFps. */
private int fps;
/** The average size of captured and encoded images.
* Used to get an estimate of the number of frames
* that can be stored in memory. */
private double avgSize = Double.MAX_VALUE;
/** The Encoder, used to
* encode captured images. */
private JPEGImageEncoder encoder;
/** The Encoder parameters, used to
* encode captured images. */
|
private JPEGEncodeParam param;
|
jimmyfm/krut
|
src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
//
// public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// return new JPEGImageEncoder(jpgBytes);
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
//
// private float encQuality;
// private boolean b;
//
// public void setQuality(float encQuality, boolean b) {
// this.encQuality = encQuality;
// this.b = b;
// }
//
// public float getEncQuality() {
// return this.encQuality;
// }
//
// public boolean getB() {
// return this.b;
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
//
// private final OutputStream out;
// private JPEGEncodeParam JPEGEncodeParam;
//
// public JPEGImageEncoder(OutputStream out) {
// this.out = out;
// }
//
// public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// return new JPEGEncodeParam();
// }
//
// public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// this.JPEGEncodeParam = JPEGEncodeParam;
// }
//
// public void encode(BufferedImage image) {
// try {
// ImageIO.write(image, "jpeg", this.out);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// return JPEGEncodeParam;
// }
// }
|
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
|
* to later on in the program.
*/
jpgBytes = new DataOutputStream(fileBuffer);
/** Figure out how many integers we can hold in the
* remaining memory. An integer takes 4B, and we will
* have 2 arrays of integers. We don't want to fill the
* entire memory, and we have used a third, or possibly
* even half, already. So we will allocate 2 arrays of
* integers, each using a sixth of the available memory.
* That means we can at the most have
* convert.intValue() / 24
* integers in each array. That also means we can at
* the most have that amount of frames in a film.
*
* As a comparison, an integer array of 1 MB can hold
* 262144 integers, which would be enough for
* 2h25m38s of film at 30 FPS.
*/
maxNOPics = (int) (convert.intValue() / 24);
System.out.println("Memory after filebuffer: " +
(myRuntime.maxMemory() - myRuntime.totalMemory() +
myRuntime.freeMemory()));
/** Init the encoder to store encoded images directly to memory.
* This will be changed later, but is an easy way of getting a
* first frame for the film, since that frame is to be kept in
* memory anyway (see below).
*
* First we take an "average (=random)" image for the method
* encoder.getDefaultJPEGEncodeParam(image) below.
*/
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
//
// public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// return new JPEGImageEncoder(jpgBytes);
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
//
// private float encQuality;
// private boolean b;
//
// public void setQuality(float encQuality, boolean b) {
// this.encQuality = encQuality;
// this.b = b;
// }
//
// public float getEncQuality() {
// return this.encQuality;
// }
//
// public boolean getB() {
// return this.b;
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
//
// private final OutputStream out;
// private JPEGEncodeParam JPEGEncodeParam;
//
// public JPEGImageEncoder(OutputStream out) {
// this.out = out;
// }
//
// public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// return new JPEGEncodeParam();
// }
//
// public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// this.JPEGEncodeParam = JPEGEncodeParam;
// }
//
// public void encode(BufferedImage image) {
// try {
// ImageIO.write(image, "jpeg", this.out);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// return JPEGEncodeParam;
// }
// }
// Path: src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
* to later on in the program.
*/
jpgBytes = new DataOutputStream(fileBuffer);
/** Figure out how many integers we can hold in the
* remaining memory. An integer takes 4B, and we will
* have 2 arrays of integers. We don't want to fill the
* entire memory, and we have used a third, or possibly
* even half, already. So we will allocate 2 arrays of
* integers, each using a sixth of the available memory.
* That means we can at the most have
* convert.intValue() / 24
* integers in each array. That also means we can at
* the most have that amount of frames in a film.
*
* As a comparison, an integer array of 1 MB can hold
* 262144 integers, which would be enough for
* 2h25m38s of film at 30 FPS.
*/
maxNOPics = (int) (convert.intValue() / 24);
System.out.println("Memory after filebuffer: " +
(myRuntime.maxMemory() - myRuntime.totalMemory() +
myRuntime.freeMemory()));
/** Init the encoder to store encoded images directly to memory.
* This will be changed later, but is an easy way of getting a
* first frame for the film, since that frame is to be kept in
* memory anyway (see below).
*
* First we take an "average (=random)" image for the method
* encoder.getDefaultJPEGEncodeParam(image) below.
*/
|
image = robot.createScreenCapture(Settings.getCaptureRect());
|
jimmyfm/krut
|
src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
//
// public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// return new JPEGImageEncoder(jpgBytes);
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
//
// private float encQuality;
// private boolean b;
//
// public void setQuality(float encQuality, boolean b) {
// this.encQuality = encQuality;
// this.b = b;
// }
//
// public float getEncQuality() {
// return this.encQuality;
// }
//
// public boolean getB() {
// return this.b;
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
//
// private final OutputStream out;
// private JPEGEncodeParam JPEGEncodeParam;
//
// public JPEGImageEncoder(OutputStream out) {
// this.out = out;
// }
//
// public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// return new JPEGEncodeParam();
// }
//
// public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// this.JPEGEncodeParam = JPEGEncodeParam;
// }
//
// public void encode(BufferedImage image) {
// try {
// ImageIO.write(image, "jpeg", this.out);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// return JPEGEncodeParam;
// }
// }
|
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
|
jpgBytes = new DataOutputStream(fileBuffer);
/** Figure out how many integers we can hold in the
* remaining memory. An integer takes 4B, and we will
* have 2 arrays of integers. We don't want to fill the
* entire memory, and we have used a third, or possibly
* even half, already. So we will allocate 2 arrays of
* integers, each using a sixth of the available memory.
* That means we can at the most have
* convert.intValue() / 24
* integers in each array. That also means we can at
* the most have that amount of frames in a film.
*
* As a comparison, an integer array of 1 MB can hold
* 262144 integers, which would be enough for
* 2h25m38s of film at 30 FPS.
*/
maxNOPics = (int) (convert.intValue() / 24);
System.out.println("Memory after filebuffer: " +
(myRuntime.maxMemory() - myRuntime.totalMemory() +
myRuntime.freeMemory()));
/** Init the encoder to store encoded images directly to memory.
* This will be changed later, but is an easy way of getting a
* first frame for the film, since that frame is to be kept in
* memory anyway (see below).
*
* First we take an "average (=random)" image for the method
* encoder.getDefaultJPEGEncodeParam(image) below.
*/
image = robot.createScreenCapture(Settings.getCaptureRect());
/** Set the encoder to the OutputStream that stores in memory. */
|
// Path: src/main/java/net/sourceforge/krut/Settings.java
// public class Settings {
//
// static {
// }
//
// private static Preferences prefs = Preferences.userNodeForPackage(Run_KRUT.class);
// public static final String PREF_CAPRECT_X = "PREF_CAPRECT_X";
// public static final String PREF_CAPRECT_Y = "PREF_CAPRECT_Y";
// public static final String PREF_CAPRECT_WIDHT = "PREF_CAPRECT_WIDHT";
// public static final String PREF_CAPRECT_HEIGHT = "PREF_CAPRECT_HEIGHT";
//
// /**
// * The starting value of the capture size.
// * This is used in the createScreenGrabber() method.
// * It is also passed on to the KrutSettings constructur
// * from the init() method.
// */
// public static Rectangle getCaptureRect() {
// return new Rectangle(
// prefs.getInt(PREF_CAPRECT_X, 0),
// prefs.getInt(PREF_CAPRECT_Y, 0),
// prefs.getInt(PREF_CAPRECT_WIDHT, 360),
// prefs.getInt(PREF_CAPRECT_HEIGHT, 240)
// );
// }
//
// public static void setCaptureRect(Rectangle captureRect) {
// prefs.putInt(PREF_CAPRECT_X, (int) captureRect.getX());
// prefs.putInt(PREF_CAPRECT_Y, (int) captureRect.getY());
// prefs.putInt(PREF_CAPRECT_WIDHT, (int) captureRect.getWidth());
// prefs.putInt(PREF_CAPRECT_HEIGHT, (int) captureRect.getHeight());
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGCodec.java
// public class JPEGCodec {
//
// public static JPEGImageEncoder createJPEGEncoder(OutputStream jpgBytes) {
// return new JPEGImageEncoder(jpgBytes);
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGEncodeParam.java
// public class JPEGEncodeParam {
//
// private float encQuality;
// private boolean b;
//
// public void setQuality(float encQuality, boolean b) {
// this.encQuality = encQuality;
// this.b = b;
// }
//
// public float getEncQuality() {
// return this.encQuality;
// }
//
// public boolean getB() {
// return this.b;
// }
// }
//
// Path: src/main/java/net/sourceforge/krut/jpeg/JPEGImageEncoder.java
// public class JPEGImageEncoder {
//
// private final OutputStream out;
// private JPEGEncodeParam JPEGEncodeParam;
//
// public JPEGImageEncoder(OutputStream out) {
// this.out = out;
// }
//
// public JPEGEncodeParam getDefaultJPEGEncodeParam(BufferedImage image) {
// return new JPEGEncodeParam();
// }
//
// public void setJPEGEncodeParam(JPEGEncodeParam JPEGEncodeParam) {
// this.JPEGEncodeParam = JPEGEncodeParam;
// }
//
// public void encode(BufferedImage image) {
// try {
// ImageIO.write(image, "jpeg", this.out);
// } catch (IOException e) {
// e.printStackTrace();
// }
// }
//
// public net.sourceforge.krut.jpeg.JPEGEncodeParam getJPEGEncodeParam() {
// return JPEGEncodeParam;
// }
// }
// Path: src/main/java/net/sourceforge/krut/recording/ScreenGrabber.java
import java.awt.AWTException;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.MouseInfo;
import java.awt.Point;
import java.awt.Polygon;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import net.sourceforge.krut.Settings;
import net.sourceforge.krut.jpeg.JPEGCodec;
import net.sourceforge.krut.jpeg.JPEGEncodeParam;
import net.sourceforge.krut.jpeg.JPEGImageEncoder;
jpgBytes = new DataOutputStream(fileBuffer);
/** Figure out how many integers we can hold in the
* remaining memory. An integer takes 4B, and we will
* have 2 arrays of integers. We don't want to fill the
* entire memory, and we have used a third, or possibly
* even half, already. So we will allocate 2 arrays of
* integers, each using a sixth of the available memory.
* That means we can at the most have
* convert.intValue() / 24
* integers in each array. That also means we can at
* the most have that amount of frames in a film.
*
* As a comparison, an integer array of 1 MB can hold
* 262144 integers, which would be enough for
* 2h25m38s of film at 30 FPS.
*/
maxNOPics = (int) (convert.intValue() / 24);
System.out.println("Memory after filebuffer: " +
(myRuntime.maxMemory() - myRuntime.totalMemory() +
myRuntime.freeMemory()));
/** Init the encoder to store encoded images directly to memory.
* This will be changed later, but is an easy way of getting a
* first frame for the film, since that frame is to be kept in
* memory anyway (see below).
*
* First we take an "average (=random)" image for the method
* encoder.getDefaultJPEGEncodeParam(image) below.
*/
image = robot.createScreenCapture(Settings.getCaptureRect());
/** Set the encoder to the OutputStream that stores in memory. */
|
encoder = JPEGCodec.createJPEGEncoder(jpgBytesII);
|
jimmyfm/krut
|
src/main/java/net/sourceforge/krut/Krut.java
|
// Path: src/main/java/net/sourceforge/krut/events/EventBus.java
// public class EventBus {
//
// private static final Logger logger = Logger.getLogger(EventBus.class.getName());
// private static final EventBus instance = new EventBus();
//
// private final Collection<Object> listeners;
//
// public EventBus() {
// listeners = new ArrayList<>();
// }
//
// public void register(Object listener) {
// listeners.add(listener);
// }
//
// public void fire(Object event) {
// for (Object listener : listeners) {
// for (Method m : listener.getClass().getMethods()) {
// if (!m.getName().startsWith("listen")) {
// continue;
// }
//
// Class<?> param = m.getParameterTypes()[0];
// if (param.isAssignableFrom(event.getClass())) {
// try {
// m.invoke(listener, event);
// } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// logger.log(Level.SEVERE, "Event bus problems", e);
// }
// }
// }
// }
// }
//
// public static final EventBus get() {
// return EventBus.instance;
// }
//
// public static void main(String[] args) {
// EventBus.instance.register(new net.sourceforge.krut.events.LogSubscriber());
// EventBus.instance.fire(new BaseEvent("asd", "asdasd"));
// }
// }
|
import java.io.IOException;
import net.sourceforge.krut.events.EventBus;
|
package net.sourceforge.krut;
public class Krut {
public static void main(String[] args) {
|
// Path: src/main/java/net/sourceforge/krut/events/EventBus.java
// public class EventBus {
//
// private static final Logger logger = Logger.getLogger(EventBus.class.getName());
// private static final EventBus instance = new EventBus();
//
// private final Collection<Object> listeners;
//
// public EventBus() {
// listeners = new ArrayList<>();
// }
//
// public void register(Object listener) {
// listeners.add(listener);
// }
//
// public void fire(Object event) {
// for (Object listener : listeners) {
// for (Method m : listener.getClass().getMethods()) {
// if (!m.getName().startsWith("listen")) {
// continue;
// }
//
// Class<?> param = m.getParameterTypes()[0];
// if (param.isAssignableFrom(event.getClass())) {
// try {
// m.invoke(listener, event);
// } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// logger.log(Level.SEVERE, "Event bus problems", e);
// }
// }
// }
// }
// }
//
// public static final EventBus get() {
// return EventBus.instance;
// }
//
// public static void main(String[] args) {
// EventBus.instance.register(new net.sourceforge.krut.events.LogSubscriber());
// EventBus.instance.fire(new BaseEvent("asd", "asdasd"));
// }
// }
// Path: src/main/java/net/sourceforge/krut/Krut.java
import java.io.IOException;
import net.sourceforge.krut.events.EventBus;
package net.sourceforge.krut;
public class Krut {
public static void main(String[] args) {
|
EventBus.get().register(new net.sourceforge.krut.events.LogSubscriber());
|
jimmyfm/krut
|
src/main/java/net/sourceforge/krut/ui/NavigationButton.java
|
// Path: src/main/java/net/sourceforge/krut/events/BaseEvent.java
// public class BaseEvent {
//
// private final Object source;
// private final String actionCommand;
//
// public BaseEvent(Object source, String actionCommand) {
// this.source = source;
// this.actionCommand = actionCommand;
// }
//
// public Object getSource() {
// return source;
// }
//
// public String getActionCommand() {
// return actionCommand;
// }
//
// @Override
// public String toString() {
// return String.format("(%s) %s", source, actionCommand);
// }
//
// }
//
// Path: src/main/java/net/sourceforge/krut/events/EventBus.java
// public class EventBus {
//
// private static final Logger logger = Logger.getLogger(EventBus.class.getName());
// private static final EventBus instance = new EventBus();
//
// private final Collection<Object> listeners;
//
// public EventBus() {
// listeners = new ArrayList<>();
// }
//
// public void register(Object listener) {
// listeners.add(listener);
// }
//
// public void fire(Object event) {
// for (Object listener : listeners) {
// for (Method m : listener.getClass().getMethods()) {
// if (!m.getName().startsWith("listen")) {
// continue;
// }
//
// Class<?> param = m.getParameterTypes()[0];
// if (param.isAssignableFrom(event.getClass())) {
// try {
// m.invoke(listener, event);
// } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// logger.log(Level.SEVERE, "Event bus problems", e);
// }
// }
// }
// }
// }
//
// public static final EventBus get() {
// return EventBus.instance;
// }
//
// public static void main(String[] args) {
// EventBus.instance.register(new net.sourceforge.krut.events.LogSubscriber());
// EventBus.instance.fire(new BaseEvent("asd", "asdasd"));
// }
// }
|
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.function.Supplier;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import net.sourceforge.krut.events.BaseEvent;
import net.sourceforge.krut.events.EventBus;
|
package net.sourceforge.krut.ui;
public class NavigationButton extends JButton {
private static final long serialVersionUID = 1L;
/**
* Creates a navigation button of the specified appearance, and returns it.
*
* @param imageName
* A String representation of the URL to an image that should be
* displayed on this button.
* @param actionCommand
* The action command for this button. This command is listened for
* in the actionPerformed(ActionEvent e) method, to determine which
* button was pressed.
* @param toolTipText
* The tooltip text for this button.
* @param altText
* The text that should be typed on this button, if any.
* @param listener
*
* @return A JButton according to the specifications given in the parameters.
*/
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
/** Attempt to locate the image */
URL imageURL = getClass().getResource(imageName);
/** Create and initialize the button. */
setActionCommand(actionCommand);
setToolTipText(toolTipText);
/** Add the image if it was succesfully located. */
if (imageURL != null) {
setIcon(new ImageIcon(imageURL, altText));
} else {
System.err.println("Resource not found: " + imageName);
}
/**
* Set a text on the button. If there is no String or an empty String in the
* parameter altText no text will appear on the button.
*/
setText(altText);
}
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText, Supplier<Object> event) {
this(imageName, actionCommand, toolTipText, altText);
addActionListener(evt -> {
|
// Path: src/main/java/net/sourceforge/krut/events/BaseEvent.java
// public class BaseEvent {
//
// private final Object source;
// private final String actionCommand;
//
// public BaseEvent(Object source, String actionCommand) {
// this.source = source;
// this.actionCommand = actionCommand;
// }
//
// public Object getSource() {
// return source;
// }
//
// public String getActionCommand() {
// return actionCommand;
// }
//
// @Override
// public String toString() {
// return String.format("(%s) %s", source, actionCommand);
// }
//
// }
//
// Path: src/main/java/net/sourceforge/krut/events/EventBus.java
// public class EventBus {
//
// private static final Logger logger = Logger.getLogger(EventBus.class.getName());
// private static final EventBus instance = new EventBus();
//
// private final Collection<Object> listeners;
//
// public EventBus() {
// listeners = new ArrayList<>();
// }
//
// public void register(Object listener) {
// listeners.add(listener);
// }
//
// public void fire(Object event) {
// for (Object listener : listeners) {
// for (Method m : listener.getClass().getMethods()) {
// if (!m.getName().startsWith("listen")) {
// continue;
// }
//
// Class<?> param = m.getParameterTypes()[0];
// if (param.isAssignableFrom(event.getClass())) {
// try {
// m.invoke(listener, event);
// } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// logger.log(Level.SEVERE, "Event bus problems", e);
// }
// }
// }
// }
// }
//
// public static final EventBus get() {
// return EventBus.instance;
// }
//
// public static void main(String[] args) {
// EventBus.instance.register(new net.sourceforge.krut.events.LogSubscriber());
// EventBus.instance.fire(new BaseEvent("asd", "asdasd"));
// }
// }
// Path: src/main/java/net/sourceforge/krut/ui/NavigationButton.java
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.function.Supplier;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import net.sourceforge.krut.events.BaseEvent;
import net.sourceforge.krut.events.EventBus;
package net.sourceforge.krut.ui;
public class NavigationButton extends JButton {
private static final long serialVersionUID = 1L;
/**
* Creates a navigation button of the specified appearance, and returns it.
*
* @param imageName
* A String representation of the URL to an image that should be
* displayed on this button.
* @param actionCommand
* The action command for this button. This command is listened for
* in the actionPerformed(ActionEvent e) method, to determine which
* button was pressed.
* @param toolTipText
* The tooltip text for this button.
* @param altText
* The text that should be typed on this button, if any.
* @param listener
*
* @return A JButton according to the specifications given in the parameters.
*/
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
/** Attempt to locate the image */
URL imageURL = getClass().getResource(imageName);
/** Create and initialize the button. */
setActionCommand(actionCommand);
setToolTipText(toolTipText);
/** Add the image if it was succesfully located. */
if (imageURL != null) {
setIcon(new ImageIcon(imageURL, altText));
} else {
System.err.println("Resource not found: " + imageName);
}
/**
* Set a text on the button. If there is no String or an empty String in the
* parameter altText no text will appear on the button.
*/
setText(altText);
}
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText, Supplier<Object> event) {
this(imageName, actionCommand, toolTipText, altText);
addActionListener(evt -> {
|
EventBus.get().fire(event.get());
|
jimmyfm/krut
|
src/main/java/net/sourceforge/krut/ui/NavigationButton.java
|
// Path: src/main/java/net/sourceforge/krut/events/BaseEvent.java
// public class BaseEvent {
//
// private final Object source;
// private final String actionCommand;
//
// public BaseEvent(Object source, String actionCommand) {
// this.source = source;
// this.actionCommand = actionCommand;
// }
//
// public Object getSource() {
// return source;
// }
//
// public String getActionCommand() {
// return actionCommand;
// }
//
// @Override
// public String toString() {
// return String.format("(%s) %s", source, actionCommand);
// }
//
// }
//
// Path: src/main/java/net/sourceforge/krut/events/EventBus.java
// public class EventBus {
//
// private static final Logger logger = Logger.getLogger(EventBus.class.getName());
// private static final EventBus instance = new EventBus();
//
// private final Collection<Object> listeners;
//
// public EventBus() {
// listeners = new ArrayList<>();
// }
//
// public void register(Object listener) {
// listeners.add(listener);
// }
//
// public void fire(Object event) {
// for (Object listener : listeners) {
// for (Method m : listener.getClass().getMethods()) {
// if (!m.getName().startsWith("listen")) {
// continue;
// }
//
// Class<?> param = m.getParameterTypes()[0];
// if (param.isAssignableFrom(event.getClass())) {
// try {
// m.invoke(listener, event);
// } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// logger.log(Level.SEVERE, "Event bus problems", e);
// }
// }
// }
// }
// }
//
// public static final EventBus get() {
// return EventBus.instance;
// }
//
// public static void main(String[] args) {
// EventBus.instance.register(new net.sourceforge.krut.events.LogSubscriber());
// EventBus.instance.fire(new BaseEvent("asd", "asdasd"));
// }
// }
|
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.function.Supplier;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import net.sourceforge.krut.events.BaseEvent;
import net.sourceforge.krut.events.EventBus;
|
package net.sourceforge.krut.ui;
public class NavigationButton extends JButton {
private static final long serialVersionUID = 1L;
/**
* Creates a navigation button of the specified appearance, and returns it.
*
* @param imageName
* A String representation of the URL to an image that should be
* displayed on this button.
* @param actionCommand
* The action command for this button. This command is listened for
* in the actionPerformed(ActionEvent e) method, to determine which
* button was pressed.
* @param toolTipText
* The tooltip text for this button.
* @param altText
* The text that should be typed on this button, if any.
* @param listener
*
* @return A JButton according to the specifications given in the parameters.
*/
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
/** Attempt to locate the image */
URL imageURL = getClass().getResource(imageName);
/** Create and initialize the button. */
setActionCommand(actionCommand);
setToolTipText(toolTipText);
/** Add the image if it was succesfully located. */
if (imageURL != null) {
setIcon(new ImageIcon(imageURL, altText));
} else {
System.err.println("Resource not found: " + imageName);
}
/**
* Set a text on the button. If there is no String or an empty String in the
* parameter altText no text will appear on the button.
*/
setText(altText);
}
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText, Supplier<Object> event) {
this(imageName, actionCommand, toolTipText, altText);
addActionListener(evt -> {
EventBus.get().fire(event.get());
});
}
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText, ActionListener listener) {
this(imageName, actionCommand, toolTipText, altText);
|
// Path: src/main/java/net/sourceforge/krut/events/BaseEvent.java
// public class BaseEvent {
//
// private final Object source;
// private final String actionCommand;
//
// public BaseEvent(Object source, String actionCommand) {
// this.source = source;
// this.actionCommand = actionCommand;
// }
//
// public Object getSource() {
// return source;
// }
//
// public String getActionCommand() {
// return actionCommand;
// }
//
// @Override
// public String toString() {
// return String.format("(%s) %s", source, actionCommand);
// }
//
// }
//
// Path: src/main/java/net/sourceforge/krut/events/EventBus.java
// public class EventBus {
//
// private static final Logger logger = Logger.getLogger(EventBus.class.getName());
// private static final EventBus instance = new EventBus();
//
// private final Collection<Object> listeners;
//
// public EventBus() {
// listeners = new ArrayList<>();
// }
//
// public void register(Object listener) {
// listeners.add(listener);
// }
//
// public void fire(Object event) {
// for (Object listener : listeners) {
// for (Method m : listener.getClass().getMethods()) {
// if (!m.getName().startsWith("listen")) {
// continue;
// }
//
// Class<?> param = m.getParameterTypes()[0];
// if (param.isAssignableFrom(event.getClass())) {
// try {
// m.invoke(listener, event);
// } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
// logger.log(Level.SEVERE, "Event bus problems", e);
// }
// }
// }
// }
// }
//
// public static final EventBus get() {
// return EventBus.instance;
// }
//
// public static void main(String[] args) {
// EventBus.instance.register(new net.sourceforge.krut.events.LogSubscriber());
// EventBus.instance.fire(new BaseEvent("asd", "asdasd"));
// }
// }
// Path: src/main/java/net/sourceforge/krut/ui/NavigationButton.java
import java.awt.event.ActionListener;
import java.net.URL;
import java.util.function.Supplier;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import net.sourceforge.krut.events.BaseEvent;
import net.sourceforge.krut.events.EventBus;
package net.sourceforge.krut.ui;
public class NavigationButton extends JButton {
private static final long serialVersionUID = 1L;
/**
* Creates a navigation button of the specified appearance, and returns it.
*
* @param imageName
* A String representation of the URL to an image that should be
* displayed on this button.
* @param actionCommand
* The action command for this button. This command is listened for
* in the actionPerformed(ActionEvent e) method, to determine which
* button was pressed.
* @param toolTipText
* The tooltip text for this button.
* @param altText
* The text that should be typed on this button, if any.
* @param listener
*
* @return A JButton according to the specifications given in the parameters.
*/
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText) {
/** Attempt to locate the image */
URL imageURL = getClass().getResource(imageName);
/** Create and initialize the button. */
setActionCommand(actionCommand);
setToolTipText(toolTipText);
/** Add the image if it was succesfully located. */
if (imageURL != null) {
setIcon(new ImageIcon(imageURL, altText));
} else {
System.err.println("Resource not found: " + imageName);
}
/**
* Set a text on the button. If there is no String or an empty String in the
* parameter altText no text will appear on the button.
*/
setText(altText);
}
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText, Supplier<Object> event) {
this(imageName, actionCommand, toolTipText, altText);
addActionListener(evt -> {
EventBus.get().fire(event.get());
});
}
public NavigationButton(String imageName, String actionCommand, String toolTipText, String altText, ActionListener listener) {
this(imageName, actionCommand, toolTipText, altText);
|
addActionListener(evt -> EventBus.get().fire(new BaseEvent(NavigationButton.this, actionCommand)));
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/utils/IndexRequestBuilderCreatorTest.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
// public class ElasticSearchConnectionHandler extends ConnectionHandler {
//
// /**
// * Constructor.
// *
// * @param configuration the configuration.
// */
// public ElasticSearchConnectionHandler(IConfiguration configuration) {
// super(configuration);
// }
//
// /**
// * This method creates a elasticsearch connection.
// *
// * @param iCredentials the credentials to connect with the database.
// * @param connectorClusterConfig the cluster configuration.
// * @throws ConnectionException if the connection is not established.
// * @return a elasticsearch connection.
// */
// @Override
// @TimerJ
// protected Connection createNativeConnection(ICredentials iCredentials,
// ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
// Connection connection;
// if (isNodeClient(connectorClusterConfig)) {
// connection = new NodeConnection(iCredentials, connectorClusterConfig);
// }
// else {
// try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
// catch (ExecutionException exception){
// throw new ConnectionException("The connection could not be established", exception);
// }
// }
// if (!connection.isConnected()) {
// throw new ConnectionException("The connection could not be established");}
// return connection;
// }
//
// /**
// * Return true if the config says that the connection is nodeClient. false in other case.
// *
// * @param config the configuration.
// * @return true if is configure to be a node connection. False in other case.
// */
// @TimerJ
// private boolean isNodeClient(ConnectorClusterConfig config) {
// return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
// }
//
// }
|
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.connection.ElasticSearchConnectionHandler;
import com.stratio.crossdata.common.data.*;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.UnsupportedException;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.IndexMetadata;
import com.stratio.crossdata.common.metadata.TableMetadata;
import com.stratio.crossdata.common.statements.structures.Selector;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.engine.utils;
/**
* IndexRequestBuilderCreator Tester.
*
* @author <Authors name>
* @version 1.0
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(value = { Client.class })
public class IndexRequestBuilderCreatorTest {
private static final String CLUSTER_NAME = "CLUSTER NAME".toLowerCase();
private static final String INDEX_NAME = "INDEX_NAME".toLowerCase();
private static final String TYPE_NAME = "TYPE_NAME".toLowerCase();
private TableName tableName = new TableName(INDEX_NAME, TYPE_NAME);
private static final String COLUMN_NAME = "row_name";
private static final String CELL_VALUE = "cell_value";
@Rule
public ExpectedException exception = ExpectedException.none();
IndexRequestBuilderCreator indexRequestBuilderCreator;
private LinkedHashMap<ColumnName, ColumnMetadata> columns = new LinkedHashMap<ColumnName, ColumnMetadata>();
private LinkedHashMap<Selector, Selector> options = new LinkedHashMap<Selector, Selector>();
private Map<IndexName, IndexMetadata> indexes = new HashMap<IndexName, IndexMetadata>();
private ClusterName clusterRef = new ClusterName(CLUSTER_NAME);
private LinkedList<ColumnName> partitionKey = new LinkedList<ColumnName>();
private LinkedList<ColumnName> clusterKey = new LinkedList<ColumnName>();
@Mock
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
// public class ElasticSearchConnectionHandler extends ConnectionHandler {
//
// /**
// * Constructor.
// *
// * @param configuration the configuration.
// */
// public ElasticSearchConnectionHandler(IConfiguration configuration) {
// super(configuration);
// }
//
// /**
// * This method creates a elasticsearch connection.
// *
// * @param iCredentials the credentials to connect with the database.
// * @param connectorClusterConfig the cluster configuration.
// * @throws ConnectionException if the connection is not established.
// * @return a elasticsearch connection.
// */
// @Override
// @TimerJ
// protected Connection createNativeConnection(ICredentials iCredentials,
// ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
// Connection connection;
// if (isNodeClient(connectorClusterConfig)) {
// connection = new NodeConnection(iCredentials, connectorClusterConfig);
// }
// else {
// try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
// catch (ExecutionException exception){
// throw new ConnectionException("The connection could not be established", exception);
// }
// }
// if (!connection.isConnected()) {
// throw new ConnectionException("The connection could not be established");}
// return connection;
// }
//
// /**
// * Return true if the config says that the connection is nodeClient. false in other case.
// *
// * @param config the configuration.
// * @return true if is configure to be a node connection. False in other case.
// */
// @TimerJ
// private boolean isNodeClient(ConnectorClusterConfig config) {
// return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
// }
//
// }
// Path: connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/utils/IndexRequestBuilderCreatorTest.java
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.connection.ElasticSearchConnectionHandler;
import com.stratio.crossdata.common.data.*;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.UnsupportedException;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.IndexMetadata;
import com.stratio.crossdata.common.metadata.TableMetadata;
import com.stratio.crossdata.common.statements.structures.Selector;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.engine.utils;
/**
* IndexRequestBuilderCreator Tester.
*
* @author <Authors name>
* @version 1.0
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(value = { Client.class })
public class IndexRequestBuilderCreatorTest {
private static final String CLUSTER_NAME = "CLUSTER NAME".toLowerCase();
private static final String INDEX_NAME = "INDEX_NAME".toLowerCase();
private static final String TYPE_NAME = "TYPE_NAME".toLowerCase();
private TableName tableName = new TableName(INDEX_NAME, TYPE_NAME);
private static final String COLUMN_NAME = "row_name";
private static final String CELL_VALUE = "cell_value";
@Rule
public ExpectedException exception = ExpectedException.none();
IndexRequestBuilderCreator indexRequestBuilderCreator;
private LinkedHashMap<ColumnName, ColumnMetadata> columns = new LinkedHashMap<ColumnName, ColumnMetadata>();
private LinkedHashMap<Selector, Selector> options = new LinkedHashMap<Selector, Selector>();
private Map<IndexName, IndexMetadata> indexes = new HashMap<IndexName, IndexMetadata>();
private ClusterName clusterRef = new ClusterName(CLUSTER_NAME);
private LinkedList<ColumnName> partitionKey = new LinkedList<ColumnName>();
private LinkedList<ColumnName> clusterKey = new LinkedList<ColumnName>();
@Mock
|
private ElasticSearchConnectionHandler connectionHandler;
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/connection/ConnectionHandleTest.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/configuration/ConfigurationOptions.java
// public enum ConfigurationOptions {
//
// /**
// * The elasticserach node type property.
// */
// NODE_TYPE("node_type", "node_type", Constants.FALSE),
// /**
// * The elasticserach node data property.
// */
// NODE_DATA("node.data", "node.data",Constants.FALSE),
// /**
// * The elasticserach node master property.
// */
// NODE_MASTER("node.master", "node.master",Constants.FALSE),
// /**
// * The elasticserach transfer sniff type property.
// */
// TRANSPORT_SNIFF("client.transport.sniff", "client.transport.sniff",Constants.TRUE),
// /**
// * The elastichseach cluser name.
// */
// CLUSTER_NAME("Cluster Name","cluster.name","", "clusterName"),
// /**
// * The hosts ip.
// */
// HOST("Hosts","Hosts", new String[] { "localhost" }),
// /**
// * The hosts ports.
// */
// PORT("Native Ports", "Native Ports",new String[] { "c" }),
// /**
// * The elasticsearch coerce property.
// */
// COERCE("index.mapping.coerce","index.mapping.coerce", Constants.FALSE),
// /**
// * The elasticsearch mapper dynamic property.
// */
// DYNAMIC("index.mapper.dynamic", "index.mapper.dynamic",Constants.FALSE);
//
// /**
// * The name of the option in crossdata manifest.
// */
// private final String manifestOption;
// /**
// * The default value of the options.
// */
// private final String[] defaultValue;
// /**
// * The option name in elasticsearch.
// */
// private final String elasticSearchOption;
//
// /**
// * Constructor.
// *
// * @param manifestOption the name of the option.
// * @param defaultValue the default value of the option.
// */
// ConfigurationOptions(String manifestOption, String elasticSearchOption, String... defaultValue) {
// this.manifestOption = manifestOption;
// this.defaultValue = defaultValue;
// this.elasticSearchOption = elasticSearchOption;
//
// }
//
// /**
// * return the default value.
// *
// * @return the default value.
// */
// public String[] getDefaultValue() {
// return defaultValue.clone();
// }
//
// /**
// * Return the option name defined in the manifest.
// *
// * @return the option name.
// */
// public String getManifestOption() {
// return manifestOption;
// }
//
//
//
// /**
// * Return the option name to ElasticSearch.
// *
// * @return the option name.
// */
// public String getElasticSearchOption() {
// return elasticSearchOption;
// }
//
// }
|
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.configuration.ConfigurationOptions;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.connector.IConfiguration;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.security.ICredentials;
import org.elasticsearch.client.transport.TransportClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.internal.util.reflection.Whitebox;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.powermock.api.mockito.PowerMockito.whenNew;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.connection;
/**
* ConnectionHandle Tester.
*
* @author <Authors name>
* @version 1.0
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(value = { ElasticSearchConnectionHandler.class, TransportClient.class })
public class ConnectionHandleTest {
private static final String CLUSTER_NAME = "cluster_name";
private ElasticSearchConnectionHandler connectionHandle = null;
@Mock
private IConfiguration iConfiguration;
@Before
public void before() throws Exception {
connectionHandle = new ElasticSearchConnectionHandler(iConfiguration);
}
@After
public void after() throws Exception {
}
/**
* Method: createConnection(String clusterName, Connection connection)
*/
@Test
public void testCreateNodeConnection() throws Exception {
ICredentials credentials = mock(ICredentials.class);
Map<String, String> connectionOptios = new HashMap<>();
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/configuration/ConfigurationOptions.java
// public enum ConfigurationOptions {
//
// /**
// * The elasticserach node type property.
// */
// NODE_TYPE("node_type", "node_type", Constants.FALSE),
// /**
// * The elasticserach node data property.
// */
// NODE_DATA("node.data", "node.data",Constants.FALSE),
// /**
// * The elasticserach node master property.
// */
// NODE_MASTER("node.master", "node.master",Constants.FALSE),
// /**
// * The elasticserach transfer sniff type property.
// */
// TRANSPORT_SNIFF("client.transport.sniff", "client.transport.sniff",Constants.TRUE),
// /**
// * The elastichseach cluser name.
// */
// CLUSTER_NAME("Cluster Name","cluster.name","", "clusterName"),
// /**
// * The hosts ip.
// */
// HOST("Hosts","Hosts", new String[] { "localhost" }),
// /**
// * The hosts ports.
// */
// PORT("Native Ports", "Native Ports",new String[] { "c" }),
// /**
// * The elasticsearch coerce property.
// */
// COERCE("index.mapping.coerce","index.mapping.coerce", Constants.FALSE),
// /**
// * The elasticsearch mapper dynamic property.
// */
// DYNAMIC("index.mapper.dynamic", "index.mapper.dynamic",Constants.FALSE);
//
// /**
// * The name of the option in crossdata manifest.
// */
// private final String manifestOption;
// /**
// * The default value of the options.
// */
// private final String[] defaultValue;
// /**
// * The option name in elasticsearch.
// */
// private final String elasticSearchOption;
//
// /**
// * Constructor.
// *
// * @param manifestOption the name of the option.
// * @param defaultValue the default value of the option.
// */
// ConfigurationOptions(String manifestOption, String elasticSearchOption, String... defaultValue) {
// this.manifestOption = manifestOption;
// this.defaultValue = defaultValue;
// this.elasticSearchOption = elasticSearchOption;
//
// }
//
// /**
// * return the default value.
// *
// * @return the default value.
// */
// public String[] getDefaultValue() {
// return defaultValue.clone();
// }
//
// /**
// * Return the option name defined in the manifest.
// *
// * @return the option name.
// */
// public String getManifestOption() {
// return manifestOption;
// }
//
//
//
// /**
// * Return the option name to ElasticSearch.
// *
// * @return the option name.
// */
// public String getElasticSearchOption() {
// return elasticSearchOption;
// }
//
// }
// Path: connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/connection/ConnectionHandleTest.java
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.configuration.ConfigurationOptions;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.connector.IConfiguration;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.security.ICredentials;
import org.elasticsearch.client.transport.TransportClient;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.internal.util.reflection.Whitebox;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import static org.powermock.api.mockito.PowerMockito.whenNew;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.connection;
/**
* ConnectionHandle Tester.
*
* @author <Authors name>
* @version 1.0
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(value = { ElasticSearchConnectionHandler.class, TransportClient.class })
public class ConnectionHandleTest {
private static final String CLUSTER_NAME = "cluster_name";
private ElasticSearchConnectionHandler connectionHandle = null;
@Mock
private IConfiguration iConfiguration;
@Before
public void before() throws Exception {
connectionHandle = new ElasticSearchConnectionHandler(iConfiguration);
}
@After
public void after() throws Exception {
}
/**
* Method: createConnection(String clusterName, Connection connection)
*/
@Test
public void testCreateNodeConnection() throws Exception {
ICredentials credentials = mock(ICredentials.class);
Map<String, String> connectionOptios = new HashMap<>();
|
connectionOptios.put(ConfigurationOptions.NODE_TYPE.getManifestOption(), "true");
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/query/metadata/MetadataCreatorTest.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/metadata/MetadataCreator.java
// public class MetadataCreator {
//
// /**
// * This method creates the column metadata.
// *
// * @param queryData the queryData object.
// * @return the list with the column metadata.
// */
// public List<ColumnMetadata> createColumnMetadata(ProjectParsed queryData) {
//
// List<ColumnMetadata> retunColumnMetadata = new ArrayList<>();
//
// Select select = queryData.getSelect();
//
// Map<Selector, String> columnAliasMap = select.getColumnMap();
// for (Map.Entry<Selector, String> columnAliasName : columnAliasMap.entrySet()) {
// ColumnMetadata columnMetadata = new ColumnMetadata(columnAliasName.getKey().getColumnName(), null,
// select.getTypeMapFromColumnName().get(columnAliasName.getKey()));
//
// columnMetadata.getName().setAlias(columnAliasName.getValue());
// retunColumnMetadata.add(columnMetadata);
// }
//
// return retunColumnMetadata;
// }
// }
|
import com.stratio.connector.commons.engine.query.ProjectParsed;
import com.stratio.connector.commons.engine.query.ProjectValidator;
import com.stratio.connector.elasticsearch.core.engine.metadata.MetadataCreator;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.data.ColumnName;
import com.stratio.crossdata.common.data.TableName;
import com.stratio.crossdata.common.exceptions.ConnectorException;
import com.stratio.crossdata.common.logicalplan.Project;
import com.stratio.crossdata.common.logicalplan.Select;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.ColumnType;
import com.stratio.crossdata.common.metadata.DataType;
import com.stratio.crossdata.common.metadata.Operations;
import com.stratio.crossdata.common.statements.structures.ColumnSelector;
import com.stratio.crossdata.common.statements.structures.Selector;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.engine.query.metadata;
/**
* MetadataCreator Tester.
*
* @author <Authors name>
* @version 1.0
*/
public class MetadataCreatorTest {
private static final String CATALOG_NAME = "catalog_name";
private static final String TABLE_NAME = "table_name";
private static final String COLUMN_NAME1 = "column_name1";
private static final String ALIAS_1 = "alias_1";
private static final String COLUMN_NAME2 = "column_name2";
private static final String ALIAS_2 = "alias_2";
private static final String COLUMN_NAME3 = "column_name3";
private String[] NAMES = { COLUMN_NAME1, COLUMN_NAME2, COLUMN_NAME3 };
private static final String ALIAS_3 = "alias_3";
private String[] ALIAS = { ALIAS_1, ALIAS_2, ALIAS_3 };
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/metadata/MetadataCreator.java
// public class MetadataCreator {
//
// /**
// * This method creates the column metadata.
// *
// * @param queryData the queryData object.
// * @return the list with the column metadata.
// */
// public List<ColumnMetadata> createColumnMetadata(ProjectParsed queryData) {
//
// List<ColumnMetadata> retunColumnMetadata = new ArrayList<>();
//
// Select select = queryData.getSelect();
//
// Map<Selector, String> columnAliasMap = select.getColumnMap();
// for (Map.Entry<Selector, String> columnAliasName : columnAliasMap.entrySet()) {
// ColumnMetadata columnMetadata = new ColumnMetadata(columnAliasName.getKey().getColumnName(), null,
// select.getTypeMapFromColumnName().get(columnAliasName.getKey()));
//
// columnMetadata.getName().setAlias(columnAliasName.getValue());
// retunColumnMetadata.add(columnMetadata);
// }
//
// return retunColumnMetadata;
// }
// }
// Path: connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/query/metadata/MetadataCreatorTest.java
import com.stratio.connector.commons.engine.query.ProjectParsed;
import com.stratio.connector.commons.engine.query.ProjectValidator;
import com.stratio.connector.elasticsearch.core.engine.metadata.MetadataCreator;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.data.ColumnName;
import com.stratio.crossdata.common.data.TableName;
import com.stratio.crossdata.common.exceptions.ConnectorException;
import com.stratio.crossdata.common.logicalplan.Project;
import com.stratio.crossdata.common.logicalplan.Select;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.ColumnType;
import com.stratio.crossdata.common.metadata.DataType;
import com.stratio.crossdata.common.metadata.Operations;
import com.stratio.crossdata.common.statements.structures.ColumnSelector;
import com.stratio.crossdata.common.statements.structures.Selector;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.engine.query.metadata;
/**
* MetadataCreator Tester.
*
* @author <Authors name>
* @version 1.0
*/
public class MetadataCreatorTest {
private static final String CATALOG_NAME = "catalog_name";
private static final String TABLE_NAME = "table_name";
private static final String COLUMN_NAME1 = "column_name1";
private static final String ALIAS_1 = "alias_1";
private static final String COLUMN_NAME2 = "column_name2";
private static final String ALIAS_2 = "alias_2";
private static final String COLUMN_NAME3 = "column_name3";
private String[] NAMES = { COLUMN_NAME1, COLUMN_NAME2, COLUMN_NAME3 };
private static final String ALIAS_3 = "alias_3";
private String[] ALIAS = { ALIAS_1, ALIAS_2, ALIAS_3 };
|
MetadataCreator metadataCreator;
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/utils/ContentBuilderCreator.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/metadata/ESIndexType.java
// public enum ESIndexType {
// /**
// * No Index.
// */
// NO("no"),
// /**
// * Analyzed Index.
// */
// ANALYZED("analyzed"),
// /**
// * Not analized index.
// */
// NOT_ANALYZED("not_analyzed");
//
// /**
// * The code.
// */
// private final String code;
//
// /**
// * Cosntructor.
// *
// * @param code the code.
// */
// ESIndexType(String code) {
// this.code = code;
// }
//
// /**
// * Return the default index value.
// *
// * @return the default index value.
// */
// public static ESIndexType getDefault() {
// return ANALYZED;
// }
//
// /**
// * Return Index code.
// *
// * @return the index code.
// */
// public String getCode() {
// return code;
// }
//
// }
|
import java.util.List;
import java.util.Map;
import com.stratio.connector.elasticsearch.core.engine.metadata.ESIndexType;
import com.stratio.crossdata.common.data.ColumnName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.ColumnType;
import com.stratio.crossdata.common.metadata.TableMetadata;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
|
for (String analyzer : analyzers) {
xContentBuilder.startObject(analyzer);
xContentBuilder = xContentBuilder.field(TYPE, columnTypeName);
xContentBuilder = xContentBuilder.field(ANALYZER, analyzer);
xContentBuilder.endObject();
}
xContentBuilder.endObject();
}
}
return xContentBuilder.endObject();
}
/**
* This method creates the XContenBuilder that defines a mapping for a specific index and type.
*
* @param columnMetadata the column meta data.
* @return the XContentBuilder.
* @throws IOException if a IO excetion happens.
* @throws ExecutionException if an error happen.
*/
public XContentBuilder addColumn(ColumnMetadata columnMetadata) throws IOException, ExecutionException {
XContentBuilder mapping;
// Adds the information about the index and type
mapping = XContentFactory.jsonBuilder().startObject()
.startObject(columnMetadata.getName().getTableName().getName()).startObject(PROPERTIES)
.startObject(columnMetadata.getName().getName())
.field(TYPE, TypeConverter.convert(columnMetadata.getColumnType()))
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/metadata/ESIndexType.java
// public enum ESIndexType {
// /**
// * No Index.
// */
// NO("no"),
// /**
// * Analyzed Index.
// */
// ANALYZED("analyzed"),
// /**
// * Not analized index.
// */
// NOT_ANALYZED("not_analyzed");
//
// /**
// * The code.
// */
// private final String code;
//
// /**
// * Cosntructor.
// *
// * @param code the code.
// */
// ESIndexType(String code) {
// this.code = code;
// }
//
// /**
// * Return the default index value.
// *
// * @return the default index value.
// */
// public static ESIndexType getDefault() {
// return ANALYZED;
// }
//
// /**
// * Return Index code.
// *
// * @return the index code.
// */
// public String getCode() {
// return code;
// }
//
// }
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/utils/ContentBuilderCreator.java
import java.util.List;
import java.util.Map;
import com.stratio.connector.elasticsearch.core.engine.metadata.ESIndexType;
import com.stratio.crossdata.common.data.ColumnName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.ColumnType;
import com.stratio.crossdata.common.metadata.TableMetadata;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
for (String analyzer : analyzers) {
xContentBuilder.startObject(analyzer);
xContentBuilder = xContentBuilder.field(TYPE, columnTypeName);
xContentBuilder = xContentBuilder.field(ANALYZER, analyzer);
xContentBuilder.endObject();
}
xContentBuilder.endObject();
}
}
return xContentBuilder.endObject();
}
/**
* This method creates the XContenBuilder that defines a mapping for a specific index and type.
*
* @param columnMetadata the column meta data.
* @return the XContentBuilder.
* @throws IOException if a IO excetion happens.
* @throws ExecutionException if an error happen.
*/
public XContentBuilder addColumn(ColumnMetadata columnMetadata) throws IOException, ExecutionException {
XContentBuilder mapping;
// Adds the information about the index and type
mapping = XContentFactory.jsonBuilder().startObject()
.startObject(columnMetadata.getName().getTableName().getName()).startObject(PROPERTIES)
.startObject(columnMetadata.getName().getName())
.field(TYPE, TypeConverter.convert(columnMetadata.getColumnType()))
|
.field(INDEX, ESIndexType.getDefault().getCode()).endObject().endObject().endObject()
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/query/ConnectorQueryBuilderTest.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/query/functions/ESFunction.java
// public abstract class ESFunction {
//
// public static final String CONTAINS = "contains";
// public static final String MATCH_PHRASE = "match_phrase";
// public static final String MULTI_MATCH = "multi_match";
// public static final String MATCH_PREFIX = "match_prefix";
// public static final String MULTI_MATCH_FUZZY = "multi_match_fuzzy";
// public static final String FUZZY = "fuzzy";
//
//
// /**
// * Function Name
// */
// private String name;
//
// /**
// * The function parameters.
// */
// private List<Selector> parameters;
//
// /**
// * Default constructor.
// *
// * @param name Function Name
// * @param paramareters function parameters.
// */
// protected ESFunction(String name, List<Selector> paramareters) {
// this.parameters = paramareters;
// this.name = name;
// }
//
// public List<Selector> getParameters() {
// return parameters;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Build a {@link org.elasticsearch.index.query.QueryBuilder} that satisfy this function.
// *
// * @return
// */
// public abstract QueryBuilder buildQuery() throws ExecutionException;
//
//
// /**
// * Builds a ESFunction using the FunctionRelation specification.cd
// * @param function
// * @return A ESFunction child.
// * @throws UnsupportedException is the FunctionRelation isn't supported.
// */
// public static ESFunction build(FunctionRelation function) throws UnsupportedException {
// List parameters = new ArrayList();
// parameters.addAll(function.getFunctionSelectors());
//
// switch(function.getFunctionName()){
// case CONTAINS:
// return new Match(parameters);
// case MATCH_PHRASE:
// return new MatchPhrase(parameters);
// case MULTI_MATCH:
// return new MultiMatch(parameters);
// case MATCH_PREFIX:
// return new MatchPrefix(parameters);
// case MULTI_MATCH_FUZZY:
// return new MultiMatchFuzzy(parameters);
// case FUZZY:
// return new Fuzzy(parameters);
// default:
// throw new UnsupportedException("The function [" + function.getFunctionName() + "] is not supported");
// }
// }
//
// /**
// * Checks function signature
// *
// * @param functionName function name
// * @param checkEmpty flag that indicates if empty values are allowed
// * @param expectedParameters expected number of parameters
// * @param expectedSignature expected function signature
// * @throws ExecutionException
// */
// public void validateFunctionSignature (String functionName, boolean checkEmpty, int expectedParameters, String expectedSignature)
// throws ExecutionException {
//
// if (null == parameters || parameters.size() != expectedParameters){
// throw new ExecutionException("Wrong number of parameters for \"" + functionName + "\" function. " +
// "Expected signature: " + expectedSignature + ".");
// }
// if (checkEmpty){
// for (Selector parameter : parameters) {
// if (null == parameter || parameter.getStringValue().trim().isEmpty()){
// throw new ExecutionException("Every parameter in \"" + functionName + "\" function must have a non empty value.");
// }
// }
// }
// }
// }
|
import com.stratio.connector.commons.engine.query.ProjectParsed;
import com.stratio.connector.elasticsearch.core.engine.query.functions.ESFunction;
import com.stratio.crossdata.common.data.ColumnName;
import com.stratio.crossdata.common.data.TableName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.logicalplan.*;
import com.stratio.crossdata.common.metadata.Operations;
import com.stratio.crossdata.common.statements.structures.*;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.client.Client;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
|
Disjunction ds = new Disjunction(Collections.singleton(Operations.FILTER_DISJUNCTION), terms);
when(parsedQuery.getDisjunctionOfFunctionsList()).thenReturn(Collections.singleton(ds));
// Mocks return fields property
buildReturnFields(parsedQuery);
SearchRequestBuilder requestBuilder = (SearchRequestBuilder) connectorQueryBuilder.buildQuery(client, parsedQuery);
assertEquals(EXPECTED_QUERY, cleanJson(requestBuilder.toString()));
}
catch (Exception exception) {
fail(exception.getMessage());
}
}
public void buildReturnFields(ProjectParsed parsedQuery) {
List<String> returnFields = new ArrayList<String>();
returnFields.add(COLUMN_1);
returnFields.add(COLUMN_2);
addReturnFields(returnFields, parsedQuery);
}
public FunctionFilter buildFunctionContainsFilter(String columnName, String value) {
List<Selector> parameters = new ArrayList<>();
TableName tableName = new TableName("catalog", "table");
parameters.add(new ColumnSelector(new ColumnName(tableName, columnName)));
parameters.add(new StringSelector(value));
parameters.add(new StringSelector("100%"));
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/query/functions/ESFunction.java
// public abstract class ESFunction {
//
// public static final String CONTAINS = "contains";
// public static final String MATCH_PHRASE = "match_phrase";
// public static final String MULTI_MATCH = "multi_match";
// public static final String MATCH_PREFIX = "match_prefix";
// public static final String MULTI_MATCH_FUZZY = "multi_match_fuzzy";
// public static final String FUZZY = "fuzzy";
//
//
// /**
// * Function Name
// */
// private String name;
//
// /**
// * The function parameters.
// */
// private List<Selector> parameters;
//
// /**
// * Default constructor.
// *
// * @param name Function Name
// * @param paramareters function parameters.
// */
// protected ESFunction(String name, List<Selector> paramareters) {
// this.parameters = paramareters;
// this.name = name;
// }
//
// public List<Selector> getParameters() {
// return parameters;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Build a {@link org.elasticsearch.index.query.QueryBuilder} that satisfy this function.
// *
// * @return
// */
// public abstract QueryBuilder buildQuery() throws ExecutionException;
//
//
// /**
// * Builds a ESFunction using the FunctionRelation specification.cd
// * @param function
// * @return A ESFunction child.
// * @throws UnsupportedException is the FunctionRelation isn't supported.
// */
// public static ESFunction build(FunctionRelation function) throws UnsupportedException {
// List parameters = new ArrayList();
// parameters.addAll(function.getFunctionSelectors());
//
// switch(function.getFunctionName()){
// case CONTAINS:
// return new Match(parameters);
// case MATCH_PHRASE:
// return new MatchPhrase(parameters);
// case MULTI_MATCH:
// return new MultiMatch(parameters);
// case MATCH_PREFIX:
// return new MatchPrefix(parameters);
// case MULTI_MATCH_FUZZY:
// return new MultiMatchFuzzy(parameters);
// case FUZZY:
// return new Fuzzy(parameters);
// default:
// throw new UnsupportedException("The function [" + function.getFunctionName() + "] is not supported");
// }
// }
//
// /**
// * Checks function signature
// *
// * @param functionName function name
// * @param checkEmpty flag that indicates if empty values are allowed
// * @param expectedParameters expected number of parameters
// * @param expectedSignature expected function signature
// * @throws ExecutionException
// */
// public void validateFunctionSignature (String functionName, boolean checkEmpty, int expectedParameters, String expectedSignature)
// throws ExecutionException {
//
// if (null == parameters || parameters.size() != expectedParameters){
// throw new ExecutionException("Wrong number of parameters for \"" + functionName + "\" function. " +
// "Expected signature: " + expectedSignature + ".");
// }
// if (checkEmpty){
// for (Selector parameter : parameters) {
// if (null == parameter || parameter.getStringValue().trim().isEmpty()){
// throw new ExecutionException("Every parameter in \"" + functionName + "\" function must have a non empty value.");
// }
// }
// }
// }
// }
// Path: connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/query/ConnectorQueryBuilderTest.java
import com.stratio.connector.commons.engine.query.ProjectParsed;
import com.stratio.connector.elasticsearch.core.engine.query.functions.ESFunction;
import com.stratio.crossdata.common.data.ColumnName;
import com.stratio.crossdata.common.data.TableName;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.logicalplan.*;
import com.stratio.crossdata.common.metadata.Operations;
import com.stratio.crossdata.common.statements.structures.*;
import org.elasticsearch.action.search.SearchRequestBuilder;
import org.elasticsearch.client.Client;
import org.junit.Before;
import org.junit.Test;
import java.util.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
Disjunction ds = new Disjunction(Collections.singleton(Operations.FILTER_DISJUNCTION), terms);
when(parsedQuery.getDisjunctionOfFunctionsList()).thenReturn(Collections.singleton(ds));
// Mocks return fields property
buildReturnFields(parsedQuery);
SearchRequestBuilder requestBuilder = (SearchRequestBuilder) connectorQueryBuilder.buildQuery(client, parsedQuery);
assertEquals(EXPECTED_QUERY, cleanJson(requestBuilder.toString()));
}
catch (Exception exception) {
fail(exception.getMessage());
}
}
public void buildReturnFields(ProjectParsed parsedQuery) {
List<String> returnFields = new ArrayList<String>();
returnFields.add(COLUMN_1);
returnFields.add(COLUMN_2);
addReturnFields(returnFields, parsedQuery);
}
public FunctionFilter buildFunctionContainsFilter(String columnName, String value) {
List<Selector> parameters = new ArrayList<>();
TableName tableName = new TableName("catalog", "table");
parameters.add(new ColumnSelector(new ColumnName(tableName, columnName)));
parameters.add(new StringSelector(value));
parameters.add(new StringSelector("100%"));
|
FunctionRelation function = new FunctionRelation(ESFunction.CONTAINS, parameters,tableName);
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/utils/IndexRequestBuilderCreatorExceptionTest.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
// public class ElasticSearchConnectionHandler extends ConnectionHandler {
//
// /**
// * Constructor.
// *
// * @param configuration the configuration.
// */
// public ElasticSearchConnectionHandler(IConfiguration configuration) {
// super(configuration);
// }
//
// /**
// * This method creates a elasticsearch connection.
// *
// * @param iCredentials the credentials to connect with the database.
// * @param connectorClusterConfig the cluster configuration.
// * @throws ConnectionException if the connection is not established.
// * @return a elasticsearch connection.
// */
// @Override
// @TimerJ
// protected Connection createNativeConnection(ICredentials iCredentials,
// ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
// Connection connection;
// if (isNodeClient(connectorClusterConfig)) {
// connection = new NodeConnection(iCredentials, connectorClusterConfig);
// }
// else {
// try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
// catch (ExecutionException exception){
// throw new ConnectionException("The connection could not be established", exception);
// }
// }
// if (!connection.isConnected()) {
// throw new ConnectionException("The connection could not be established");}
// return connection;
// }
//
// /**
// * Return true if the config says that the connection is nodeClient. false in other case.
// *
// * @param config the configuration.
// * @return true if is configure to be a node connection. False in other case.
// */
// @TimerJ
// private boolean isNodeClient(ConnectorClusterConfig config) {
// return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
// }
//
// }
|
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.connection.ElasticSearchConnectionHandler;
import com.stratio.crossdata.common.data.*;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.UnsupportedException;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.IndexMetadata;
import com.stratio.crossdata.common.metadata.TableMetadata;
import com.stratio.crossdata.common.statements.structures.Selector;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.engine.utils;
/**
* IndexRequestBuilderCreator Tester.
*
* @author <Authors name>
* @version 1.0
*/
public class IndexRequestBuilderCreatorExceptionTest {
private static final String CLUSTER_NAME = "CLUSTER NAME";
private static final String INDEX_NAME = "INDEX_NAME";
private static final String TYPE_NAME = "TYPE_NAME";
private TableName tableName = new TableName(INDEX_NAME, TYPE_NAME);
private static final String ROW_NAME = "row_name";
private static final String OTHER_ROW_NAME = "OTHER_ROW_NAME";
private static final String CELL_VALUE = "cell_value";
@Rule
public ExpectedException exception = ExpectedException.none();
IndexRequestBuilderCreator indexRequestBuilderCreator;
private LinkedHashMap<ColumnName, ColumnMetadata> columns = new LinkedHashMap<>();
private Map<Selector, Selector> options = new LinkedHashMap<>();
private Map<IndexName, IndexMetadata> indexes = new HashMap<IndexName, IndexMetadata>();
private ClusterName clusterRef = new ClusterName(CLUSTER_NAME);
private LinkedList<ColumnName> partitionKey = new LinkedList<ColumnName>();
private LinkedList<ColumnName> clusterKey = new LinkedList<ColumnName>();
@Mock
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
// public class ElasticSearchConnectionHandler extends ConnectionHandler {
//
// /**
// * Constructor.
// *
// * @param configuration the configuration.
// */
// public ElasticSearchConnectionHandler(IConfiguration configuration) {
// super(configuration);
// }
//
// /**
// * This method creates a elasticsearch connection.
// *
// * @param iCredentials the credentials to connect with the database.
// * @param connectorClusterConfig the cluster configuration.
// * @throws ConnectionException if the connection is not established.
// * @return a elasticsearch connection.
// */
// @Override
// @TimerJ
// protected Connection createNativeConnection(ICredentials iCredentials,
// ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
// Connection connection;
// if (isNodeClient(connectorClusterConfig)) {
// connection = new NodeConnection(iCredentials, connectorClusterConfig);
// }
// else {
// try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
// catch (ExecutionException exception){
// throw new ConnectionException("The connection could not be established", exception);
// }
// }
// if (!connection.isConnected()) {
// throw new ConnectionException("The connection could not be established");}
// return connection;
// }
//
// /**
// * Return true if the config says that the connection is nodeClient. false in other case.
// *
// * @param config the configuration.
// * @return true if is configure to be a node connection. False in other case.
// */
// @TimerJ
// private boolean isNodeClient(ConnectorClusterConfig config) {
// return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
// }
//
// }
// Path: connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/engine/utils/IndexRequestBuilderCreatorExceptionTest.java
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.connection.ElasticSearchConnectionHandler;
import com.stratio.crossdata.common.data.*;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.UnsupportedException;
import com.stratio.crossdata.common.metadata.ColumnMetadata;
import com.stratio.crossdata.common.metadata.IndexMetadata;
import com.stratio.crossdata.common.metadata.TableMetadata;
import com.stratio.crossdata.common.statements.structures.Selector;
import org.elasticsearch.action.index.IndexRequestBuilder;
import org.elasticsearch.client.Client;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.Map;
import static org.mockito.Mockito.when;
import static org.powermock.api.mockito.PowerMockito.mock;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.engine.utils;
/**
* IndexRequestBuilderCreator Tester.
*
* @author <Authors name>
* @version 1.0
*/
public class IndexRequestBuilderCreatorExceptionTest {
private static final String CLUSTER_NAME = "CLUSTER NAME";
private static final String INDEX_NAME = "INDEX_NAME";
private static final String TYPE_NAME = "TYPE_NAME";
private TableName tableName = new TableName(INDEX_NAME, TYPE_NAME);
private static final String ROW_NAME = "row_name";
private static final String OTHER_ROW_NAME = "OTHER_ROW_NAME";
private static final String CELL_VALUE = "cell_value";
@Rule
public ExpectedException exception = ExpectedException.none();
IndexRequestBuilderCreator indexRequestBuilderCreator;
private LinkedHashMap<ColumnName, ColumnMetadata> columns = new LinkedHashMap<>();
private Map<Selector, Selector> options = new LinkedHashMap<>();
private Map<IndexName, IndexMetadata> indexes = new HashMap<IndexName, IndexMetadata>();
private ClusterName clusterRef = new ClusterName(CLUSTER_NAME);
private LinkedList<ColumnName> partitionKey = new LinkedList<ColumnName>();
private LinkedList<ColumnName> clusterKey = new LinkedList<ColumnName>();
@Mock
|
private ElasticSearchConnectionHandler connectionHandler;
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/utils/QueryBuilderFactory.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/query/functions/ESFunction.java
// public abstract class ESFunction {
//
// public static final String CONTAINS = "contains";
// public static final String MATCH_PHRASE = "match_phrase";
// public static final String MULTI_MATCH = "multi_match";
// public static final String MATCH_PREFIX = "match_prefix";
// public static final String MULTI_MATCH_FUZZY = "multi_match_fuzzy";
// public static final String FUZZY = "fuzzy";
//
//
// /**
// * Function Name
// */
// private String name;
//
// /**
// * The function parameters.
// */
// private List<Selector> parameters;
//
// /**
// * Default constructor.
// *
// * @param name Function Name
// * @param paramareters function parameters.
// */
// protected ESFunction(String name, List<Selector> paramareters) {
// this.parameters = paramareters;
// this.name = name;
// }
//
// public List<Selector> getParameters() {
// return parameters;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Build a {@link org.elasticsearch.index.query.QueryBuilder} that satisfy this function.
// *
// * @return
// */
// public abstract QueryBuilder buildQuery() throws ExecutionException;
//
//
// /**
// * Builds a ESFunction using the FunctionRelation specification.cd
// * @param function
// * @return A ESFunction child.
// * @throws UnsupportedException is the FunctionRelation isn't supported.
// */
// public static ESFunction build(FunctionRelation function) throws UnsupportedException {
// List parameters = new ArrayList();
// parameters.addAll(function.getFunctionSelectors());
//
// switch(function.getFunctionName()){
// case CONTAINS:
// return new Match(parameters);
// case MATCH_PHRASE:
// return new MatchPhrase(parameters);
// case MULTI_MATCH:
// return new MultiMatch(parameters);
// case MATCH_PREFIX:
// return new MatchPrefix(parameters);
// case MULTI_MATCH_FUZZY:
// return new MultiMatchFuzzy(parameters);
// case FUZZY:
// return new Fuzzy(parameters);
// default:
// throw new UnsupportedException("The function [" + function.getFunctionName() + "] is not supported");
// }
// }
//
// /**
// * Checks function signature
// *
// * @param functionName function name
// * @param checkEmpty flag that indicates if empty values are allowed
// * @param expectedParameters expected number of parameters
// * @param expectedSignature expected function signature
// * @throws ExecutionException
// */
// public void validateFunctionSignature (String functionName, boolean checkEmpty, int expectedParameters, String expectedSignature)
// throws ExecutionException {
//
// if (null == parameters || parameters.size() != expectedParameters){
// throw new ExecutionException("Wrong number of parameters for \"" + functionName + "\" function. " +
// "Expected signature: " + expectedSignature + ".");
// }
// if (checkEmpty){
// for (Selector parameter : parameters) {
// if (null == parameter || parameter.getStringValue().trim().isEmpty()){
// throw new ExecutionException("Every parameter in \"" + functionName + "\" function must have a non empty value.");
// }
// }
// }
// }
// }
|
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.stratio.connector.commons.util.SelectorHelper;
import com.stratio.connector.elasticsearch.core.engine.query.functions.ESFunction;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.UnsupportedException;
import com.stratio.crossdata.common.logicalplan.Disjunction;
import com.stratio.crossdata.common.logicalplan.Filter;
import com.stratio.crossdata.common.logicalplan.FunctionFilter;
import com.stratio.crossdata.common.logicalplan.ITerm;
import com.stratio.crossdata.common.statements.structures.AbstractRelation;
import com.stratio.crossdata.common.statements.structures.Relation;
import org.elasticsearch.index.query.*;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.engine.utils;
/**
* The responsibility of this class is create a QueryBuilder.
* Created by jmgomez on 17/09/14.
*/
public class QueryBuilderFactory {
public QueryBuilder createBuilder(Collection<Filter> filters) throws ExecutionException, UnsupportedException {
return createBuilder(filters, new ArrayList<FunctionFilter>(), new ArrayList<Disjunction>());
}
/**
* Create a query builder.
*
* @param filters Match and rangeQuery Functions
* @return a queryBuilder. the queryBuilder.
* @throws ExecutionException if any error happens.
* @throws UnsupportedException if the operation is not supported.
*/
public QueryBuilder createBuilder(Collection<Filter> filters, Collection<FunctionFilter> functionFilters, Collection<Disjunction> disjunctions) throws ExecutionException, UnsupportedException {
QueryBuilder queryBuilder;
if (filters.isEmpty() && functionFilters.isEmpty() && disjunctions.isEmpty()) {
queryBuilder = QueryBuilders.matchAllQuery();
} else {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); //"bool" : {
for(FunctionFilter functionFilter: functionFilters){
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/query/functions/ESFunction.java
// public abstract class ESFunction {
//
// public static final String CONTAINS = "contains";
// public static final String MATCH_PHRASE = "match_phrase";
// public static final String MULTI_MATCH = "multi_match";
// public static final String MATCH_PREFIX = "match_prefix";
// public static final String MULTI_MATCH_FUZZY = "multi_match_fuzzy";
// public static final String FUZZY = "fuzzy";
//
//
// /**
// * Function Name
// */
// private String name;
//
// /**
// * The function parameters.
// */
// private List<Selector> parameters;
//
// /**
// * Default constructor.
// *
// * @param name Function Name
// * @param paramareters function parameters.
// */
// protected ESFunction(String name, List<Selector> paramareters) {
// this.parameters = paramareters;
// this.name = name;
// }
//
// public List<Selector> getParameters() {
// return parameters;
// }
//
// public String getName() {
// return name;
// }
//
// /**
// * Build a {@link org.elasticsearch.index.query.QueryBuilder} that satisfy this function.
// *
// * @return
// */
// public abstract QueryBuilder buildQuery() throws ExecutionException;
//
//
// /**
// * Builds a ESFunction using the FunctionRelation specification.cd
// * @param function
// * @return A ESFunction child.
// * @throws UnsupportedException is the FunctionRelation isn't supported.
// */
// public static ESFunction build(FunctionRelation function) throws UnsupportedException {
// List parameters = new ArrayList();
// parameters.addAll(function.getFunctionSelectors());
//
// switch(function.getFunctionName()){
// case CONTAINS:
// return new Match(parameters);
// case MATCH_PHRASE:
// return new MatchPhrase(parameters);
// case MULTI_MATCH:
// return new MultiMatch(parameters);
// case MATCH_PREFIX:
// return new MatchPrefix(parameters);
// case MULTI_MATCH_FUZZY:
// return new MultiMatchFuzzy(parameters);
// case FUZZY:
// return new Fuzzy(parameters);
// default:
// throw new UnsupportedException("The function [" + function.getFunctionName() + "] is not supported");
// }
// }
//
// /**
// * Checks function signature
// *
// * @param functionName function name
// * @param checkEmpty flag that indicates if empty values are allowed
// * @param expectedParameters expected number of parameters
// * @param expectedSignature expected function signature
// * @throws ExecutionException
// */
// public void validateFunctionSignature (String functionName, boolean checkEmpty, int expectedParameters, String expectedSignature)
// throws ExecutionException {
//
// if (null == parameters || parameters.size() != expectedParameters){
// throw new ExecutionException("Wrong number of parameters for \"" + functionName + "\" function. " +
// "Expected signature: " + expectedSignature + ".");
// }
// if (checkEmpty){
// for (Selector parameter : parameters) {
// if (null == parameter || parameter.getStringValue().trim().isEmpty()){
// throw new ExecutionException("Every parameter in \"" + functionName + "\" function must have a non empty value.");
// }
// }
// }
// }
// }
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/engine/utils/QueryBuilderFactory.java
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import com.stratio.connector.commons.util.SelectorHelper;
import com.stratio.connector.elasticsearch.core.engine.query.functions.ESFunction;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.exceptions.UnsupportedException;
import com.stratio.crossdata.common.logicalplan.Disjunction;
import com.stratio.crossdata.common.logicalplan.Filter;
import com.stratio.crossdata.common.logicalplan.FunctionFilter;
import com.stratio.crossdata.common.logicalplan.ITerm;
import com.stratio.crossdata.common.statements.structures.AbstractRelation;
import com.stratio.crossdata.common.statements.structures.Relation;
import org.elasticsearch.index.query.*;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.engine.utils;
/**
* The responsibility of this class is create a QueryBuilder.
* Created by jmgomez on 17/09/14.
*/
public class QueryBuilderFactory {
public QueryBuilder createBuilder(Collection<Filter> filters) throws ExecutionException, UnsupportedException {
return createBuilder(filters, new ArrayList<FunctionFilter>(), new ArrayList<Disjunction>());
}
/**
* Create a query builder.
*
* @param filters Match and rangeQuery Functions
* @return a queryBuilder. the queryBuilder.
* @throws ExecutionException if any error happens.
* @throws UnsupportedException if the operation is not supported.
*/
public QueryBuilder createBuilder(Collection<Filter> filters, Collection<FunctionFilter> functionFilters, Collection<Disjunction> disjunctions) throws ExecutionException, UnsupportedException {
QueryBuilder queryBuilder;
if (filters.isEmpty() && functionFilters.isEmpty() && disjunctions.isEmpty()) {
queryBuilder = QueryBuilders.matchAllQuery();
} else {
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); //"bool" : {
for(FunctionFilter functionFilter: functionFilters){
|
boolQueryBuilder.must(ESFunction.build(functionFilter.getRelation()).buildQuery());
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/TransportConnection.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/configuration/ElasticsearchClientConfiguration.java
// public final class ElasticsearchClientConfiguration {
//
// /**
// * Private constructor.
// */
// private ElasticsearchClientConfiguration() {
// }
//
// /**
// * Retrieves the Settings using either the Elasticsearch client configuration or the configuration file.
// *
// * @param configuration the configuration
// * @return the settings
// */
// public static Settings getSettings(ConnectorClusterConfig configuration) {
//
// Map<String, String> setting = new HashMap<String, String>();
// setting.put(NODE_DATA.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), NODE_DATA));
// setting.put(NODE_MASTER.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), NODE_MASTER));
// setting.put(TRANSPORT_SNIFF.getElasticSearchOption(),
// recoverdOptionValue(configuration.getConnectorOptions(), TRANSPORT_SNIFF));
// setting.put(COERCE.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), COERCE));
// setting.put(DYNAMIC.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), DYNAMIC));
//
// setting.put(CLUSTER_NAME.getElasticSearchOption(),recoverdOptionValue(configuration.getClusterOptions(), CLUSTER_NAME));
// return ImmutableSettings.settingsBuilder().put(setting).build();
//
// }
//
// /**
// * this recovered the option value if it is set. It not return the default value..
// *
// * @param configuration the configuration.
// * @param nodeData the configuration options.
// * @return the actual value of the option.
// */
// private static String recoverdOptionValue(Map<String, String> configuration, ConfigurationOptions nodeData) {
// String option;
// if (configuration.containsKey(nodeData.getManifestOption())) {
// option = configuration.get(nodeData.getManifestOption());
// } else {
// option = nodeData.getDefaultValue()[0];
// }
// return option;
// }
//
// /**
// * Gets the transport address.
// *
// * @param config the configuration options.
// * @return the transport address
// */
// public static TransportAddress[] getTransportAddress(ConnectorClusterConfig config) throws ExecutionException{
//
// String[] hosts = PropertyValueRecovered.recoveredValueASArray(String.class, config.getClusterOptions().get(HOST.getManifestOption()));
// String[] ports = PropertyValueRecovered.recoveredValueASArray(String.class, config.getClusterOptions().get(PORT.getManifestOption()));
// TransportAddress[] transportAddresses = new TransportAddress[hosts.length];
//
// for (int i = 0; i < hosts.length; i++) {
// transportAddresses[i] = new InetSocketTransportAddress(hosts[i], Integer.decode(ports[i]));
// }
//
// return transportAddresses;
//
// }
// }
|
import com.stratio.connector.commons.TimerJ;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.configuration.ElasticsearchClientConfiguration;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.security.ICredentials;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.connection;
/**
* This class represents a logic connection.
* Created by jmgomez on 28/08/14.
*/
public class TransportConnection extends Connection<Client> {
/**
* The Log.
*/
private final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* The Elasticsearch client.
*/
private Client elasticClient = null;
/**
* Constructor.
*
* @param credentiasl the credentials.
* @param config The cluster configuration.
*/
public TransportConnection(ICredentials credentiasl, ConnectorClusterConfig config) throws ExecutionException {
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/configuration/ElasticsearchClientConfiguration.java
// public final class ElasticsearchClientConfiguration {
//
// /**
// * Private constructor.
// */
// private ElasticsearchClientConfiguration() {
// }
//
// /**
// * Retrieves the Settings using either the Elasticsearch client configuration or the configuration file.
// *
// * @param configuration the configuration
// * @return the settings
// */
// public static Settings getSettings(ConnectorClusterConfig configuration) {
//
// Map<String, String> setting = new HashMap<String, String>();
// setting.put(NODE_DATA.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), NODE_DATA));
// setting.put(NODE_MASTER.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), NODE_MASTER));
// setting.put(TRANSPORT_SNIFF.getElasticSearchOption(),
// recoverdOptionValue(configuration.getConnectorOptions(), TRANSPORT_SNIFF));
// setting.put(COERCE.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), COERCE));
// setting.put(DYNAMIC.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), DYNAMIC));
//
// setting.put(CLUSTER_NAME.getElasticSearchOption(),recoverdOptionValue(configuration.getClusterOptions(), CLUSTER_NAME));
// return ImmutableSettings.settingsBuilder().put(setting).build();
//
// }
//
// /**
// * this recovered the option value if it is set. It not return the default value..
// *
// * @param configuration the configuration.
// * @param nodeData the configuration options.
// * @return the actual value of the option.
// */
// private static String recoverdOptionValue(Map<String, String> configuration, ConfigurationOptions nodeData) {
// String option;
// if (configuration.containsKey(nodeData.getManifestOption())) {
// option = configuration.get(nodeData.getManifestOption());
// } else {
// option = nodeData.getDefaultValue()[0];
// }
// return option;
// }
//
// /**
// * Gets the transport address.
// *
// * @param config the configuration options.
// * @return the transport address
// */
// public static TransportAddress[] getTransportAddress(ConnectorClusterConfig config) throws ExecutionException{
//
// String[] hosts = PropertyValueRecovered.recoveredValueASArray(String.class, config.getClusterOptions().get(HOST.getManifestOption()));
// String[] ports = PropertyValueRecovered.recoveredValueASArray(String.class, config.getClusterOptions().get(PORT.getManifestOption()));
// TransportAddress[] transportAddresses = new TransportAddress[hosts.length];
//
// for (int i = 0; i < hosts.length; i++) {
// transportAddresses[i] = new InetSocketTransportAddress(hosts[i], Integer.decode(ports[i]));
// }
//
// return transportAddresses;
//
// }
// }
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/TransportConnection.java
import com.stratio.connector.commons.TimerJ;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.configuration.ElasticsearchClientConfiguration;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.security.ICredentials;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.connection;
/**
* This class represents a logic connection.
* Created by jmgomez on 28/08/14.
*/
public class TransportConnection extends Connection<Client> {
/**
* The Log.
*/
private final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* The Elasticsearch client.
*/
private Client elasticClient = null;
/**
* Constructor.
*
* @param credentiasl the credentials.
* @param config The cluster configuration.
*/
public TransportConnection(ICredentials credentiasl, ConnectorClusterConfig config) throws ExecutionException {
|
elasticClient = new TransportClient(ElasticsearchClientConfiguration.getSettings(config))
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/configuration/ConfigurationOptions.java
// public enum ConfigurationOptions {
//
// /**
// * The elasticserach node type property.
// */
// NODE_TYPE("node_type", "node_type", Constants.FALSE),
// /**
// * The elasticserach node data property.
// */
// NODE_DATA("node.data", "node.data",Constants.FALSE),
// /**
// * The elasticserach node master property.
// */
// NODE_MASTER("node.master", "node.master",Constants.FALSE),
// /**
// * The elasticserach transfer sniff type property.
// */
// TRANSPORT_SNIFF("client.transport.sniff", "client.transport.sniff",Constants.TRUE),
// /**
// * The elastichseach cluser name.
// */
// CLUSTER_NAME("Cluster Name","cluster.name","", "clusterName"),
// /**
// * The hosts ip.
// */
// HOST("Hosts","Hosts", new String[] { "localhost" }),
// /**
// * The hosts ports.
// */
// PORT("Native Ports", "Native Ports",new String[] { "c" }),
// /**
// * The elasticsearch coerce property.
// */
// COERCE("index.mapping.coerce","index.mapping.coerce", Constants.FALSE),
// /**
// * The elasticsearch mapper dynamic property.
// */
// DYNAMIC("index.mapper.dynamic", "index.mapper.dynamic",Constants.FALSE);
//
// /**
// * The name of the option in crossdata manifest.
// */
// private final String manifestOption;
// /**
// * The default value of the options.
// */
// private final String[] defaultValue;
// /**
// * The option name in elasticsearch.
// */
// private final String elasticSearchOption;
//
// /**
// * Constructor.
// *
// * @param manifestOption the name of the option.
// * @param defaultValue the default value of the option.
// */
// ConfigurationOptions(String manifestOption, String elasticSearchOption, String... defaultValue) {
// this.manifestOption = manifestOption;
// this.defaultValue = defaultValue;
// this.elasticSearchOption = elasticSearchOption;
//
// }
//
// /**
// * return the default value.
// *
// * @return the default value.
// */
// public String[] getDefaultValue() {
// return defaultValue.clone();
// }
//
// /**
// * Return the option name defined in the manifest.
// *
// * @return the option name.
// */
// public String getManifestOption() {
// return manifestOption;
// }
//
//
//
// /**
// * Return the option name to ElasticSearch.
// *
// * @return the option name.
// */
// public String getElasticSearchOption() {
// return elasticSearchOption;
// }
//
// }
|
import com.stratio.connector.commons.TimerJ;
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.commons.connection.ConnectionHandler;
import com.stratio.connector.elasticsearch.core.configuration.ConfigurationOptions;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.connector.IConfiguration;
import com.stratio.crossdata.common.exceptions.ConnectionException;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.security.ICredentials;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.connection;
/**
* This class represents a elasticsearchs connetions handler.
* Created by jmgomez on 28/08/14.
*/
public class ElasticSearchConnectionHandler extends ConnectionHandler {
/**
* Constructor.
*
* @param configuration the configuration.
*/
public ElasticSearchConnectionHandler(IConfiguration configuration) {
super(configuration);
}
/**
* This method creates a elasticsearch connection.
*
* @param iCredentials the credentials to connect with the database.
* @param connectorClusterConfig the cluster configuration.
* @throws ConnectionException if the connection is not established.
* @return a elasticsearch connection.
*/
@Override
@TimerJ
protected Connection createNativeConnection(ICredentials iCredentials,
ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
Connection connection;
if (isNodeClient(connectorClusterConfig)) {
connection = new NodeConnection(iCredentials, connectorClusterConfig);
}
else {
try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
catch (ExecutionException exception){
throw new ConnectionException("The connection could not be established", exception);
}
}
if (!connection.isConnected()) {
throw new ConnectionException("The connection could not be established");}
return connection;
}
/**
* Return true if the config says that the connection is nodeClient. false in other case.
*
* @param config the configuration.
* @return true if is configure to be a node connection. False in other case.
*/
@TimerJ
private boolean isNodeClient(ConnectorClusterConfig config) {
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/configuration/ConfigurationOptions.java
// public enum ConfigurationOptions {
//
// /**
// * The elasticserach node type property.
// */
// NODE_TYPE("node_type", "node_type", Constants.FALSE),
// /**
// * The elasticserach node data property.
// */
// NODE_DATA("node.data", "node.data",Constants.FALSE),
// /**
// * The elasticserach node master property.
// */
// NODE_MASTER("node.master", "node.master",Constants.FALSE),
// /**
// * The elasticserach transfer sniff type property.
// */
// TRANSPORT_SNIFF("client.transport.sniff", "client.transport.sniff",Constants.TRUE),
// /**
// * The elastichseach cluser name.
// */
// CLUSTER_NAME("Cluster Name","cluster.name","", "clusterName"),
// /**
// * The hosts ip.
// */
// HOST("Hosts","Hosts", new String[] { "localhost" }),
// /**
// * The hosts ports.
// */
// PORT("Native Ports", "Native Ports",new String[] { "c" }),
// /**
// * The elasticsearch coerce property.
// */
// COERCE("index.mapping.coerce","index.mapping.coerce", Constants.FALSE),
// /**
// * The elasticsearch mapper dynamic property.
// */
// DYNAMIC("index.mapper.dynamic", "index.mapper.dynamic",Constants.FALSE);
//
// /**
// * The name of the option in crossdata manifest.
// */
// private final String manifestOption;
// /**
// * The default value of the options.
// */
// private final String[] defaultValue;
// /**
// * The option name in elasticsearch.
// */
// private final String elasticSearchOption;
//
// /**
// * Constructor.
// *
// * @param manifestOption the name of the option.
// * @param defaultValue the default value of the option.
// */
// ConfigurationOptions(String manifestOption, String elasticSearchOption, String... defaultValue) {
// this.manifestOption = manifestOption;
// this.defaultValue = defaultValue;
// this.elasticSearchOption = elasticSearchOption;
//
// }
//
// /**
// * return the default value.
// *
// * @return the default value.
// */
// public String[] getDefaultValue() {
// return defaultValue.clone();
// }
//
// /**
// * Return the option name defined in the manifest.
// *
// * @return the option name.
// */
// public String getManifestOption() {
// return manifestOption;
// }
//
//
//
// /**
// * Return the option name to ElasticSearch.
// *
// * @return the option name.
// */
// public String getElasticSearchOption() {
// return elasticSearchOption;
// }
//
// }
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
import com.stratio.connector.commons.TimerJ;
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.commons.connection.ConnectionHandler;
import com.stratio.connector.elasticsearch.core.configuration.ConfigurationOptions;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.connector.IConfiguration;
import com.stratio.crossdata.common.exceptions.ConnectionException;
import com.stratio.crossdata.common.exceptions.ExecutionException;
import com.stratio.crossdata.common.security.ICredentials;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.connection;
/**
* This class represents a elasticsearchs connetions handler.
* Created by jmgomez on 28/08/14.
*/
public class ElasticSearchConnectionHandler extends ConnectionHandler {
/**
* Constructor.
*
* @param configuration the configuration.
*/
public ElasticSearchConnectionHandler(IConfiguration configuration) {
super(configuration);
}
/**
* This method creates a elasticsearch connection.
*
* @param iCredentials the credentials to connect with the database.
* @param connectorClusterConfig the cluster configuration.
* @throws ConnectionException if the connection is not established.
* @return a elasticsearch connection.
*/
@Override
@TimerJ
protected Connection createNativeConnection(ICredentials iCredentials,
ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
Connection connection;
if (isNodeClient(connectorClusterConfig)) {
connection = new NodeConnection(iCredentials, connectorClusterConfig);
}
else {
try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
catch (ExecutionException exception){
throw new ConnectionException("The connection could not be established", exception);
}
}
if (!connection.isConnected()) {
throw new ConnectionException("The connection could not be established");}
return connection;
}
/**
* Return true if the config says that the connection is nodeClient. false in other case.
*
* @param config the configuration.
* @return true if is configure to be a node connection. False in other case.
*/
@TimerJ
private boolean isNodeClient(ConnectorClusterConfig config) {
|
return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/ElasticsearchConnectorTest.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
// public class ElasticSearchConnectionHandler extends ConnectionHandler {
//
// /**
// * Constructor.
// *
// * @param configuration the configuration.
// */
// public ElasticSearchConnectionHandler(IConfiguration configuration) {
// super(configuration);
// }
//
// /**
// * This method creates a elasticsearch connection.
// *
// * @param iCredentials the credentials to connect with the database.
// * @param connectorClusterConfig the cluster configuration.
// * @throws ConnectionException if the connection is not established.
// * @return a elasticsearch connection.
// */
// @Override
// @TimerJ
// protected Connection createNativeConnection(ICredentials iCredentials,
// ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
// Connection connection;
// if (isNodeClient(connectorClusterConfig)) {
// connection = new NodeConnection(iCredentials, connectorClusterConfig);
// }
// else {
// try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
// catch (ExecutionException exception){
// throw new ConnectionException("The connection could not be established", exception);
// }
// }
// if (!connection.isConnected()) {
// throw new ConnectionException("The connection could not be established");}
// return connection;
// }
//
// /**
// * Return true if the config says that the connection is nodeClient. false in other case.
// *
// * @param config the configuration.
// * @return true if is configure to be a node connection. False in other case.
// */
// @TimerJ
// private boolean isNodeClient(ConnectorClusterConfig config) {
// return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
// }
//
// }
//
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/NodeConnection.java
// public class NodeConnection extends Connection<Client> {
//
// /**
// * The Log.
// */
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
//
// /**
// * The Elasticsearch client.
// */
// private Client elasticClient = null;
//
// /**
// * The elasticsearch node connection.
// */
// private Node node = null;
//
//
// /**
// * Store the connection name.
// */
// private String connectionName;
//
// /**
// * Constructor.
// *
// * @param credentials the credentials.
// * @param config The cluster configuration.
// */
// public NodeConnection(ICredentials credentials, ConnectorClusterConfig config) {
// NodeBuilder nodeBuilder = nodeBuilder();
//
// node = nodeBuilder.settings(ElasticsearchClientConfiguration.getSettings(config)).node();
// elasticClient = node.client();
//
// connectionName = config.getName().getName();
// logger.info("Elasticsearch Node connection established ");
//
// }
//
// /**
// * Close the connection.
// */
// @TimerJ
// public void close() {
// if (node != null) {
// node.close();
// node = null;
// elasticClient = null;
// logger.info("ElasticSearch connection [" + connectionName + "] close");
// }
//
// }
//
// /**
// * Retun the connection status.
// *
// * @return true if the connection is open. False in other case.
// */
// @Override
// @TimerJ
// public boolean isConnected() {
// return (node!=null && !node.isClosed());
// }
//
// /**
// * Return the native connection.
// *
// * @return the native connection.
// */
// @Override
// @TimerJ
// public Client getNativeConnection() {
// return elasticClient;
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.*;
import com.stratio.connector.elasticsearch.core.connection.ElasticSearchConnectionHandler;
import com.stratio.connector.elasticsearch.core.connection.NodeConnection;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.security.ICredentials;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.internal.util.reflection.Whitebox;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core;
/**
* ElasticsearchConnector Tester.
*
* @author <Authors name>
* @version 1.0
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(value = { NodeConnection.class, ElasticsearchConnector.class })
public class ElasticsearchConnectorTest {
private static final String CLUSTER_NAME = "CLUSTER_NAME";
private ElasticsearchConnector elasticsearchConnector = null;
@Before
public void before() throws Exception {
elasticsearchConnector = new ElasticsearchConnector();
}
@After
public void after() throws Exception {
}
/**
* Method: init(IConfiguration configuration)
*/
/**
* Method: close()
*/
@Test
public void testConnect() throws Exception {
ICredentials iCredentials = mock(ICredentials.class);
ClusterName clusterName = new ClusterName(CLUSTER_NAME);
Map<String, String> connectorOptions = new HashMap<>();
Map<String, String> clusterOptions = new HashMap<>();
ConnectorClusterConfig config = new ConnectorClusterConfig(clusterName, connectorOptions, clusterOptions);
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/ElasticSearchConnectionHandler.java
// public class ElasticSearchConnectionHandler extends ConnectionHandler {
//
// /**
// * Constructor.
// *
// * @param configuration the configuration.
// */
// public ElasticSearchConnectionHandler(IConfiguration configuration) {
// super(configuration);
// }
//
// /**
// * This method creates a elasticsearch connection.
// *
// * @param iCredentials the credentials to connect with the database.
// * @param connectorClusterConfig the cluster configuration.
// * @throws ConnectionException if the connection is not established.
// * @return a elasticsearch connection.
// */
// @Override
// @TimerJ
// protected Connection createNativeConnection(ICredentials iCredentials,
// ConnectorClusterConfig connectorClusterConfig) throws ConnectionException {
// Connection connection;
// if (isNodeClient(connectorClusterConfig)) {
// connection = new NodeConnection(iCredentials, connectorClusterConfig);
// }
// else {
// try {connection = new TransportConnection(iCredentials, connectorClusterConfig);}
// catch (ExecutionException exception){
// throw new ConnectionException("The connection could not be established", exception);
// }
// }
// if (!connection.isConnected()) {
// throw new ConnectionException("The connection could not be established");}
// return connection;
// }
//
// /**
// * Return true if the config says that the connection is nodeClient. false in other case.
// *
// * @param config the configuration.
// * @return true if is configure to be a node connection. False in other case.
// */
// @TimerJ
// private boolean isNodeClient(ConnectorClusterConfig config) {
// return Boolean.parseBoolean(config.getConnectorOptions().get(ConfigurationOptions.NODE_TYPE.getManifestOption()));
// }
//
// }
//
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/NodeConnection.java
// public class NodeConnection extends Connection<Client> {
//
// /**
// * The Log.
// */
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
//
// /**
// * The Elasticsearch client.
// */
// private Client elasticClient = null;
//
// /**
// * The elasticsearch node connection.
// */
// private Node node = null;
//
//
// /**
// * Store the connection name.
// */
// private String connectionName;
//
// /**
// * Constructor.
// *
// * @param credentials the credentials.
// * @param config The cluster configuration.
// */
// public NodeConnection(ICredentials credentials, ConnectorClusterConfig config) {
// NodeBuilder nodeBuilder = nodeBuilder();
//
// node = nodeBuilder.settings(ElasticsearchClientConfiguration.getSettings(config)).node();
// elasticClient = node.client();
//
// connectionName = config.getName().getName();
// logger.info("Elasticsearch Node connection established ");
//
// }
//
// /**
// * Close the connection.
// */
// @TimerJ
// public void close() {
// if (node != null) {
// node.close();
// node = null;
// elasticClient = null;
// logger.info("ElasticSearch connection [" + connectionName + "] close");
// }
//
// }
//
// /**
// * Retun the connection status.
// *
// * @return true if the connection is open. False in other case.
// */
// @Override
// @TimerJ
// public boolean isConnected() {
// return (node!=null && !node.isClosed());
// }
//
// /**
// * Return the native connection.
// *
// * @return the native connection.
// */
// @Override
// @TimerJ
// public Client getNativeConnection() {
// return elasticClient;
// }
//
// }
// Path: connector-elasticsearch/src/test/java/com/stratio/connector/elasticsearch/core/ElasticsearchConnectorTest.java
import java.util.HashMap;
import java.util.Map;
import static org.mockito.Mockito.*;
import com.stratio.connector.elasticsearch.core.connection.ElasticSearchConnectionHandler;
import com.stratio.connector.elasticsearch.core.connection.NodeConnection;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
import com.stratio.crossdata.common.data.ClusterName;
import com.stratio.crossdata.common.security.ICredentials;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.internal.util.reflection.Whitebox;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core;
/**
* ElasticsearchConnector Tester.
*
* @author <Authors name>
* @version 1.0
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest(value = { NodeConnection.class, ElasticsearchConnector.class })
public class ElasticsearchConnectorTest {
private static final String CLUSTER_NAME = "CLUSTER_NAME";
private ElasticsearchConnector elasticsearchConnector = null;
@Before
public void before() throws Exception {
elasticsearchConnector = new ElasticsearchConnector();
}
@After
public void after() throws Exception {
}
/**
* Method: init(IConfiguration configuration)
*/
/**
* Method: close()
*/
@Test
public void testConnect() throws Exception {
ICredentials iCredentials = mock(ICredentials.class);
ClusterName clusterName = new ClusterName(CLUSTER_NAME);
Map<String, String> connectorOptions = new HashMap<>();
Map<String, String> clusterOptions = new HashMap<>();
ConnectorClusterConfig config = new ConnectorClusterConfig(clusterName, connectorOptions, clusterOptions);
|
ElasticSearchConnectionHandler connectionHandle = mock(ElasticSearchConnectionHandler.class);
|
Stratio/stratio-connector-elasticsearch
|
connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/NodeConnection.java
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/configuration/ElasticsearchClientConfiguration.java
// public final class ElasticsearchClientConfiguration {
//
// /**
// * Private constructor.
// */
// private ElasticsearchClientConfiguration() {
// }
//
// /**
// * Retrieves the Settings using either the Elasticsearch client configuration or the configuration file.
// *
// * @param configuration the configuration
// * @return the settings
// */
// public static Settings getSettings(ConnectorClusterConfig configuration) {
//
// Map<String, String> setting = new HashMap<String, String>();
// setting.put(NODE_DATA.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), NODE_DATA));
// setting.put(NODE_MASTER.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), NODE_MASTER));
// setting.put(TRANSPORT_SNIFF.getElasticSearchOption(),
// recoverdOptionValue(configuration.getConnectorOptions(), TRANSPORT_SNIFF));
// setting.put(COERCE.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), COERCE));
// setting.put(DYNAMIC.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), DYNAMIC));
//
// setting.put(CLUSTER_NAME.getElasticSearchOption(),recoverdOptionValue(configuration.getClusterOptions(), CLUSTER_NAME));
// return ImmutableSettings.settingsBuilder().put(setting).build();
//
// }
//
// /**
// * this recovered the option value if it is set. It not return the default value..
// *
// * @param configuration the configuration.
// * @param nodeData the configuration options.
// * @return the actual value of the option.
// */
// private static String recoverdOptionValue(Map<String, String> configuration, ConfigurationOptions nodeData) {
// String option;
// if (configuration.containsKey(nodeData.getManifestOption())) {
// option = configuration.get(nodeData.getManifestOption());
// } else {
// option = nodeData.getDefaultValue()[0];
// }
// return option;
// }
//
// /**
// * Gets the transport address.
// *
// * @param config the configuration options.
// * @return the transport address
// */
// public static TransportAddress[] getTransportAddress(ConnectorClusterConfig config) throws ExecutionException{
//
// String[] hosts = PropertyValueRecovered.recoveredValueASArray(String.class, config.getClusterOptions().get(HOST.getManifestOption()));
// String[] ports = PropertyValueRecovered.recoveredValueASArray(String.class, config.getClusterOptions().get(PORT.getManifestOption()));
// TransportAddress[] transportAddresses = new TransportAddress[hosts.length];
//
// for (int i = 0; i < hosts.length; i++) {
// transportAddresses[i] = new InetSocketTransportAddress(hosts[i], Integer.decode(ports[i]));
// }
//
// return transportAddresses;
//
// }
// }
|
import com.stratio.crossdata.common.security.ICredentials;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import com.stratio.connector.commons.TimerJ;
import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.configuration.ElasticsearchClientConfiguration;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
|
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.connection;
/**
* This class represents a logic connection.
* Created by jmgomez on 28/08/14.
*/
public class NodeConnection extends Connection<Client> {
/**
* The Log.
*/
private final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* The Elasticsearch client.
*/
private Client elasticClient = null;
/**
* The elasticsearch node connection.
*/
private Node node = null;
/**
* Store the connection name.
*/
private String connectionName;
/**
* Constructor.
*
* @param credentials the credentials.
* @param config The cluster configuration.
*/
public NodeConnection(ICredentials credentials, ConnectorClusterConfig config) {
NodeBuilder nodeBuilder = nodeBuilder();
|
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/configuration/ElasticsearchClientConfiguration.java
// public final class ElasticsearchClientConfiguration {
//
// /**
// * Private constructor.
// */
// private ElasticsearchClientConfiguration() {
// }
//
// /**
// * Retrieves the Settings using either the Elasticsearch client configuration or the configuration file.
// *
// * @param configuration the configuration
// * @return the settings
// */
// public static Settings getSettings(ConnectorClusterConfig configuration) {
//
// Map<String, String> setting = new HashMap<String, String>();
// setting.put(NODE_DATA.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), NODE_DATA));
// setting.put(NODE_MASTER.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), NODE_MASTER));
// setting.put(TRANSPORT_SNIFF.getElasticSearchOption(),
// recoverdOptionValue(configuration.getConnectorOptions(), TRANSPORT_SNIFF));
// setting.put(COERCE.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), COERCE));
// setting.put(DYNAMIC.getElasticSearchOption(), recoverdOptionValue(configuration.getConnectorOptions(), DYNAMIC));
//
// setting.put(CLUSTER_NAME.getElasticSearchOption(),recoverdOptionValue(configuration.getClusterOptions(), CLUSTER_NAME));
// return ImmutableSettings.settingsBuilder().put(setting).build();
//
// }
//
// /**
// * this recovered the option value if it is set. It not return the default value..
// *
// * @param configuration the configuration.
// * @param nodeData the configuration options.
// * @return the actual value of the option.
// */
// private static String recoverdOptionValue(Map<String, String> configuration, ConfigurationOptions nodeData) {
// String option;
// if (configuration.containsKey(nodeData.getManifestOption())) {
// option = configuration.get(nodeData.getManifestOption());
// } else {
// option = nodeData.getDefaultValue()[0];
// }
// return option;
// }
//
// /**
// * Gets the transport address.
// *
// * @param config the configuration options.
// * @return the transport address
// */
// public static TransportAddress[] getTransportAddress(ConnectorClusterConfig config) throws ExecutionException{
//
// String[] hosts = PropertyValueRecovered.recoveredValueASArray(String.class, config.getClusterOptions().get(HOST.getManifestOption()));
// String[] ports = PropertyValueRecovered.recoveredValueASArray(String.class, config.getClusterOptions().get(PORT.getManifestOption()));
// TransportAddress[] transportAddresses = new TransportAddress[hosts.length];
//
// for (int i = 0; i < hosts.length; i++) {
// transportAddresses[i] = new InetSocketTransportAddress(hosts[i], Integer.decode(ports[i]));
// }
//
// return transportAddresses;
//
// }
// }
// Path: connector-elasticsearch/src/main/java/com/stratio/connector/elasticsearch/core/connection/NodeConnection.java
import com.stratio.crossdata.common.security.ICredentials;
import static org.elasticsearch.node.NodeBuilder.nodeBuilder;
import com.stratio.connector.commons.TimerJ;
import org.elasticsearch.client.Client;
import org.elasticsearch.node.Node;
import org.elasticsearch.node.NodeBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.stratio.connector.commons.connection.Connection;
import com.stratio.connector.elasticsearch.core.configuration.ElasticsearchClientConfiguration;
import com.stratio.crossdata.common.connector.ConnectorClusterConfig;
/*
* Licensed to STRATIO (C) under one or more contributor license agreements.
* See the NOTICE file distributed with this work for additional information
* regarding copyright ownership. The STRATIO (C) licenses this file
* to you 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.stratio.connector.elasticsearch.core.connection;
/**
* This class represents a logic connection.
* Created by jmgomez on 28/08/14.
*/
public class NodeConnection extends Connection<Client> {
/**
* The Log.
*/
private final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* The Elasticsearch client.
*/
private Client elasticClient = null;
/**
* The elasticsearch node connection.
*/
private Node node = null;
/**
* Store the connection name.
*/
private String connectionName;
/**
* Constructor.
*
* @param credentials the credentials.
* @param config The cluster configuration.
*/
public NodeConnection(ICredentials credentials, ConnectorClusterConfig config) {
NodeBuilder nodeBuilder = nodeBuilder();
|
node = nodeBuilder.settings(ElasticsearchClientConfiguration.getSettings(config)).node();
|
patrickfav/density-converter
|
src/main/java/at/favre/tools/dconvert/converters/postprocessing/APostProcessor.java
|
// Path: src/main/java/at/favre/tools/dconvert/converters/Result.java
// public class Result {
// public final Exception exception;
// public final List<File> processedFiles;
// public final String log;
//
// public Result(String log, Exception exception, List<File> processedFiles) {
// this.log = log;
// this.exception = exception;
// this.processedFiles = processedFiles;
// }
//
// public Result(String log, List<File> processedFiles) {
// this(log, null, processedFiles);
// }
// }
|
import at.favre.tools.dconvert.converters.Result;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
|
/*
* Copyright 2016 Patrick Favre-Bulle
*
* 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 at.favre.tools.dconvert.converters.postprocessing;
/**
* Shared code among {@link IPostProcessor}.
* <p>
* This helps to synchronize processors: will create a lock for each input file,
* so that only 1 processor can process a file at a time
*/
public abstract class APostProcessor implements IPostProcessor {
private static Map<File, ReentrantLock> lockMap = new ConcurrentHashMap<>();
private static ReentrantLock administrationLock = new ReentrantLock(true);
@Override
|
// Path: src/main/java/at/favre/tools/dconvert/converters/Result.java
// public class Result {
// public final Exception exception;
// public final List<File> processedFiles;
// public final String log;
//
// public Result(String log, Exception exception, List<File> processedFiles) {
// this.log = log;
// this.exception = exception;
// this.processedFiles = processedFiles;
// }
//
// public Result(String log, List<File> processedFiles) {
// this(log, null, processedFiles);
// }
// }
// Path: src/main/java/at/favre/tools/dconvert/converters/postprocessing/APostProcessor.java
import at.favre.tools.dconvert.converters.Result;
import java.io.File;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.ReentrantLock;
/*
* Copyright 2016 Patrick Favre-Bulle
*
* 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 at.favre.tools.dconvert.converters.postprocessing;
/**
* Shared code among {@link IPostProcessor}.
* <p>
* This helps to synchronize processors: will create a lock for each input file,
* so that only 1 processor can process a file at a time
*/
public abstract class APostProcessor implements IPostProcessor {
private static Map<File, ReentrantLock> lockMap = new ConcurrentHashMap<>();
private static ReentrantLock administrationLock = new ReentrantLock(true);
@Override
|
public Result process(File rawFile, boolean keepOriginal) {
|
patrickfav/density-converter
|
src/main/java/at/favre/tools/dconvert/converters/postprocessing/IPostProcessor.java
|
// Path: src/main/java/at/favre/tools/dconvert/converters/Result.java
// public class Result {
// public final Exception exception;
// public final List<File> processedFiles;
// public final String log;
//
// public Result(String log, Exception exception, List<File> processedFiles) {
// this.log = log;
// this.exception = exception;
// this.processedFiles = processedFiles;
// }
//
// public Result(String log, List<File> processedFiles) {
// this(log, null, processedFiles);
// }
// }
|
import at.favre.tools.dconvert.converters.Result;
import java.io.File;
|
/*
* Copyright 2016 Patrick Favre-Bulle
*
* 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 at.favre.tools.dconvert.converters.postprocessing;
/**
* PostProcessor run after the main conversation on all files
*/
public interface IPostProcessor {
String ORIG_POSTFIX = "_orig";
/**
* Will process the given file. It is not necessary to spawn another thread for exectution
*
* @param rawFile to process
* @param keepOriginal if true will not delete unprocessed file, but renames it to (filename)_orig.(extension)
* @return optional log or output
*/
|
// Path: src/main/java/at/favre/tools/dconvert/converters/Result.java
// public class Result {
// public final Exception exception;
// public final List<File> processedFiles;
// public final String log;
//
// public Result(String log, Exception exception, List<File> processedFiles) {
// this.log = log;
// this.exception = exception;
// this.processedFiles = processedFiles;
// }
//
// public Result(String log, List<File> processedFiles) {
// this(log, null, processedFiles);
// }
// }
// Path: src/main/java/at/favre/tools/dconvert/converters/postprocessing/IPostProcessor.java
import at.favre.tools.dconvert.converters.Result;
import java.io.File;
/*
* Copyright 2016 Patrick Favre-Bulle
*
* 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 at.favre.tools.dconvert.converters.postprocessing;
/**
* PostProcessor run after the main conversation on all files
*/
public interface IPostProcessor {
String ORIG_POSTFIX = "_orig";
/**
* Will process the given file. It is not necessary to spawn another thread for exectution
*
* @param rawFile to process
* @param keepOriginal if true will not delete unprocessed file, but renames it to (filename)_orig.(extension)
* @return optional log or output
*/
|
Result process(File rawFile, boolean keepOriginal);
|
patrickfav/density-converter
|
src/test/java/at/favre/tools/dconvert/test/helper/MockProcessor.java
|
// Path: src/main/java/at/favre/tools/dconvert/converters/Result.java
// public class Result {
// public final Exception exception;
// public final List<File> processedFiles;
// public final String log;
//
// public Result(String log, Exception exception, List<File> processedFiles) {
// this.log = log;
// this.exception = exception;
// this.processedFiles = processedFiles;
// }
//
// public Result(String log, List<File> processedFiles) {
// this(log, null, processedFiles);
// }
// }
//
// Path: src/main/java/at/favre/tools/dconvert/converters/postprocessing/IPostProcessor.java
// public interface IPostProcessor {
// String ORIG_POSTFIX = "_orig";
//
// /**
// * Will process the given file. It is not necessary to spawn another thread for exectution
// *
// * @param rawFile to process
// * @param keepOriginal if true will not delete unprocessed file, but renames it to (filename)_orig.(extension)
// * @return optional log or output
// */
// Result process(File rawFile, boolean keepOriginal);
//
// /**
// * @return true if this processor is supported with the current setup (e.g. tool is set in PATH)
// */
// boolean isSupported();
// }
|
import at.favre.tools.dconvert.converters.Result;
import at.favre.tools.dconvert.converters.postprocessing.IPostProcessor;
import org.junit.Ignore;
import java.io.File;
import java.util.Collections;
|
package at.favre.tools.dconvert.test.helper;
/**
* For testing worker handlers
*/
@Ignore
public class MockProcessor implements IPostProcessor {
private long sleep = 66;
private Exception exception = null;
public MockProcessor() {
}
public MockProcessor(long sleep) {
this.sleep = sleep;
}
public MockProcessor(Exception exception) {
this.exception = exception;
}
@Override
|
// Path: src/main/java/at/favre/tools/dconvert/converters/Result.java
// public class Result {
// public final Exception exception;
// public final List<File> processedFiles;
// public final String log;
//
// public Result(String log, Exception exception, List<File> processedFiles) {
// this.log = log;
// this.exception = exception;
// this.processedFiles = processedFiles;
// }
//
// public Result(String log, List<File> processedFiles) {
// this(log, null, processedFiles);
// }
// }
//
// Path: src/main/java/at/favre/tools/dconvert/converters/postprocessing/IPostProcessor.java
// public interface IPostProcessor {
// String ORIG_POSTFIX = "_orig";
//
// /**
// * Will process the given file. It is not necessary to spawn another thread for exectution
// *
// * @param rawFile to process
// * @param keepOriginal if true will not delete unprocessed file, but renames it to (filename)_orig.(extension)
// * @return optional log or output
// */
// Result process(File rawFile, boolean keepOriginal);
//
// /**
// * @return true if this processor is supported with the current setup (e.g. tool is set in PATH)
// */
// boolean isSupported();
// }
// Path: src/test/java/at/favre/tools/dconvert/test/helper/MockProcessor.java
import at.favre.tools.dconvert.converters.Result;
import at.favre.tools.dconvert.converters.postprocessing.IPostProcessor;
import org.junit.Ignore;
import java.io.File;
import java.util.Collections;
package at.favre.tools.dconvert.test.helper;
/**
* For testing worker handlers
*/
@Ignore
public class MockProcessor implements IPostProcessor {
private long sleep = 66;
private Exception exception = null;
public MockProcessor() {
}
public MockProcessor(long sleep) {
this.sleep = sleep;
}
public MockProcessor(Exception exception) {
this.exception = exception;
}
@Override
|
public Result process(File rawFile, boolean keepOriginal) {
|
patrickfav/density-converter
|
src/main/java/at/favre/tools/dconvert/arg/Arguments.java
|
// Path: src/main/java/at/favre/tools/dconvert/exceptions/InvalidArgumentException.java
// public class InvalidArgumentException extends Exception {
// public InvalidArgumentException(String message) {
// super(message);
// }
//
// public InvalidArgumentException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/at/favre/tools/dconvert/util/MiscUtil.java
// public final class MiscUtil {
// private MiscUtil() {
// }
//
// public static String getStackTrace(Throwable t) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// t.printStackTrace(pw);
// return sw.toString();
// }
//
// public static String duration(long ms) {
// if (ms >= 1000) {
// return String.format(Locale.US, "%.2f sec", (double) ms / 1000);
// }
// return ms + " ms";
// }
//
// public static <T> T[] concat(T[] first, T[] second) {
// T[] result = Arrays.copyOf(first, first.length + second.length);
// System.arraycopy(second, 0, result, first.length, second.length);
// return result;
// }
//
// public static File createAndCheckFolder(String path, boolean dryRun) {
// File f = new File(path);
//
// if (dryRun) {
// return f;
// }
//
// if (!f.exists()) {
// f.mkdirs();
// }
//
// if (!f.exists() || !f.isDirectory()) {
// throw new IllegalStateException("could not create folder: " + path);
// }
// return f;
// }
//
// public static String getFileExtensionLowerCase(File file) {
// return getFileExtension(file).toLowerCase();
// }
//
// public static String getFileExtension(File file) {
// if (file == null) {
// return "";
// }
// return file.getName().substring(file.getName().lastIndexOf(".") + 1);
// }
//
// public static String getFileNameWithoutExtension(File file) {
// String fileName = file.getName();
// int pos = fileName.lastIndexOf(".");
// if (pos > 0) {
// fileName = fileName.substring(0, pos);
// }
// return fileName;
// }
//
// public static String getCmdProgressBar(float progress) {
// int loadingBarCount = 40;
// int bars = Math.round((float) loadingBarCount * progress);
// StringBuilder sb = new StringBuilder("\r[");
//
// for (int i = 0; i < loadingBarCount; i++) {
// if (i < bars) {
// sb.append("-");
// } else {
// sb.append(" ");
// }
// }
// sb.append("] ");
//
// if (progress < 1f) {
// sb.append(String.format("%6s", String.format(Locale.US, "%.2f", progress * 100f))).append("%");
// } else {
// sb.append("100.00%\n");
// }
//
// return sb.toString();
// }
//
// public static <T> Set<T> toSet(T elem) {
// Set<T> set = new HashSet<>(1);
// set.add(elem);
// return set;
// }
//
// public static void deleteFolder(File folder) {
// if (folder != null && folder.exists()) {
// File[] files = folder.listFiles();
// if (files != null) { //some JVMs return null for empty dirs
// for (File f : files) {
// if (f.isDirectory()) {
// deleteFolder(f);
// } else {
// f.delete();
// }
// }
// }
// folder.delete();
// }
// }
// }
|
import at.favre.tools.dconvert.exceptions.InvalidArgumentException;
import at.favre.tools.dconvert.util.MiscUtil;
import java.io.File;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.*;
|
this.platform = platform;
this.outputCompressionMode = outputCompressionMode;
this.scaleMode = scaleMode;
this.downScalingAlgorithm = downScalingAlgorithm;
this.upScalingAlgorithm = upScalingAlgorithm;
this.compressionQuality = compressionQuality;
this.threadCount = threadCount;
this.skipExistingFiles = skipExistingFiles;
this.skipUpscaling = skipUpscaling;
this.verboseLog = verboseLog;
this.includeAndroidLdpiTvdpi = includeAndroidLdpiTvdpi;
this.haltOnError = haltOnError;
this.createMipMapInsteadOfDrawableDir = createMipMapInsteadOfDrawableDir;
this.iosCreateImagesetFolders = iosCreateImagesetFolders;
this.enablePngCrush = enablePngCrush;
this.enableMozJpeg = enableMozJpeg;
this.postConvertWebp = postConvertWebp;
this.enableAntiAliasing = enableAntiAliasing;
this.dryRun = dryRun;
this.keepUnoptimizedFilesPostProcessor = keepUnoptimizedFilesPostProcessor;
this.roundingHandler = roundingHandler;
this.guiAdvancedOptions = guiAdvancedOptions;
this.clearDirBeforeConvert = clearDirBeforeConvert;
this.filesToProcess = new ArrayList<>();
Set<String> supportedFileTypes = getSupportedFileTypes();
if (src != null && src.isDirectory()) {
for (File file : src.listFiles()) {
|
// Path: src/main/java/at/favre/tools/dconvert/exceptions/InvalidArgumentException.java
// public class InvalidArgumentException extends Exception {
// public InvalidArgumentException(String message) {
// super(message);
// }
//
// public InvalidArgumentException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/at/favre/tools/dconvert/util/MiscUtil.java
// public final class MiscUtil {
// private MiscUtil() {
// }
//
// public static String getStackTrace(Throwable t) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// t.printStackTrace(pw);
// return sw.toString();
// }
//
// public static String duration(long ms) {
// if (ms >= 1000) {
// return String.format(Locale.US, "%.2f sec", (double) ms / 1000);
// }
// return ms + " ms";
// }
//
// public static <T> T[] concat(T[] first, T[] second) {
// T[] result = Arrays.copyOf(first, first.length + second.length);
// System.arraycopy(second, 0, result, first.length, second.length);
// return result;
// }
//
// public static File createAndCheckFolder(String path, boolean dryRun) {
// File f = new File(path);
//
// if (dryRun) {
// return f;
// }
//
// if (!f.exists()) {
// f.mkdirs();
// }
//
// if (!f.exists() || !f.isDirectory()) {
// throw new IllegalStateException("could not create folder: " + path);
// }
// return f;
// }
//
// public static String getFileExtensionLowerCase(File file) {
// return getFileExtension(file).toLowerCase();
// }
//
// public static String getFileExtension(File file) {
// if (file == null) {
// return "";
// }
// return file.getName().substring(file.getName().lastIndexOf(".") + 1);
// }
//
// public static String getFileNameWithoutExtension(File file) {
// String fileName = file.getName();
// int pos = fileName.lastIndexOf(".");
// if (pos > 0) {
// fileName = fileName.substring(0, pos);
// }
// return fileName;
// }
//
// public static String getCmdProgressBar(float progress) {
// int loadingBarCount = 40;
// int bars = Math.round((float) loadingBarCount * progress);
// StringBuilder sb = new StringBuilder("\r[");
//
// for (int i = 0; i < loadingBarCount; i++) {
// if (i < bars) {
// sb.append("-");
// } else {
// sb.append(" ");
// }
// }
// sb.append("] ");
//
// if (progress < 1f) {
// sb.append(String.format("%6s", String.format(Locale.US, "%.2f", progress * 100f))).append("%");
// } else {
// sb.append("100.00%\n");
// }
//
// return sb.toString();
// }
//
// public static <T> Set<T> toSet(T elem) {
// Set<T> set = new HashSet<>(1);
// set.add(elem);
// return set;
// }
//
// public static void deleteFolder(File folder) {
// if (folder != null && folder.exists()) {
// File[] files = folder.listFiles();
// if (files != null) { //some JVMs return null for empty dirs
// for (File f : files) {
// if (f.isDirectory()) {
// deleteFolder(f);
// } else {
// f.delete();
// }
// }
// }
// folder.delete();
// }
// }
// }
// Path: src/main/java/at/favre/tools/dconvert/arg/Arguments.java
import at.favre.tools.dconvert.exceptions.InvalidArgumentException;
import at.favre.tools.dconvert.util.MiscUtil;
import java.io.File;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.*;
this.platform = platform;
this.outputCompressionMode = outputCompressionMode;
this.scaleMode = scaleMode;
this.downScalingAlgorithm = downScalingAlgorithm;
this.upScalingAlgorithm = upScalingAlgorithm;
this.compressionQuality = compressionQuality;
this.threadCount = threadCount;
this.skipExistingFiles = skipExistingFiles;
this.skipUpscaling = skipUpscaling;
this.verboseLog = verboseLog;
this.includeAndroidLdpiTvdpi = includeAndroidLdpiTvdpi;
this.haltOnError = haltOnError;
this.createMipMapInsteadOfDrawableDir = createMipMapInsteadOfDrawableDir;
this.iosCreateImagesetFolders = iosCreateImagesetFolders;
this.enablePngCrush = enablePngCrush;
this.enableMozJpeg = enableMozJpeg;
this.postConvertWebp = postConvertWebp;
this.enableAntiAliasing = enableAntiAliasing;
this.dryRun = dryRun;
this.keepUnoptimizedFilesPostProcessor = keepUnoptimizedFilesPostProcessor;
this.roundingHandler = roundingHandler;
this.guiAdvancedOptions = guiAdvancedOptions;
this.clearDirBeforeConvert = clearDirBeforeConvert;
this.filesToProcess = new ArrayList<>();
Set<String> supportedFileTypes = getSupportedFileTypes();
if (src != null && src.isDirectory()) {
for (File file : src.listFiles()) {
|
String extension = MiscUtil.getFileExtensionLowerCase(file);
|
patrickfav/density-converter
|
src/main/java/at/favre/tools/dconvert/arg/Arguments.java
|
// Path: src/main/java/at/favre/tools/dconvert/exceptions/InvalidArgumentException.java
// public class InvalidArgumentException extends Exception {
// public InvalidArgumentException(String message) {
// super(message);
// }
//
// public InvalidArgumentException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/at/favre/tools/dconvert/util/MiscUtil.java
// public final class MiscUtil {
// private MiscUtil() {
// }
//
// public static String getStackTrace(Throwable t) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// t.printStackTrace(pw);
// return sw.toString();
// }
//
// public static String duration(long ms) {
// if (ms >= 1000) {
// return String.format(Locale.US, "%.2f sec", (double) ms / 1000);
// }
// return ms + " ms";
// }
//
// public static <T> T[] concat(T[] first, T[] second) {
// T[] result = Arrays.copyOf(first, first.length + second.length);
// System.arraycopy(second, 0, result, first.length, second.length);
// return result;
// }
//
// public static File createAndCheckFolder(String path, boolean dryRun) {
// File f = new File(path);
//
// if (dryRun) {
// return f;
// }
//
// if (!f.exists()) {
// f.mkdirs();
// }
//
// if (!f.exists() || !f.isDirectory()) {
// throw new IllegalStateException("could not create folder: " + path);
// }
// return f;
// }
//
// public static String getFileExtensionLowerCase(File file) {
// return getFileExtension(file).toLowerCase();
// }
//
// public static String getFileExtension(File file) {
// if (file == null) {
// return "";
// }
// return file.getName().substring(file.getName().lastIndexOf(".") + 1);
// }
//
// public static String getFileNameWithoutExtension(File file) {
// String fileName = file.getName();
// int pos = fileName.lastIndexOf(".");
// if (pos > 0) {
// fileName = fileName.substring(0, pos);
// }
// return fileName;
// }
//
// public static String getCmdProgressBar(float progress) {
// int loadingBarCount = 40;
// int bars = Math.round((float) loadingBarCount * progress);
// StringBuilder sb = new StringBuilder("\r[");
//
// for (int i = 0; i < loadingBarCount; i++) {
// if (i < bars) {
// sb.append("-");
// } else {
// sb.append(" ");
// }
// }
// sb.append("] ");
//
// if (progress < 1f) {
// sb.append(String.format("%6s", String.format(Locale.US, "%.2f", progress * 100f))).append("%");
// } else {
// sb.append("100.00%\n");
// }
//
// return sb.toString();
// }
//
// public static <T> Set<T> toSet(T elem) {
// Set<T> set = new HashSet<>(1);
// set.add(elem);
// return set;
// }
//
// public static void deleteFolder(File folder) {
// if (folder != null && folder.exists()) {
// File[] files = folder.listFiles();
// if (files != null) { //some JVMs return null for empty dirs
// for (File f : files) {
// if (f.isDirectory()) {
// deleteFolder(f);
// } else {
// f.delete();
// }
// }
// }
// folder.delete();
// }
// }
// }
|
import at.favre.tools.dconvert.exceptions.InvalidArgumentException;
import at.favre.tools.dconvert.util.MiscUtil;
import java.io.File;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.*;
|
public Builder scaleRoundingStragy(RoundingHandler.Strategy strategy) {
this.roundingStrategy = strategy;
return this;
}
public Builder skipParamValidation(boolean b) {
this.internalSkipParamValidation = b;
return this;
}
public Builder keepUnoptimizedFilesPostProcessor(boolean b) {
this.keepUnoptimizedFilesPostProcessor = b;
return this;
}
public Builder iosCreateImagesetFolders(boolean b) {
this.iosCreateImagesetFolders = b;
return this;
}
public Builder guiAdvancedOptions(boolean b) {
this.guiAdvancedOptions = b;
return this;
}
public Builder clearDirBeforeConvert(boolean b) {
this.clearDirBeforeConvert = b;
return this;
}
|
// Path: src/main/java/at/favre/tools/dconvert/exceptions/InvalidArgumentException.java
// public class InvalidArgumentException extends Exception {
// public InvalidArgumentException(String message) {
// super(message);
// }
//
// public InvalidArgumentException(String message, Throwable cause) {
// super(message, cause);
// }
// }
//
// Path: src/main/java/at/favre/tools/dconvert/util/MiscUtil.java
// public final class MiscUtil {
// private MiscUtil() {
// }
//
// public static String getStackTrace(Throwable t) {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// t.printStackTrace(pw);
// return sw.toString();
// }
//
// public static String duration(long ms) {
// if (ms >= 1000) {
// return String.format(Locale.US, "%.2f sec", (double) ms / 1000);
// }
// return ms + " ms";
// }
//
// public static <T> T[] concat(T[] first, T[] second) {
// T[] result = Arrays.copyOf(first, first.length + second.length);
// System.arraycopy(second, 0, result, first.length, second.length);
// return result;
// }
//
// public static File createAndCheckFolder(String path, boolean dryRun) {
// File f = new File(path);
//
// if (dryRun) {
// return f;
// }
//
// if (!f.exists()) {
// f.mkdirs();
// }
//
// if (!f.exists() || !f.isDirectory()) {
// throw new IllegalStateException("could not create folder: " + path);
// }
// return f;
// }
//
// public static String getFileExtensionLowerCase(File file) {
// return getFileExtension(file).toLowerCase();
// }
//
// public static String getFileExtension(File file) {
// if (file == null) {
// return "";
// }
// return file.getName().substring(file.getName().lastIndexOf(".") + 1);
// }
//
// public static String getFileNameWithoutExtension(File file) {
// String fileName = file.getName();
// int pos = fileName.lastIndexOf(".");
// if (pos > 0) {
// fileName = fileName.substring(0, pos);
// }
// return fileName;
// }
//
// public static String getCmdProgressBar(float progress) {
// int loadingBarCount = 40;
// int bars = Math.round((float) loadingBarCount * progress);
// StringBuilder sb = new StringBuilder("\r[");
//
// for (int i = 0; i < loadingBarCount; i++) {
// if (i < bars) {
// sb.append("-");
// } else {
// sb.append(" ");
// }
// }
// sb.append("] ");
//
// if (progress < 1f) {
// sb.append(String.format("%6s", String.format(Locale.US, "%.2f", progress * 100f))).append("%");
// } else {
// sb.append("100.00%\n");
// }
//
// return sb.toString();
// }
//
// public static <T> Set<T> toSet(T elem) {
// Set<T> set = new HashSet<>(1);
// set.add(elem);
// return set;
// }
//
// public static void deleteFolder(File folder) {
// if (folder != null && folder.exists()) {
// File[] files = folder.listFiles();
// if (files != null) { //some JVMs return null for empty dirs
// for (File f : files) {
// if (f.isDirectory()) {
// deleteFolder(f);
// } else {
// f.delete();
// }
// }
// }
// folder.delete();
// }
// }
// }
// Path: src/main/java/at/favre/tools/dconvert/arg/Arguments.java
import at.favre.tools.dconvert.exceptions.InvalidArgumentException;
import at.favre.tools.dconvert.util.MiscUtil;
import java.io.File;
import java.io.Serializable;
import java.text.MessageFormat;
import java.util.*;
public Builder scaleRoundingStragy(RoundingHandler.Strategy strategy) {
this.roundingStrategy = strategy;
return this;
}
public Builder skipParamValidation(boolean b) {
this.internalSkipParamValidation = b;
return this;
}
public Builder keepUnoptimizedFilesPostProcessor(boolean b) {
this.keepUnoptimizedFilesPostProcessor = b;
return this;
}
public Builder iosCreateImagesetFolders(boolean b) {
this.iosCreateImagesetFolders = b;
return this;
}
public Builder guiAdvancedOptions(boolean b) {
this.guiAdvancedOptions = b;
return this;
}
public Builder clearDirBeforeConvert(boolean b) {
this.clearDirBeforeConvert = b;
return this;
}
|
public Arguments build() throws InvalidArgumentException {
|
eleybourn/Book-Catalogue
|
src/com/eleybourn/bookcatalogue/bcservices/BcSearchManager.java
|
// Path: src/com/eleybourn/bookcatalogue/SearchThread.java
// public static class BookSearchResults {
// public DataSource source;
// public Bundle data;
// public BookSearchResults(DataSource source, Bundle data) {
// this.source = source;
// this.data = data;
// }
// }
//
// Path: src/com/eleybourn/bookcatalogue/SearchThread.java
// public enum DataSource {
// Amazon(0),
// Google(SearchManager.SEARCH_GOOGLE),
// OpenLibrary(0),
// LibraryThing(SearchManager.SEARCH_LIBRARY_THING),
// Goodreads(SearchManager.SEARCH_GOODREADS),
// BCDB(SearchManager.SEARCH_BC),
// Other(0),
// ;
// private int mValue;
//
// private DataSource(int value) {
// mValue = value;
// }
//
// public int getValue() {
// return mValue;
// }
// }
//
// Path: src/com/eleybourn/bookcatalogue/bcservices/BcService.java
// public enum Methods {
// Get,
// Post
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import android.net.Uri;
import android.os.Bundle;
import com.eleybourn.bookcatalogue.BuildConfig;
import com.eleybourn.bookcatalogue.SearchThread.BookSearchResults;
import com.eleybourn.bookcatalogue.SearchThread.DataSource;
import com.eleybourn.bookcatalogue.bcservices.BcService.Methods;
import com.eleybourn.bookcatalogue.utils.Logger;
import org.json.JSONArray;
|
if (author.length() == 0) {
author = Uri.encode(" ");
}
if (title.length() == 0) {
title = Uri.encode(" ");
}
// Base path for an ISBN search
String path = String.format(SEARCH_AUTHOR_TITLE_URL, author, title);
if (author.equals("") && title.equals(""))
throw new IllegalArgumentException();
search(path, fetchThumbnail, results);
}
/**
* Use the passed complete search URL to gather results.
*
* @param url URL for search.
* @param fetchThumbnail True if thumbnails are wanted.
* @param resultList List of {@link BookSearchResults} objects
*/
private void search(String url, boolean fetchThumbnail, ArrayList<BookSearchResults> resultList) {
JSONObject apiResult;
try {
// Make sure we limit requests (no more than 1 request/second/client).
BcService.waitUntilRequestAllowed();
// Get the JSON result
|
// Path: src/com/eleybourn/bookcatalogue/SearchThread.java
// public static class BookSearchResults {
// public DataSource source;
// public Bundle data;
// public BookSearchResults(DataSource source, Bundle data) {
// this.source = source;
// this.data = data;
// }
// }
//
// Path: src/com/eleybourn/bookcatalogue/SearchThread.java
// public enum DataSource {
// Amazon(0),
// Google(SearchManager.SEARCH_GOOGLE),
// OpenLibrary(0),
// LibraryThing(SearchManager.SEARCH_LIBRARY_THING),
// Goodreads(SearchManager.SEARCH_GOODREADS),
// BCDB(SearchManager.SEARCH_BC),
// Other(0),
// ;
// private int mValue;
//
// private DataSource(int value) {
// mValue = value;
// }
//
// public int getValue() {
// return mValue;
// }
// }
//
// Path: src/com/eleybourn/bookcatalogue/bcservices/BcService.java
// public enum Methods {
// Get,
// Post
// }
// Path: src/com/eleybourn/bookcatalogue/bcservices/BcSearchManager.java
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import android.net.Uri;
import android.os.Bundle;
import com.eleybourn.bookcatalogue.BuildConfig;
import com.eleybourn.bookcatalogue.SearchThread.BookSearchResults;
import com.eleybourn.bookcatalogue.SearchThread.DataSource;
import com.eleybourn.bookcatalogue.bcservices.BcService.Methods;
import com.eleybourn.bookcatalogue.utils.Logger;
import org.json.JSONArray;
if (author.length() == 0) {
author = Uri.encode(" ");
}
if (title.length() == 0) {
title = Uri.encode(" ");
}
// Base path for an ISBN search
String path = String.format(SEARCH_AUTHOR_TITLE_URL, author, title);
if (author.equals("") && title.equals(""))
throw new IllegalArgumentException();
search(path, fetchThumbnail, results);
}
/**
* Use the passed complete search URL to gather results.
*
* @param url URL for search.
* @param fetchThumbnail True if thumbnails are wanted.
* @param resultList List of {@link BookSearchResults} objects
*/
private void search(String url, boolean fetchThumbnail, ArrayList<BookSearchResults> resultList) {
JSONObject apiResult;
try {
// Make sure we limit requests (no more than 1 request/second/client).
BcService.waitUntilRequestAllowed();
// Get the JSON result
|
apiResult = BcService.makeServiceCall(url, Methods.Get, new HashMap<>());
|
eleybourn/Book-Catalogue
|
src/com/eleybourn/bookcatalogue/bcservices/BcSearchManager.java
|
// Path: src/com/eleybourn/bookcatalogue/SearchThread.java
// public static class BookSearchResults {
// public DataSource source;
// public Bundle data;
// public BookSearchResults(DataSource source, Bundle data) {
// this.source = source;
// this.data = data;
// }
// }
//
// Path: src/com/eleybourn/bookcatalogue/SearchThread.java
// public enum DataSource {
// Amazon(0),
// Google(SearchManager.SEARCH_GOOGLE),
// OpenLibrary(0),
// LibraryThing(SearchManager.SEARCH_LIBRARY_THING),
// Goodreads(SearchManager.SEARCH_GOODREADS),
// BCDB(SearchManager.SEARCH_BC),
// Other(0),
// ;
// private int mValue;
//
// private DataSource(int value) {
// mValue = value;
// }
//
// public int getValue() {
// return mValue;
// }
// }
//
// Path: src/com/eleybourn/bookcatalogue/bcservices/BcService.java
// public enum Methods {
// Get,
// Post
// }
|
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import android.net.Uri;
import android.os.Bundle;
import com.eleybourn.bookcatalogue.BuildConfig;
import com.eleybourn.bookcatalogue.SearchThread.BookSearchResults;
import com.eleybourn.bookcatalogue.SearchThread.DataSource;
import com.eleybourn.bookcatalogue.bcservices.BcService.Methods;
import com.eleybourn.bookcatalogue.utils.Logger;
import org.json.JSONArray;
|
private void search(String url, boolean fetchThumbnail, ArrayList<BookSearchResults> resultList) {
JSONObject apiResult;
try {
// Make sure we limit requests (no more than 1 request/second/client).
BcService.waitUntilRequestAllowed();
// Get the JSON result
apiResult = BcService.makeServiceCall(url, Methods.Get, new HashMap<>());
} catch (Exception e) {
Logger.logError(e, "Service call failed");
return;
}
if (apiResult == null) {
Logger.logError(new RuntimeException("API result is null"));
return;
}
try {
// Check overall status
apiResult = apiResult.getJSONObject(RESULTS);
if (apiResult.optString(STATUS, "").equals(STATUS_OK)) {
JSONArray results = apiResult.getJSONArray(DATA);
// Process array of results
for (int i = 0; i < results.length(); i++) {
// Get one result
JSONObject resultWrapper = results.getJSONObject(i);
// If result status OK, process data
if (resultWrapper.optString(STATUS, "").equals(STATUS_OK)) {
boolean skip = false;
String source = resultWrapper.getString(SOURCE);
|
// Path: src/com/eleybourn/bookcatalogue/SearchThread.java
// public static class BookSearchResults {
// public DataSource source;
// public Bundle data;
// public BookSearchResults(DataSource source, Bundle data) {
// this.source = source;
// this.data = data;
// }
// }
//
// Path: src/com/eleybourn/bookcatalogue/SearchThread.java
// public enum DataSource {
// Amazon(0),
// Google(SearchManager.SEARCH_GOOGLE),
// OpenLibrary(0),
// LibraryThing(SearchManager.SEARCH_LIBRARY_THING),
// Goodreads(SearchManager.SEARCH_GOODREADS),
// BCDB(SearchManager.SEARCH_BC),
// Other(0),
// ;
// private int mValue;
//
// private DataSource(int value) {
// mValue = value;
// }
//
// public int getValue() {
// return mValue;
// }
// }
//
// Path: src/com/eleybourn/bookcatalogue/bcservices/BcService.java
// public enum Methods {
// Get,
// Post
// }
// Path: src/com/eleybourn/bookcatalogue/bcservices/BcSearchManager.java
import org.json.JSONException;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashMap;
import android.net.Uri;
import android.os.Bundle;
import com.eleybourn.bookcatalogue.BuildConfig;
import com.eleybourn.bookcatalogue.SearchThread.BookSearchResults;
import com.eleybourn.bookcatalogue.SearchThread.DataSource;
import com.eleybourn.bookcatalogue.bcservices.BcService.Methods;
import com.eleybourn.bookcatalogue.utils.Logger;
import org.json.JSONArray;
private void search(String url, boolean fetchThumbnail, ArrayList<BookSearchResults> resultList) {
JSONObject apiResult;
try {
// Make sure we limit requests (no more than 1 request/second/client).
BcService.waitUntilRequestAllowed();
// Get the JSON result
apiResult = BcService.makeServiceCall(url, Methods.Get, new HashMap<>());
} catch (Exception e) {
Logger.logError(e, "Service call failed");
return;
}
if (apiResult == null) {
Logger.logError(new RuntimeException("API result is null"));
return;
}
try {
// Check overall status
apiResult = apiResult.getJSONObject(RESULTS);
if (apiResult.optString(STATUS, "").equals(STATUS_OK)) {
JSONArray results = apiResult.getJSONArray(DATA);
// Process array of results
for (int i = 0; i < results.length(); i++) {
// Get one result
JSONObject resultWrapper = results.getJSONObject(i);
// If result status OK, process data
if (resultWrapper.optString(STATUS, "").equals(STATUS_OK)) {
boolean skip = false;
String source = resultWrapper.getString(SOURCE);
|
DataSource src;
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/NoticesXmlParser.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
|
import android.util.Xml;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.io.InputStream;
|
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public final class NoticesXmlParser {
private NoticesXmlParser() {
}
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/NoticesXmlParser.java
import android.util.Xml;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.io.InputStream;
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public final class NoticesXmlParser {
private NoticesXmlParser() {
}
|
public static Notices parse(final InputStream inputStream) throws Exception {
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/NoticesXmlParser.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
|
import android.util.Xml;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.io.InputStream;
|
public static Notices parse(final InputStream inputStream) throws Exception {
try {
final XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(inputStream, null);
parser.nextTag();
return parse(parser);
} finally {
inputStream.close();
}
}
private static Notices parse(final XmlPullParser parser) throws IOException, XmlPullParserException {
final Notices notices = new Notices();
parser.require(XmlPullParser.START_TAG, null, "notices");
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
final String name = parser.getName();
// Starts by looking for the entry tag
if ("notice".equals(name)) {
notices.addNotice(readNotice(parser));
} else {
skip(parser);
}
}
return notices;
}
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/NoticesXmlParser.java
import android.util.Xml;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
import java.io.InputStream;
public static Notices parse(final InputStream inputStream) throws Exception {
try {
final XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(inputStream, null);
parser.nextTag();
return parse(parser);
} finally {
inputStream.close();
}
}
private static Notices parse(final XmlPullParser parser) throws IOException, XmlPullParserException {
final Notices notices = new Notices();
parser.require(XmlPullParser.START_TAG, null, "notices");
while (parser.next() != XmlPullParser.END_TAG) {
if (parser.getEventType() != XmlPullParser.START_TAG) {
continue;
}
final String name = parser.getName();
// Starts by looking for the entry tag
if ("notice".equals(name)) {
notices.addNotice(readNotice(parser));
} else {
skip(parser);
}
}
return notices;
}
|
private static Notice readNotice(final XmlPullParser parser) throws IOException,
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/NoticesHtmlBuilder.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
|
import android.content.Context;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
|
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public final class NoticesHtmlBuilder {
private final Context mContext;
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/NoticesHtmlBuilder.java
import android.content.Context;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public final class NoticesHtmlBuilder {
private final Context mContext;
|
private Notices mNotices;
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/NoticesHtmlBuilder.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
|
import android.content.Context;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
|
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public final class NoticesHtmlBuilder {
private final Context mContext;
private Notices mNotices;
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/NoticesHtmlBuilder.java
import android.content.Context;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.model.Notice;
import de.psdev.licensesdialog.model.Notices;
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public final class NoticesHtmlBuilder {
private final Context mContext;
private Notices mNotices;
|
private Notice mNotice;
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/SingleLicenseDialogFragment.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
|
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import de.psdev.licensesdialog.model.Notice;
|
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class SingleLicenseDialogFragment extends DialogFragment {
private static final String ARGUMENT_NOTICE = "ARGUMENT_NOTICE";
private static final String STATE_LICENSE_TEXT = "license_text";
private static final String STATE_TITLE_TEXT = "title_text";
private static final String STATE_CLOSE_TEXT = "close_text";
//
private String mTitleText;
private String mCloseButtonText;
private String mLicenseText;
//
private boolean mShowFullLicenseText;
private DialogInterface.OnDismissListener mOnDismissListener;
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notice.java
// public class Notice implements Serializable {
// private static final long serialVersionUID = -6257913944601445939L;
//
// private String mName;
// private String mUrl;
// private String mCopyright;
// private License mLicense;
//
// //
//
// public Notice() {
// }
//
// public Notice(final String name, final String url, final String copyright, final License license) {
// mName = name;
// mUrl = url;
// mCopyright = copyright;
// mLicense = license;
// }
//
// // Setter / Getter
//
// public void setName(final String name) {
// mName = name;
// }
//
// public void setUrl(final String url) {
// mUrl = url;
// }
//
// public void setCopyright(final String copyright) {
// mCopyright = copyright;
// }
//
// public void setLicense(final License license) {
// mLicense = license;
// }
//
// public String getName() {
// return mName;
// }
//
// public String getUrl() {
// return mUrl;
// }
//
// public String getCopyright() {
// return mCopyright;
// }
//
// public License getLicense() {
// return mLicense;
// }
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/SingleLicenseDialogFragment.java
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import de.psdev.licensesdialog.model.Notice;
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class SingleLicenseDialogFragment extends DialogFragment {
private static final String ARGUMENT_NOTICE = "ARGUMENT_NOTICE";
private static final String STATE_LICENSE_TEXT = "license_text";
private static final String STATE_TITLE_TEXT = "title_text";
private static final String STATE_CLOSE_TEXT = "close_text";
//
private String mTitleText;
private String mCloseButtonText;
private String mLicenseText;
//
private boolean mShowFullLicenseText;
private DialogInterface.OnDismissListener mOnDismissListener;
|
public static SingleLicenseDialogFragment newInstance(final Notice notice) {
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/LicensesDialogFragment.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
|
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import de.psdev.licensesdialog.model.Notices;
|
private String mCloseButtonText;
private String mLicensesText;
private DialogInterface.OnDismissListener mOnDismissListener;
public static LicensesDialogFragment newInstance(final int rawNoticesResourceId, final boolean includeOwnLicense) {
final LicensesDialogFragment licensesDialogFragment = new LicensesDialogFragment();
final Bundle args = new Bundle();
args.putInt(ARGUMENT_NOTICES_XML_ID, rawNoticesResourceId);
args.putBoolean(ARGUMENT_INCLUDE_OWN_LICENSE, includeOwnLicense);
licensesDialogFragment.setArguments(args);
return licensesDialogFragment;
}
public LicensesDialogFragment() {
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Resources resources = getResources();
if (savedInstanceState != null) {
mTitleText = savedInstanceState.getString(STATE_TITLE_TEXT);
mLicensesText = savedInstanceState.getString(STATE_LICENSES_TEXT);
mCloseButtonText = savedInstanceState.getString(STATE_CLOSE_TEXT);
} else {
mTitleText = resources.getString(R.string.notices_title);
mCloseButtonText = resources.getString(R.string.notices_close);
try {
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/model/Notices.java
// public class Notices {
//
// private final List<Notice> mNotices = new ArrayList<Notice>();
//
// // Setter / Getter
//
// public void addNotice(final Notice notice) {
// mNotices.add(notice);
// }
//
// public List<Notice> getNotices() {
// return mNotices;
// }
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/LicensesDialogFragment.java
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.os.Bundle;
import android.support.v4.app.DialogFragment;
import de.psdev.licensesdialog.model.Notices;
private String mCloseButtonText;
private String mLicensesText;
private DialogInterface.OnDismissListener mOnDismissListener;
public static LicensesDialogFragment newInstance(final int rawNoticesResourceId, final boolean includeOwnLicense) {
final LicensesDialogFragment licensesDialogFragment = new LicensesDialogFragment();
final Bundle args = new Bundle();
args.putInt(ARGUMENT_NOTICES_XML_ID, rawNoticesResourceId);
args.putBoolean(ARGUMENT_INCLUDE_OWN_LICENSE, includeOwnLicense);
licensesDialogFragment.setArguments(args);
return licensesDialogFragment;
}
public LicensesDialogFragment() {
}
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Resources resources = getResources();
if (savedInstanceState != null) {
mTitleText = savedInstanceState.getString(STATE_TITLE_TEXT);
mLicensesText = savedInstanceState.getString(STATE_LICENSES_TEXT);
mCloseButtonText = savedInstanceState.getString(STATE_CLOSE_TEXT);
} else {
mTitleText = resources.getString(R.string.notices_title);
mCloseButtonText = resources.getString(R.string.notices_close);
try {
|
final Notices notices = NoticesXmlParser.parse(resources.openRawResource(getNoticesXmlResourceId()));
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ApacheSoftwareLicense20.java
// public class ApacheSoftwareLicense20 extends License {
//
// private static final long serialVersionUID = 4854000061990891449L;
//
// @Override
// public String getName() {
// return "Apache Software License 2.0";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.asl_20_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.asl_20_full);
// }
//
// @Override
// public String getVersion() {
// return "2.0";
// }
//
// @Override
// public String getUrl() {
// return "http://www.apache.org/licenses/LICENSE-2.0.txt";
// }
//
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/BSD3ClauseLicense.java
// public class BSD3ClauseLicense extends License {
//
// private static final long serialVersionUID = -5205394619884057474L;
//
// @Override
// public String getName() {
// return "BSD 3-Clause License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.bsd3_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.bsd3_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/BSD-3-Clause";
// }
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ISCLicense.java
// public class ISCLicense extends License {
// private static final long serialVersionUID = -4636435634132169860L;
//
// @Override
// public String getName() {
// return "ISC License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.isc_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.isc_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/isc-license.txt";
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/NanoHttpdLicense.java
// public class NanoHttpdLicense extends License {
//
// private static final long serialVersionUID = 5673599951781482594L;
//
// @Override
// public String getName() {
// return "NanoHTTPD License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "https://github.com/NanoHttpd/nanohttpd/blob/master/LICENSE.md";
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD3ClauseLicense;
import de.psdev.licensesdialog.licenses.ISCLicense;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.licenses.MITLicense;
import de.psdev.licensesdialog.licenses.NanoHttpdLicense;
import de.psdev.licensesdialog.licenses.ViewerJSLicense;
import de.psdev.licensesdialog.licenses.XstreamLicense;
|
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class LicenseResolver {
private static final int INITIAL_LICENSES_COUNT = 4;
private static Map<String, License> sLicenses = new HashMap<String, License>(INITIAL_LICENSES_COUNT);
static {
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ApacheSoftwareLicense20.java
// public class ApacheSoftwareLicense20 extends License {
//
// private static final long serialVersionUID = 4854000061990891449L;
//
// @Override
// public String getName() {
// return "Apache Software License 2.0";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.asl_20_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.asl_20_full);
// }
//
// @Override
// public String getVersion() {
// return "2.0";
// }
//
// @Override
// public String getUrl() {
// return "http://www.apache.org/licenses/LICENSE-2.0.txt";
// }
//
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/BSD3ClauseLicense.java
// public class BSD3ClauseLicense extends License {
//
// private static final long serialVersionUID = -5205394619884057474L;
//
// @Override
// public String getName() {
// return "BSD 3-Clause License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.bsd3_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.bsd3_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/BSD-3-Clause";
// }
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ISCLicense.java
// public class ISCLicense extends License {
// private static final long serialVersionUID = -4636435634132169860L;
//
// @Override
// public String getName() {
// return "ISC License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.isc_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.isc_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/isc-license.txt";
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/NanoHttpdLicense.java
// public class NanoHttpdLicense extends License {
//
// private static final long serialVersionUID = 5673599951781482594L;
//
// @Override
// public String getName() {
// return "NanoHTTPD License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "https://github.com/NanoHttpd/nanohttpd/blob/master/LICENSE.md";
// }
//
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java
import java.util.HashMap;
import java.util.Map;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD3ClauseLicense;
import de.psdev.licensesdialog.licenses.ISCLicense;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.licenses.MITLicense;
import de.psdev.licensesdialog.licenses.NanoHttpdLicense;
import de.psdev.licensesdialog.licenses.ViewerJSLicense;
import de.psdev.licensesdialog.licenses.XstreamLicense;
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class LicenseResolver {
private static final int INITIAL_LICENSES_COUNT = 4;
private static Map<String, License> sLicenses = new HashMap<String, License>(INITIAL_LICENSES_COUNT);
static {
|
registerLicense(new ApacheSoftwareLicense20());
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ApacheSoftwareLicense20.java
// public class ApacheSoftwareLicense20 extends License {
//
// private static final long serialVersionUID = 4854000061990891449L;
//
// @Override
// public String getName() {
// return "Apache Software License 2.0";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.asl_20_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.asl_20_full);
// }
//
// @Override
// public String getVersion() {
// return "2.0";
// }
//
// @Override
// public String getUrl() {
// return "http://www.apache.org/licenses/LICENSE-2.0.txt";
// }
//
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/BSD3ClauseLicense.java
// public class BSD3ClauseLicense extends License {
//
// private static final long serialVersionUID = -5205394619884057474L;
//
// @Override
// public String getName() {
// return "BSD 3-Clause License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.bsd3_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.bsd3_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/BSD-3-Clause";
// }
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ISCLicense.java
// public class ISCLicense extends License {
// private static final long serialVersionUID = -4636435634132169860L;
//
// @Override
// public String getName() {
// return "ISC License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.isc_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.isc_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/isc-license.txt";
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/NanoHttpdLicense.java
// public class NanoHttpdLicense extends License {
//
// private static final long serialVersionUID = 5673599951781482594L;
//
// @Override
// public String getName() {
// return "NanoHTTPD License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "https://github.com/NanoHttpd/nanohttpd/blob/master/LICENSE.md";
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD3ClauseLicense;
import de.psdev.licensesdialog.licenses.ISCLicense;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.licenses.MITLicense;
import de.psdev.licensesdialog.licenses.NanoHttpdLicense;
import de.psdev.licensesdialog.licenses.ViewerJSLicense;
import de.psdev.licensesdialog.licenses.XstreamLicense;
|
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class LicenseResolver {
private static final int INITIAL_LICENSES_COUNT = 4;
private static Map<String, License> sLicenses = new HashMap<String, License>(INITIAL_LICENSES_COUNT);
static {
registerLicense(new ApacheSoftwareLicense20());
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ApacheSoftwareLicense20.java
// public class ApacheSoftwareLicense20 extends License {
//
// private static final long serialVersionUID = 4854000061990891449L;
//
// @Override
// public String getName() {
// return "Apache Software License 2.0";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.asl_20_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.asl_20_full);
// }
//
// @Override
// public String getVersion() {
// return "2.0";
// }
//
// @Override
// public String getUrl() {
// return "http://www.apache.org/licenses/LICENSE-2.0.txt";
// }
//
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/BSD3ClauseLicense.java
// public class BSD3ClauseLicense extends License {
//
// private static final long serialVersionUID = -5205394619884057474L;
//
// @Override
// public String getName() {
// return "BSD 3-Clause License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.bsd3_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.bsd3_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/BSD-3-Clause";
// }
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ISCLicense.java
// public class ISCLicense extends License {
// private static final long serialVersionUID = -4636435634132169860L;
//
// @Override
// public String getName() {
// return "ISC License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.isc_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.isc_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/isc-license.txt";
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/NanoHttpdLicense.java
// public class NanoHttpdLicense extends License {
//
// private static final long serialVersionUID = 5673599951781482594L;
//
// @Override
// public String getName() {
// return "NanoHTTPD License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "https://github.com/NanoHttpd/nanohttpd/blob/master/LICENSE.md";
// }
//
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java
import java.util.HashMap;
import java.util.Map;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD3ClauseLicense;
import de.psdev.licensesdialog.licenses.ISCLicense;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.licenses.MITLicense;
import de.psdev.licensesdialog.licenses.NanoHttpdLicense;
import de.psdev.licensesdialog.licenses.ViewerJSLicense;
import de.psdev.licensesdialog.licenses.XstreamLicense;
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class LicenseResolver {
private static final int INITIAL_LICENSES_COUNT = 4;
private static Map<String, License> sLicenses = new HashMap<String, License>(INITIAL_LICENSES_COUNT);
static {
registerLicense(new ApacheSoftwareLicense20());
|
registerLicense(new BSD3ClauseLicense());
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ApacheSoftwareLicense20.java
// public class ApacheSoftwareLicense20 extends License {
//
// private static final long serialVersionUID = 4854000061990891449L;
//
// @Override
// public String getName() {
// return "Apache Software License 2.0";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.asl_20_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.asl_20_full);
// }
//
// @Override
// public String getVersion() {
// return "2.0";
// }
//
// @Override
// public String getUrl() {
// return "http://www.apache.org/licenses/LICENSE-2.0.txt";
// }
//
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/BSD3ClauseLicense.java
// public class BSD3ClauseLicense extends License {
//
// private static final long serialVersionUID = -5205394619884057474L;
//
// @Override
// public String getName() {
// return "BSD 3-Clause License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.bsd3_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.bsd3_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/BSD-3-Clause";
// }
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ISCLicense.java
// public class ISCLicense extends License {
// private static final long serialVersionUID = -4636435634132169860L;
//
// @Override
// public String getName() {
// return "ISC License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.isc_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.isc_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/isc-license.txt";
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/NanoHttpdLicense.java
// public class NanoHttpdLicense extends License {
//
// private static final long serialVersionUID = 5673599951781482594L;
//
// @Override
// public String getName() {
// return "NanoHTTPD License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "https://github.com/NanoHttpd/nanohttpd/blob/master/LICENSE.md";
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD3ClauseLicense;
import de.psdev.licensesdialog.licenses.ISCLicense;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.licenses.MITLicense;
import de.psdev.licensesdialog.licenses.NanoHttpdLicense;
import de.psdev.licensesdialog.licenses.ViewerJSLicense;
import de.psdev.licensesdialog.licenses.XstreamLicense;
|
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class LicenseResolver {
private static final int INITIAL_LICENSES_COUNT = 4;
private static Map<String, License> sLicenses = new HashMap<String, License>(INITIAL_LICENSES_COUNT);
static {
registerLicense(new ApacheSoftwareLicense20());
registerLicense(new BSD3ClauseLicense());
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ApacheSoftwareLicense20.java
// public class ApacheSoftwareLicense20 extends License {
//
// private static final long serialVersionUID = 4854000061990891449L;
//
// @Override
// public String getName() {
// return "Apache Software License 2.0";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.asl_20_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.asl_20_full);
// }
//
// @Override
// public String getVersion() {
// return "2.0";
// }
//
// @Override
// public String getUrl() {
// return "http://www.apache.org/licenses/LICENSE-2.0.txt";
// }
//
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/BSD3ClauseLicense.java
// public class BSD3ClauseLicense extends License {
//
// private static final long serialVersionUID = -5205394619884057474L;
//
// @Override
// public String getName() {
// return "BSD 3-Clause License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.bsd3_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.bsd3_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/BSD-3-Clause";
// }
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ISCLicense.java
// public class ISCLicense extends License {
// private static final long serialVersionUID = -4636435634132169860L;
//
// @Override
// public String getName() {
// return "ISC License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.isc_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.isc_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/isc-license.txt";
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/NanoHttpdLicense.java
// public class NanoHttpdLicense extends License {
//
// private static final long serialVersionUID = 5673599951781482594L;
//
// @Override
// public String getName() {
// return "NanoHTTPD License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "https://github.com/NanoHttpd/nanohttpd/blob/master/LICENSE.md";
// }
//
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java
import java.util.HashMap;
import java.util.Map;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD3ClauseLicense;
import de.psdev.licensesdialog.licenses.ISCLicense;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.licenses.MITLicense;
import de.psdev.licensesdialog.licenses.NanoHttpdLicense;
import de.psdev.licensesdialog.licenses.ViewerJSLicense;
import de.psdev.licensesdialog.licenses.XstreamLicense;
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class LicenseResolver {
private static final int INITIAL_LICENSES_COUNT = 4;
private static Map<String, License> sLicenses = new HashMap<String, License>(INITIAL_LICENSES_COUNT);
static {
registerLicense(new ApacheSoftwareLicense20());
registerLicense(new BSD3ClauseLicense());
|
registerLicense(new ISCLicense());
|
guiguito/AIRShare
|
licencesDialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ApacheSoftwareLicense20.java
// public class ApacheSoftwareLicense20 extends License {
//
// private static final long serialVersionUID = 4854000061990891449L;
//
// @Override
// public String getName() {
// return "Apache Software License 2.0";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.asl_20_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.asl_20_full);
// }
//
// @Override
// public String getVersion() {
// return "2.0";
// }
//
// @Override
// public String getUrl() {
// return "http://www.apache.org/licenses/LICENSE-2.0.txt";
// }
//
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/BSD3ClauseLicense.java
// public class BSD3ClauseLicense extends License {
//
// private static final long serialVersionUID = -5205394619884057474L;
//
// @Override
// public String getName() {
// return "BSD 3-Clause License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.bsd3_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.bsd3_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/BSD-3-Clause";
// }
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ISCLicense.java
// public class ISCLicense extends License {
// private static final long serialVersionUID = -4636435634132169860L;
//
// @Override
// public String getName() {
// return "ISC License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.isc_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.isc_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/isc-license.txt";
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/NanoHttpdLicense.java
// public class NanoHttpdLicense extends License {
//
// private static final long serialVersionUID = 5673599951781482594L;
//
// @Override
// public String getName() {
// return "NanoHTTPD License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "https://github.com/NanoHttpd/nanohttpd/blob/master/LICENSE.md";
// }
//
// }
|
import java.util.HashMap;
import java.util.Map;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD3ClauseLicense;
import de.psdev.licensesdialog.licenses.ISCLicense;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.licenses.MITLicense;
import de.psdev.licensesdialog.licenses.NanoHttpdLicense;
import de.psdev.licensesdialog.licenses.ViewerJSLicense;
import de.psdev.licensesdialog.licenses.XstreamLicense;
|
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class LicenseResolver {
private static final int INITIAL_LICENSES_COUNT = 4;
private static Map<String, License> sLicenses = new HashMap<String, License>(INITIAL_LICENSES_COUNT);
static {
registerLicense(new ApacheSoftwareLicense20());
registerLicense(new BSD3ClauseLicense());
registerLicense(new ISCLicense());
registerLicense(new MITLicense());
|
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ApacheSoftwareLicense20.java
// public class ApacheSoftwareLicense20 extends License {
//
// private static final long serialVersionUID = 4854000061990891449L;
//
// @Override
// public String getName() {
// return "Apache Software License 2.0";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.asl_20_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.asl_20_full);
// }
//
// @Override
// public String getVersion() {
// return "2.0";
// }
//
// @Override
// public String getUrl() {
// return "http://www.apache.org/licenses/LICENSE-2.0.txt";
// }
//
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/BSD3ClauseLicense.java
// public class BSD3ClauseLicense extends License {
//
// private static final long serialVersionUID = -5205394619884057474L;
//
// @Override
// public String getName() {
// return "BSD 3-Clause License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.bsd3_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.bsd3_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/BSD-3-Clause";
// }
//
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/ISCLicense.java
// public class ISCLicense extends License {
// private static final long serialVersionUID = -4636435634132169860L;
//
// @Override
// public String getName() {
// return "ISC License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.isc_summary);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.isc_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "http://opensource.org/licenses/isc-license.txt";
// }
// }
//
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/licenses/NanoHttpdLicense.java
// public class NanoHttpdLicense extends License {
//
// private static final long serialVersionUID = 5673599951781482594L;
//
// @Override
// public String getName() {
// return "NanoHTTPD License";
// }
//
// @Override
// public String getSummaryText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getFullText(final Context context) {
// return getContent(context, R.raw.nano_full);
// }
//
// @Override
// public String getVersion() {
// return "";
// }
//
// @Override
// public String getUrl() {
// return "https://github.com/NanoHttpd/nanohttpd/blob/master/LICENSE.md";
// }
//
// }
// Path: licencesDialog/src/main/java/de/psdev/licensesdialog/LicenseResolver.java
import java.util.HashMap;
import java.util.Map;
import de.psdev.licensesdialog.licenses.ApacheSoftwareLicense20;
import de.psdev.licensesdialog.licenses.BSD3ClauseLicense;
import de.psdev.licensesdialog.licenses.ISCLicense;
import de.psdev.licensesdialog.licenses.License;
import de.psdev.licensesdialog.licenses.MITLicense;
import de.psdev.licensesdialog.licenses.NanoHttpdLicense;
import de.psdev.licensesdialog.licenses.ViewerJSLicense;
import de.psdev.licensesdialog.licenses.XstreamLicense;
/*
* Copyright 2013 Philip Schiffer
*
* 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 de.psdev.licensesdialog;
public class LicenseResolver {
private static final int INITIAL_LICENSES_COUNT = 4;
private static Map<String, License> sLicenses = new HashMap<String, License>(INITIAL_LICENSES_COUNT);
static {
registerLicense(new ApacheSoftwareLicense20());
registerLicense(new BSD3ClauseLicense());
registerLicense(new ISCLicense());
registerLicense(new MITLicense());
|
registerLicense(new NanoHttpdLicense());
|
glenrobson/SimpleAnnotationServer
|
src/main/java/uk/org/llgc/annotation/store/ListAnnoPages.java
|
// Path: src/main/java/uk/org/llgc/annotation/store/data/PageAnnoCount.java
// public class PageAnnoCount {
// protected int _count = 0;
// // These three properties should really be a canvas object...
// protected Canvas _canvas = null;
// protected String _pageId = "";
// protected String _label = "";
// protected String _shortId = "";
// protected Manifest _manifest = null;
//
// public PageAnnoCount(final Canvas pCanvas, final int pCount, final Manifest pManifest) {
// this.setCanvas(pCanvas);
// this.setCount(pCount);
// this.setManifest(pManifest);
// }
//
// public Manifest getManifest() {
// return _manifest;
// }
//
// public void setManifest(final Manifest pManifest) {
// _manifest = pManifest;
// }
//
//
// /**
// * Get count.
// *
// * @return count as int.
// */
// public int getCount() {
// return _count;
// }
//
// /**
// * Set count.
// *
// * @param count the value to set.
// */
// public void setCount(final int pCount) {
// _count = pCount;
// }
//
// /**
// * Get canvas.
// *
// * @return canvas as Canvas.
// */
// public Canvas getCanvas() {
// return _canvas;
// }
//
// /**
// * Set canvas.
// *
// * @param canvas the value to set.
// */
// public void setCanvas(final Canvas pCanvas) {
// _canvas = pCanvas;
// }
//
// public String toString() {
// return "Canvas=>" + _canvas.toString() + "\tCount=>" + _count;
// }
// }
//
// Path: src/main/java/uk/org/llgc/annotation/store/adapters/StoreAdapter.java
// public interface StoreAdapter {
//
// public void init(final AnnotationUtils pAnnoUtils);
//
// // CRUD annotations
// public Annotation addAnnotation(final Annotation pJson) throws IOException, IDConflictException, MalformedAnnotation;
// public Annotation updateAnnotation(final Annotation pJson) throws IOException, MalformedAnnotation;
// public Annotation getAnnotation(final String pId) throws IOException;
// public void deleteAnnotation(final String pAnnoId) throws IOException;
//
// public AnnotationList addAnnotationList(final AnnotationList pJson) throws IOException, IDConflictException, MalformedAnnotation;
//
// // CRUD manifests
// public String indexManifest(final Manifest pManifest) throws IOException;
// public List<Manifest> getManifests() throws IOException;
// public List<Manifest> getSkeletonManifests() throws IOException;
// public String getManifestId(final String pShortId) throws IOException;
// public Manifest getManifest(final String pShortId) throws IOException;
// public Manifest getManifestForCanvas(final Canvas pCanvasId) throws IOException;
//
// // CRUD canvas
// public Canvas resolveCanvas(final String pShortId) throws IOException;
// public void storeCanvas(final Canvas pCanvas) throws IOException;
//
// // Search
// public IIIFSearchResults search(final SearchQuery pQuery) throws IOException;
// public AnnotationList getAnnotationsFromPage(final Canvas pPage) throws IOException;
//
// // Used in ListAnnotations can we get rid?
// public AnnotationList getAllAnnotations() throws IOException;
// public List<PageAnnoCount> listAnnoPages() throws IOException;
// // Stats
// public List<PageAnnoCount> listAnnoPages(final Manifest pManifest) throws IOException;
// }
|
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import com.github.jsonldjava.utils.JsonUtils;
import org.apache.jena.rdf.model.Model;
import java.util.Map;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import uk.org.llgc.annotation.store.data.PageAnnoCount;
import uk.org.llgc.annotation.store.adapters.StoreAdapter;
|
package uk.org.llgc.annotation.store;
public class ListAnnoPages extends HttpServlet {
protected static Logger _logger = LogManager.getLogger(ListAnnoPages.class.getName());
protected AnnotationUtils _annotationUtils = null;
|
// Path: src/main/java/uk/org/llgc/annotation/store/data/PageAnnoCount.java
// public class PageAnnoCount {
// protected int _count = 0;
// // These three properties should really be a canvas object...
// protected Canvas _canvas = null;
// protected String _pageId = "";
// protected String _label = "";
// protected String _shortId = "";
// protected Manifest _manifest = null;
//
// public PageAnnoCount(final Canvas pCanvas, final int pCount, final Manifest pManifest) {
// this.setCanvas(pCanvas);
// this.setCount(pCount);
// this.setManifest(pManifest);
// }
//
// public Manifest getManifest() {
// return _manifest;
// }
//
// public void setManifest(final Manifest pManifest) {
// _manifest = pManifest;
// }
//
//
// /**
// * Get count.
// *
// * @return count as int.
// */
// public int getCount() {
// return _count;
// }
//
// /**
// * Set count.
// *
// * @param count the value to set.
// */
// public void setCount(final int pCount) {
// _count = pCount;
// }
//
// /**
// * Get canvas.
// *
// * @return canvas as Canvas.
// */
// public Canvas getCanvas() {
// return _canvas;
// }
//
// /**
// * Set canvas.
// *
// * @param canvas the value to set.
// */
// public void setCanvas(final Canvas pCanvas) {
// _canvas = pCanvas;
// }
//
// public String toString() {
// return "Canvas=>" + _canvas.toString() + "\tCount=>" + _count;
// }
// }
//
// Path: src/main/java/uk/org/llgc/annotation/store/adapters/StoreAdapter.java
// public interface StoreAdapter {
//
// public void init(final AnnotationUtils pAnnoUtils);
//
// // CRUD annotations
// public Annotation addAnnotation(final Annotation pJson) throws IOException, IDConflictException, MalformedAnnotation;
// public Annotation updateAnnotation(final Annotation pJson) throws IOException, MalformedAnnotation;
// public Annotation getAnnotation(final String pId) throws IOException;
// public void deleteAnnotation(final String pAnnoId) throws IOException;
//
// public AnnotationList addAnnotationList(final AnnotationList pJson) throws IOException, IDConflictException, MalformedAnnotation;
//
// // CRUD manifests
// public String indexManifest(final Manifest pManifest) throws IOException;
// public List<Manifest> getManifests() throws IOException;
// public List<Manifest> getSkeletonManifests() throws IOException;
// public String getManifestId(final String pShortId) throws IOException;
// public Manifest getManifest(final String pShortId) throws IOException;
// public Manifest getManifestForCanvas(final Canvas pCanvasId) throws IOException;
//
// // CRUD canvas
// public Canvas resolveCanvas(final String pShortId) throws IOException;
// public void storeCanvas(final Canvas pCanvas) throws IOException;
//
// // Search
// public IIIFSearchResults search(final SearchQuery pQuery) throws IOException;
// public AnnotationList getAnnotationsFromPage(final Canvas pPage) throws IOException;
//
// // Used in ListAnnotations can we get rid?
// public AnnotationList getAllAnnotations() throws IOException;
// public List<PageAnnoCount> listAnnoPages() throws IOException;
// // Stats
// public List<PageAnnoCount> listAnnoPages(final Manifest pManifest) throws IOException;
// }
// Path: src/main/java/uk/org/llgc/annotation/store/ListAnnoPages.java
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import com.github.jsonldjava.utils.JsonUtils;
import org.apache.jena.rdf.model.Model;
import java.util.Map;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import uk.org.llgc.annotation.store.data.PageAnnoCount;
import uk.org.llgc.annotation.store.adapters.StoreAdapter;
package uk.org.llgc.annotation.store;
public class ListAnnoPages extends HttpServlet {
protected static Logger _logger = LogManager.getLogger(ListAnnoPages.class.getName());
protected AnnotationUtils _annotationUtils = null;
|
protected StoreAdapter _store = null;
|
glenrobson/SimpleAnnotationServer
|
src/main/java/uk/org/llgc/annotation/store/ListAnnoPages.java
|
// Path: src/main/java/uk/org/llgc/annotation/store/data/PageAnnoCount.java
// public class PageAnnoCount {
// protected int _count = 0;
// // These three properties should really be a canvas object...
// protected Canvas _canvas = null;
// protected String _pageId = "";
// protected String _label = "";
// protected String _shortId = "";
// protected Manifest _manifest = null;
//
// public PageAnnoCount(final Canvas pCanvas, final int pCount, final Manifest pManifest) {
// this.setCanvas(pCanvas);
// this.setCount(pCount);
// this.setManifest(pManifest);
// }
//
// public Manifest getManifest() {
// return _manifest;
// }
//
// public void setManifest(final Manifest pManifest) {
// _manifest = pManifest;
// }
//
//
// /**
// * Get count.
// *
// * @return count as int.
// */
// public int getCount() {
// return _count;
// }
//
// /**
// * Set count.
// *
// * @param count the value to set.
// */
// public void setCount(final int pCount) {
// _count = pCount;
// }
//
// /**
// * Get canvas.
// *
// * @return canvas as Canvas.
// */
// public Canvas getCanvas() {
// return _canvas;
// }
//
// /**
// * Set canvas.
// *
// * @param canvas the value to set.
// */
// public void setCanvas(final Canvas pCanvas) {
// _canvas = pCanvas;
// }
//
// public String toString() {
// return "Canvas=>" + _canvas.toString() + "\tCount=>" + _count;
// }
// }
//
// Path: src/main/java/uk/org/llgc/annotation/store/adapters/StoreAdapter.java
// public interface StoreAdapter {
//
// public void init(final AnnotationUtils pAnnoUtils);
//
// // CRUD annotations
// public Annotation addAnnotation(final Annotation pJson) throws IOException, IDConflictException, MalformedAnnotation;
// public Annotation updateAnnotation(final Annotation pJson) throws IOException, MalformedAnnotation;
// public Annotation getAnnotation(final String pId) throws IOException;
// public void deleteAnnotation(final String pAnnoId) throws IOException;
//
// public AnnotationList addAnnotationList(final AnnotationList pJson) throws IOException, IDConflictException, MalformedAnnotation;
//
// // CRUD manifests
// public String indexManifest(final Manifest pManifest) throws IOException;
// public List<Manifest> getManifests() throws IOException;
// public List<Manifest> getSkeletonManifests() throws IOException;
// public String getManifestId(final String pShortId) throws IOException;
// public Manifest getManifest(final String pShortId) throws IOException;
// public Manifest getManifestForCanvas(final Canvas pCanvasId) throws IOException;
//
// // CRUD canvas
// public Canvas resolveCanvas(final String pShortId) throws IOException;
// public void storeCanvas(final Canvas pCanvas) throws IOException;
//
// // Search
// public IIIFSearchResults search(final SearchQuery pQuery) throws IOException;
// public AnnotationList getAnnotationsFromPage(final Canvas pPage) throws IOException;
//
// // Used in ListAnnotations can we get rid?
// public AnnotationList getAllAnnotations() throws IOException;
// public List<PageAnnoCount> listAnnoPages() throws IOException;
// // Stats
// public List<PageAnnoCount> listAnnoPages(final Manifest pManifest) throws IOException;
// }
|
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import com.github.jsonldjava.utils.JsonUtils;
import org.apache.jena.rdf.model.Model;
import java.util.Map;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import uk.org.llgc.annotation.store.data.PageAnnoCount;
import uk.org.llgc.annotation.store.adapters.StoreAdapter;
|
package uk.org.llgc.annotation.store;
public class ListAnnoPages extends HttpServlet {
protected static Logger _logger = LogManager.getLogger(ListAnnoPages.class.getName());
protected AnnotationUtils _annotationUtils = null;
protected StoreAdapter _store = null;
public void init(final ServletConfig pConfig) throws ServletException {
super.init(pConfig);
_annotationUtils = new AnnotationUtils(new File(super.getServletContext().getRealPath("/contexts")),StoreConfig.getConfig().getEncoder());
_store = StoreConfig.getConfig().getStore();
_store.init(_annotationUtils);
}
public void doGet(final HttpServletRequest pReq, final HttpServletResponse pRes) throws IOException {
|
// Path: src/main/java/uk/org/llgc/annotation/store/data/PageAnnoCount.java
// public class PageAnnoCount {
// protected int _count = 0;
// // These three properties should really be a canvas object...
// protected Canvas _canvas = null;
// protected String _pageId = "";
// protected String _label = "";
// protected String _shortId = "";
// protected Manifest _manifest = null;
//
// public PageAnnoCount(final Canvas pCanvas, final int pCount, final Manifest pManifest) {
// this.setCanvas(pCanvas);
// this.setCount(pCount);
// this.setManifest(pManifest);
// }
//
// public Manifest getManifest() {
// return _manifest;
// }
//
// public void setManifest(final Manifest pManifest) {
// _manifest = pManifest;
// }
//
//
// /**
// * Get count.
// *
// * @return count as int.
// */
// public int getCount() {
// return _count;
// }
//
// /**
// * Set count.
// *
// * @param count the value to set.
// */
// public void setCount(final int pCount) {
// _count = pCount;
// }
//
// /**
// * Get canvas.
// *
// * @return canvas as Canvas.
// */
// public Canvas getCanvas() {
// return _canvas;
// }
//
// /**
// * Set canvas.
// *
// * @param canvas the value to set.
// */
// public void setCanvas(final Canvas pCanvas) {
// _canvas = pCanvas;
// }
//
// public String toString() {
// return "Canvas=>" + _canvas.toString() + "\tCount=>" + _count;
// }
// }
//
// Path: src/main/java/uk/org/llgc/annotation/store/adapters/StoreAdapter.java
// public interface StoreAdapter {
//
// public void init(final AnnotationUtils pAnnoUtils);
//
// // CRUD annotations
// public Annotation addAnnotation(final Annotation pJson) throws IOException, IDConflictException, MalformedAnnotation;
// public Annotation updateAnnotation(final Annotation pJson) throws IOException, MalformedAnnotation;
// public Annotation getAnnotation(final String pId) throws IOException;
// public void deleteAnnotation(final String pAnnoId) throws IOException;
//
// public AnnotationList addAnnotationList(final AnnotationList pJson) throws IOException, IDConflictException, MalformedAnnotation;
//
// // CRUD manifests
// public String indexManifest(final Manifest pManifest) throws IOException;
// public List<Manifest> getManifests() throws IOException;
// public List<Manifest> getSkeletonManifests() throws IOException;
// public String getManifestId(final String pShortId) throws IOException;
// public Manifest getManifest(final String pShortId) throws IOException;
// public Manifest getManifestForCanvas(final Canvas pCanvasId) throws IOException;
//
// // CRUD canvas
// public Canvas resolveCanvas(final String pShortId) throws IOException;
// public void storeCanvas(final Canvas pCanvas) throws IOException;
//
// // Search
// public IIIFSearchResults search(final SearchQuery pQuery) throws IOException;
// public AnnotationList getAnnotationsFromPage(final Canvas pPage) throws IOException;
//
// // Used in ListAnnotations can we get rid?
// public AnnotationList getAllAnnotations() throws IOException;
// public List<PageAnnoCount> listAnnoPages() throws IOException;
// // Stats
// public List<PageAnnoCount> listAnnoPages(final Manifest pManifest) throws IOException;
// }
// Path: src/main/java/uk/org/llgc/annotation/store/ListAnnoPages.java
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import java.io.IOException;
import java.io.File;
import java.io.FileReader;
import java.io.BufferedReader;
import com.github.jsonldjava.utils.JsonUtils;
import org.apache.jena.rdf.model.Model;
import java.util.Map;
import java.util.List;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
import uk.org.llgc.annotation.store.data.PageAnnoCount;
import uk.org.llgc.annotation.store.adapters.StoreAdapter;
package uk.org.llgc.annotation.store;
public class ListAnnoPages extends HttpServlet {
protected static Logger _logger = LogManager.getLogger(ListAnnoPages.class.getName());
protected AnnotationUtils _annotationUtils = null;
protected StoreAdapter _store = null;
public void init(final ServletConfig pConfig) throws ServletException {
super.init(pConfig);
_annotationUtils = new AnnotationUtils(new File(super.getServletContext().getRealPath("/contexts")),StoreConfig.getConfig().getEncoder());
_store = StoreConfig.getConfig().getStore();
_store.init(_annotationUtils);
}
public void doGet(final HttpServletRequest pReq, final HttpServletResponse pRes) throws IOException {
|
List<PageAnnoCount> tAnnotations = _store.listAnnoPages();
|
glenrobson/SimpleAnnotationServer
|
src/main/java/uk/org/llgc/annotation/store/data/PageAnnoCount.java
|
// Path: src/main/java/uk/org/llgc/annotation/store/data/Manifest.java
// public class Manifest {
// protected String _URI = "";
// protected String _shortId = "";
// protected String _label = "";
// protected Map<String, Object> _json = null;
// protected List<Canvas> _canvases = new ArrayList<Canvas>();
//
//
// public Manifest() {
// }
//
// /*
// * Set manifest before it has a short id
// */
// public Manifest(final Map<String, Object> pJson) throws IOException {
// this(pJson, "");
// }
//
// public Manifest(final Map<String, Object> pJson, final String pShortId) throws IOException {
// this.setJson(pJson);
// if (!this.getType().equals("sc:Manifest")) {
// throw new IOException("Can't create manifest as type was incorrect. Expected sc:Manifest but got: " + this.getType());
// }
// if (this.getCanvases().isEmpty()) {
// throw new IOException("Can't load manifest as it has no pages.");
// }
// this.setShortId(pShortId);
// this.setURI((String)pJson.get("@id"));
// }
//
// public Map<String, Object> toJson() {
// return _json;
// }
//
// public void setJson(final Map<String, Object> pJson) {
// _json = pJson;
// this.setURI((String)_json.get("@id"));
// this.setLabel((String)_json.get("label")); // will fail if there is a multilingual string
//
// Map<String,Object> tSequence = null;
// if (_json.get("sequences") instanceof List ) {
// if (!((List)_json.get("sequences")).isEmpty()) {
// tSequence = ((List<Map<String, Object>>)_json.get("sequences")).get(0);
// }
// } else {
// tSequence = (Map<String, Object>)_json.get("sequences");
// }
//
// _canvases = new ArrayList<Canvas>();
// if (tSequence != null) {
// for (Map<String, Object> tCanvas : (List<Map<String, Object>>)tSequence.get("canvases")) {
// _canvases.add(new Canvas((String)tCanvas.get("@id"), (String)tCanvas.get("label")));
// }
// }
// }
//
// public String getType() {
// try {
// return (String)getJson().get("@type");
// } catch (IOException tExcpt) {
// tExcpt.printStackTrace();
// return null;
// }
// }
//
// public Canvas getCanvas(final String pId) {
// for (Canvas tCanvas : _canvases) {
// if (tCanvas.getId().equals(pId)) {
// return tCanvas;
// }
// }
// return null;
// }
//
// /**
// *
// */
// public Map<String,Object> getJson() throws IOException {
// if (_json == null) {
// this.setJson((Map<String,Object>)JsonUtils.fromInputStream(new URL(_URI).openStream()));
// }
// return _json;
// }
//
// /**
// * Get URI.
// *
// * @return URI as String.
// */
// public String getURI() {
// return _URI;
// }
//
// /**
// * Set URI.
// *
// * @param URI the value to set.
// */
// public void setURI(final String pURI) {
// _URI = pURI;
// }
//
// /**
// * Get shortId.
// *
// * @return shortId as String.
// */
// public String getShortId() {
// if (_shortId == null || _shortId.isEmpty()) {
// if (_URI.endsWith("manifest.json")) {
// String[] tURI = _URI.split("/");
// _shortId = tURI[tURI.length - 2];
// } else {
// try {
// _shortId = AnnotationUtils.getHash(_URI, "md5");
// } catch (IOException tExcpt) {
// tExcpt.printStackTrace();
// }
// }
// }
// return _shortId;
// }
//
// /**
// * Set shortId.
// *
// * @param shortId the value to set.
// */
// public void setShortId(final String pShortId) {
// _shortId = pShortId;
// }
//
// /**
// * Get label.
// *
// * @return label as String.
// */
// public String getLabel() {
// return _label;
// }
//
// /**
// * Set label.
// *
// * @param label the value to set.
// */
// public void setLabel(final String pLabel) {
// _label = pLabel;
// }
//
//
// public List<Canvas> getCanvases() {
// return _canvases;
// }
//
// public boolean equals(Object pOther) {
// if (pOther instanceof Manifest) {
// return _URI.equals(((Manifest)pOther).getURI());
// } else {
// return false;
// }
// }
//
// public String toString() {
// return "Id: " + _URI + "\nShortId: " + _shortId + "\nLabel: " + _label + "\nCanvases: " + _canvases.size();
// }
// }
|
import uk.org.llgc.annotation.store.data.Manifest;
|
package uk.org.llgc.annotation.store.data;
public class PageAnnoCount {
protected int _count = 0;
// These three properties should really be a canvas object...
protected Canvas _canvas = null;
protected String _pageId = "";
protected String _label = "";
protected String _shortId = "";
|
// Path: src/main/java/uk/org/llgc/annotation/store/data/Manifest.java
// public class Manifest {
// protected String _URI = "";
// protected String _shortId = "";
// protected String _label = "";
// protected Map<String, Object> _json = null;
// protected List<Canvas> _canvases = new ArrayList<Canvas>();
//
//
// public Manifest() {
// }
//
// /*
// * Set manifest before it has a short id
// */
// public Manifest(final Map<String, Object> pJson) throws IOException {
// this(pJson, "");
// }
//
// public Manifest(final Map<String, Object> pJson, final String pShortId) throws IOException {
// this.setJson(pJson);
// if (!this.getType().equals("sc:Manifest")) {
// throw new IOException("Can't create manifest as type was incorrect. Expected sc:Manifest but got: " + this.getType());
// }
// if (this.getCanvases().isEmpty()) {
// throw new IOException("Can't load manifest as it has no pages.");
// }
// this.setShortId(pShortId);
// this.setURI((String)pJson.get("@id"));
// }
//
// public Map<String, Object> toJson() {
// return _json;
// }
//
// public void setJson(final Map<String, Object> pJson) {
// _json = pJson;
// this.setURI((String)_json.get("@id"));
// this.setLabel((String)_json.get("label")); // will fail if there is a multilingual string
//
// Map<String,Object> tSequence = null;
// if (_json.get("sequences") instanceof List ) {
// if (!((List)_json.get("sequences")).isEmpty()) {
// tSequence = ((List<Map<String, Object>>)_json.get("sequences")).get(0);
// }
// } else {
// tSequence = (Map<String, Object>)_json.get("sequences");
// }
//
// _canvases = new ArrayList<Canvas>();
// if (tSequence != null) {
// for (Map<String, Object> tCanvas : (List<Map<String, Object>>)tSequence.get("canvases")) {
// _canvases.add(new Canvas((String)tCanvas.get("@id"), (String)tCanvas.get("label")));
// }
// }
// }
//
// public String getType() {
// try {
// return (String)getJson().get("@type");
// } catch (IOException tExcpt) {
// tExcpt.printStackTrace();
// return null;
// }
// }
//
// public Canvas getCanvas(final String pId) {
// for (Canvas tCanvas : _canvases) {
// if (tCanvas.getId().equals(pId)) {
// return tCanvas;
// }
// }
// return null;
// }
//
// /**
// *
// */
// public Map<String,Object> getJson() throws IOException {
// if (_json == null) {
// this.setJson((Map<String,Object>)JsonUtils.fromInputStream(new URL(_URI).openStream()));
// }
// return _json;
// }
//
// /**
// * Get URI.
// *
// * @return URI as String.
// */
// public String getURI() {
// return _URI;
// }
//
// /**
// * Set URI.
// *
// * @param URI the value to set.
// */
// public void setURI(final String pURI) {
// _URI = pURI;
// }
//
// /**
// * Get shortId.
// *
// * @return shortId as String.
// */
// public String getShortId() {
// if (_shortId == null || _shortId.isEmpty()) {
// if (_URI.endsWith("manifest.json")) {
// String[] tURI = _URI.split("/");
// _shortId = tURI[tURI.length - 2];
// } else {
// try {
// _shortId = AnnotationUtils.getHash(_URI, "md5");
// } catch (IOException tExcpt) {
// tExcpt.printStackTrace();
// }
// }
// }
// return _shortId;
// }
//
// /**
// * Set shortId.
// *
// * @param shortId the value to set.
// */
// public void setShortId(final String pShortId) {
// _shortId = pShortId;
// }
//
// /**
// * Get label.
// *
// * @return label as String.
// */
// public String getLabel() {
// return _label;
// }
//
// /**
// * Set label.
// *
// * @param label the value to set.
// */
// public void setLabel(final String pLabel) {
// _label = pLabel;
// }
//
//
// public List<Canvas> getCanvases() {
// return _canvases;
// }
//
// public boolean equals(Object pOther) {
// if (pOther instanceof Manifest) {
// return _URI.equals(((Manifest)pOther).getURI());
// } else {
// return false;
// }
// }
//
// public String toString() {
// return "Id: " + _URI + "\nShortId: " + _shortId + "\nLabel: " + _label + "\nCanvases: " + _canvases.size();
// }
// }
// Path: src/main/java/uk/org/llgc/annotation/store/data/PageAnnoCount.java
import uk.org.llgc.annotation.store.data.Manifest;
package uk.org.llgc.annotation.store.data;
public class PageAnnoCount {
protected int _count = 0;
// These three properties should really be a canvas object...
protected Canvas _canvas = null;
protected String _pageId = "";
protected String _label = "";
protected String _shortId = "";
|
protected Manifest _manifest = null;
|
07kit/07kit
|
src/main/java/com/kit/plugins/combat/CannonOverlayPlugin.java
|
// Path: src/main/java/com/kit/core/control/PluginManager.java
// public final class PluginManager {
// private final CopyOnWriteArrayList<Plugin.SchedulableRunnable> scheduledRunnables = new CopyOnWriteArrayList<>();
// private final CopyOnWriteArrayList<Plugin> enabledPlugins = new CopyOnWriteArrayList<>();
// private final ScheduledExecutorService lifecycleManager = Executors.newSingleThreadScheduledExecutor();
// private final Logger logger = Logger.getLogger(PluginManager.class);
//
// private final List<Plugin> plugins = new ArrayList<>();
// private final Events eventBus;
// private final Session session;
// private boolean pluginsStarted;
//
// public PluginManager(Session session) {
// this.eventBus = session.getEventBus();
// this.session = session;
// eventBus.register(this);
// }
//
// public void startPlugin(Plugin plugin) {
// eventBus.register(plugin);
// plugin.start();
// scheduledRunnables.addAll(plugin.getRunnables());
// enabledPlugins.add(plugin);
// }
//
// public void stopPlugin(Plugin plugin) {
// eventBus.deregister(plugin);
// scheduledRunnables.removeAll(plugin.getRunnables());
// plugin.stop();
// enabledPlugins.remove(plugin);
// }
//
// public void start() {
// try {
// // plugins.add(new SocialStreamPlugin(this));
// // plugins.add(new QuickHopPlugin(this));
// plugins.add(new HiscorePlugin(this));
// plugins.add(new GrandExchangePlugin(this));
// plugins.add(new XPTrackerPlugin(this));
// plugins.add(new NotesPlugin(this));
//
//
// plugins.add(new DebugPlugin(this));
//
// plugins.add(new InventoryMarkerPlugin(this));
//
// plugins.add(new ClanPlugin(this));
//
// plugins.add(new LootOverlayPlugin(this));
// plugins.add(new CombatPlugin(this));
// plugins.add(new FishingPlugin(this));
// plugins.add(new RememberMeOverlayPlugin(this));
// plugins.add(new WoodcuttingOverlayPlugin(this));
// plugins.add(new MiningOverlayPlugin(this));
// plugins.add(new BoostsOverlayPlugin(this));
// plugins.add(new RunecraftingOverlayPlugin(this));
// plugins.add(new BankValuatorPlugin(this));
// plugins.add(new FirstActionOverlayPlugin(this));
// plugins.add(new FoodOverlayPlugin(this));
// plugins.add(new NpcMarkerOverlayPlugin(this));
// plugins.add(new AgilityOverlayPlugin(this));
// //plugins.add(new CannonOverlayPlugin(this));
// plugins.add(new NpcKillCounterOverlayPlugin(this));
// plugins.add(new KillCounterOverlayPlugin(this));
// plugins.add(new LootProfitAndDropRecorder(this));
// plugins.add(new TradeOverlayPlugin(this));
// plugins.add(new WintertodtPlugin(this));
//
// plugins.add(new LevelUpCapturerPlugin(this));
// plugins.add(new QuickChatPlugin(this));
// plugins.add(new ItemExaminePricePlugin(this));
// plugins.add(new FriendClanChatMinimapMarkerPlugin(this));
// // plugins.add(new ClueScrollPlugin(this));
//
// plugins.add(new IdleNotifierPlugin(this));
// plugins.add(new LogoutNotifierPlugin(this));
// plugins.add(new AFKMentionNotifierPlugin(this));
// plugins.add(new TradeNotifierPlugin(this));
//
// // plugins.add(new WorldMapPlugin(this));
// // plugins.add(new DeathMarkerPlugin(this));
//
// plugins.add(new PlayerStatsPlugin(this));
//
// plugins.add(new TwitchChatPlugin(this));
//
// plugins.add(new AFKWatcherPlugin(this));
//
// lifecycleManager.scheduleAtFixedRate(this::updateLifecycle, 0, 500, TimeUnit.MILLISECONDS);
// } catch (Exception e) {
// logger.error("Error creating plugins", e);
// }
// }
//
// public void stop() {
// plugins.forEach(this::stopPlugin);
// }
//
// @EventHandler
// public void onClientLoop(ClientLoopEvent event) {
// for (Plugin.SchedulableRunnable runnable : scheduledRunnables) {
// long timePast = System.currentTimeMillis() - runnable.getLastRan();
// if (timePast > runnable.getMillis()) {
// try {
// runnable.run();
// } catch (Exception e) {
// logger.error("Error executing runnable", e);
// }
// }
// }
// }
//
// private void updateLifecycle() {
// plugins.forEach(plugin -> {
// if (plugin.isEnabled() && !enabledPlugins.contains(plugin)) {
// try {
// startPlugin(plugin);
// } catch (Exception e) {
// logger.error("Error starting plugin", e);
// }
// } else if (!plugin.isEnabled() && enabledPlugins.contains(plugin)) {
// try {
// stopPlugin(plugin);
// } catch (Exception e) {
// logger.error("Error stopping plugin", e);
// }
// }
// });
// pluginsStarted = true;
// }
//
// public boolean isPluginsStarted() {
// return pluginsStarted;
// }
//
// public boolean isReady() {
// return session.getState() == Session.State.ACTIVE;
// }
//
// public List<Plugin> getPlugins() {
// return plugins;
// }
// }
|
import com.kit.Application;
import com.kit.api.overlay.BoxOverlay;
import com.kit.api.plugin.Option;
import com.kit.api.plugin.Plugin;
import com.kit.api.plugin.Schedule;
import com.kit.api.util.ColorUtils;
import com.kit.api.util.PaintUtils;
import com.kit.core.control.PluginManager;
import com.kit.plugins.skills.mining.MiningOverlayPlugin;
import java.awt.*;
|
package com.kit.plugins.combat;
/**
* Created by Matt on 13/09/2016.
*/
public class CannonOverlayPlugin extends Plugin {
private final CannonBoxOverlay boxOverlay = new CannonBoxOverlay(this);
@Option(label = "Floating overlay", value = "false", type = Option.Type.TOGGLE)
private boolean floating;
int cannonBalls = 0;
|
// Path: src/main/java/com/kit/core/control/PluginManager.java
// public final class PluginManager {
// private final CopyOnWriteArrayList<Plugin.SchedulableRunnable> scheduledRunnables = new CopyOnWriteArrayList<>();
// private final CopyOnWriteArrayList<Plugin> enabledPlugins = new CopyOnWriteArrayList<>();
// private final ScheduledExecutorService lifecycleManager = Executors.newSingleThreadScheduledExecutor();
// private final Logger logger = Logger.getLogger(PluginManager.class);
//
// private final List<Plugin> plugins = new ArrayList<>();
// private final Events eventBus;
// private final Session session;
// private boolean pluginsStarted;
//
// public PluginManager(Session session) {
// this.eventBus = session.getEventBus();
// this.session = session;
// eventBus.register(this);
// }
//
// public void startPlugin(Plugin plugin) {
// eventBus.register(plugin);
// plugin.start();
// scheduledRunnables.addAll(plugin.getRunnables());
// enabledPlugins.add(plugin);
// }
//
// public void stopPlugin(Plugin plugin) {
// eventBus.deregister(plugin);
// scheduledRunnables.removeAll(plugin.getRunnables());
// plugin.stop();
// enabledPlugins.remove(plugin);
// }
//
// public void start() {
// try {
// // plugins.add(new SocialStreamPlugin(this));
// // plugins.add(new QuickHopPlugin(this));
// plugins.add(new HiscorePlugin(this));
// plugins.add(new GrandExchangePlugin(this));
// plugins.add(new XPTrackerPlugin(this));
// plugins.add(new NotesPlugin(this));
//
//
// plugins.add(new DebugPlugin(this));
//
// plugins.add(new InventoryMarkerPlugin(this));
//
// plugins.add(new ClanPlugin(this));
//
// plugins.add(new LootOverlayPlugin(this));
// plugins.add(new CombatPlugin(this));
// plugins.add(new FishingPlugin(this));
// plugins.add(new RememberMeOverlayPlugin(this));
// plugins.add(new WoodcuttingOverlayPlugin(this));
// plugins.add(new MiningOverlayPlugin(this));
// plugins.add(new BoostsOverlayPlugin(this));
// plugins.add(new RunecraftingOverlayPlugin(this));
// plugins.add(new BankValuatorPlugin(this));
// plugins.add(new FirstActionOverlayPlugin(this));
// plugins.add(new FoodOverlayPlugin(this));
// plugins.add(new NpcMarkerOverlayPlugin(this));
// plugins.add(new AgilityOverlayPlugin(this));
// //plugins.add(new CannonOverlayPlugin(this));
// plugins.add(new NpcKillCounterOverlayPlugin(this));
// plugins.add(new KillCounterOverlayPlugin(this));
// plugins.add(new LootProfitAndDropRecorder(this));
// plugins.add(new TradeOverlayPlugin(this));
// plugins.add(new WintertodtPlugin(this));
//
// plugins.add(new LevelUpCapturerPlugin(this));
// plugins.add(new QuickChatPlugin(this));
// plugins.add(new ItemExaminePricePlugin(this));
// plugins.add(new FriendClanChatMinimapMarkerPlugin(this));
// // plugins.add(new ClueScrollPlugin(this));
//
// plugins.add(new IdleNotifierPlugin(this));
// plugins.add(new LogoutNotifierPlugin(this));
// plugins.add(new AFKMentionNotifierPlugin(this));
// plugins.add(new TradeNotifierPlugin(this));
//
// // plugins.add(new WorldMapPlugin(this));
// // plugins.add(new DeathMarkerPlugin(this));
//
// plugins.add(new PlayerStatsPlugin(this));
//
// plugins.add(new TwitchChatPlugin(this));
//
// plugins.add(new AFKWatcherPlugin(this));
//
// lifecycleManager.scheduleAtFixedRate(this::updateLifecycle, 0, 500, TimeUnit.MILLISECONDS);
// } catch (Exception e) {
// logger.error("Error creating plugins", e);
// }
// }
//
// public void stop() {
// plugins.forEach(this::stopPlugin);
// }
//
// @EventHandler
// public void onClientLoop(ClientLoopEvent event) {
// for (Plugin.SchedulableRunnable runnable : scheduledRunnables) {
// long timePast = System.currentTimeMillis() - runnable.getLastRan();
// if (timePast > runnable.getMillis()) {
// try {
// runnable.run();
// } catch (Exception e) {
// logger.error("Error executing runnable", e);
// }
// }
// }
// }
//
// private void updateLifecycle() {
// plugins.forEach(plugin -> {
// if (plugin.isEnabled() && !enabledPlugins.contains(plugin)) {
// try {
// startPlugin(plugin);
// } catch (Exception e) {
// logger.error("Error starting plugin", e);
// }
// } else if (!plugin.isEnabled() && enabledPlugins.contains(plugin)) {
// try {
// stopPlugin(plugin);
// } catch (Exception e) {
// logger.error("Error stopping plugin", e);
// }
// }
// });
// pluginsStarted = true;
// }
//
// public boolean isPluginsStarted() {
// return pluginsStarted;
// }
//
// public boolean isReady() {
// return session.getState() == Session.State.ACTIVE;
// }
//
// public List<Plugin> getPlugins() {
// return plugins;
// }
// }
// Path: src/main/java/com/kit/plugins/combat/CannonOverlayPlugin.java
import com.kit.Application;
import com.kit.api.overlay.BoxOverlay;
import com.kit.api.plugin.Option;
import com.kit.api.plugin.Plugin;
import com.kit.api.plugin.Schedule;
import com.kit.api.util.ColorUtils;
import com.kit.api.util.PaintUtils;
import com.kit.core.control.PluginManager;
import com.kit.plugins.skills.mining.MiningOverlayPlugin;
import java.awt.*;
package com.kit.plugins.combat;
/**
* Created by Matt on 13/09/2016.
*/
public class CannonOverlayPlugin extends Plugin {
private final CannonBoxOverlay boxOverlay = new CannonBoxOverlay(this);
@Option(label = "Floating overlay", value = "false", type = Option.Type.TOGGLE)
private boolean floating;
int cannonBalls = 0;
|
public CannonOverlayPlugin(PluginManager manager) {
|
07kit/07kit
|
src/main/java/com/kit/api/wrappers/World.java
|
// Path: src/main/java/com/kit/api/MethodContext.java
// public class MethodContext {
//
// public static final int FIXED_VIEWPORT_WIDTH = 512;
// public static final int FIXED_VIEWPORT_HEIGHT = 334;
//
//
// public Logger logger = new LoggerImpl();
//
//
// public LocalPlayer player = new LocalPlayer(this);
//
//
// public Viewport viewport = new ViewportImpl(this);
//
//
// public Widgets widgets = new WidgetsImpl(this);
//
//
// public Players players = new PlayersImpl(this);
//
//
// public Npcs npcs = new NpcsImpl(this);
//
//
// public Objects objects = new ObjectsImpl(this);
//
//
// public Loots loot = new LootsImpl(this);
//
//
// public Menu menu = new MenuImpl(this);
//
//
// public Worlds worlds = new WorldsImpl(this);
//
//
// public Inventory inventory = new InventoryImpl(this);
//
//
// public Equipment equipment = new EquipmentImpl(this);
//
//
// public Skills skills = new SkillsImpl(this);
//
//
// public Tabs tabs = new TabsImpl(this);
//
//
// public Camera camera = new CameraImpl(this);
//
//
// public Bank bank = new BankImpl(this);
//
//
// public Magic magic = new MagicImpl(this);
//
//
// public Minimap minimap = new MinimapImpl(this);
//
//
// public Mouse mouse = new MouseImpl(this);
//
//
// public Settings settings = new SettingsImpl(this);
//
// public Shops shops = new ShopsImpl(this);
//
//
// public Prayers prayers = new PrayersImpl(this);
//
//
// public Screen screen = new ScreenImpl(this);
//
// public Hiscores hiscores = new HiscoresImpl(this);
//
// public Composites composites = new CompositesImpl(this);
//
// public UserInterface ui = new UserInterfaceImpl();
//
// public Game game = new GameImpl(this);
//
// public Friends friends = new FriendsImpl(this);
//
// public ClanChat clanChat = new ClanChatImpl(this);
//
// public IClient client() {
// return Session.get().getClient();
// }
//
// public boolean inResizableMode() {
// return client().getViewportWidth() != FIXED_VIEWPORT_WIDTH ||
// client().getViewportHeight() != FIXED_VIEWPORT_HEIGHT;
// }
//
// public boolean isLoggedIn() {
// return client() != null &&
// client().getLoginIndex() >= 30 &&
// widgets.find(378, 6) == null;
// }
//
// }
//
// Path: src/main/java/com/kit/api/MethodContext.java
// public class MethodContext {
//
// public static final int FIXED_VIEWPORT_WIDTH = 512;
// public static final int FIXED_VIEWPORT_HEIGHT = 334;
//
//
// public Logger logger = new LoggerImpl();
//
//
// public LocalPlayer player = new LocalPlayer(this);
//
//
// public Viewport viewport = new ViewportImpl(this);
//
//
// public Widgets widgets = new WidgetsImpl(this);
//
//
// public Players players = new PlayersImpl(this);
//
//
// public Npcs npcs = new NpcsImpl(this);
//
//
// public Objects objects = new ObjectsImpl(this);
//
//
// public Loots loot = new LootsImpl(this);
//
//
// public Menu menu = new MenuImpl(this);
//
//
// public Worlds worlds = new WorldsImpl(this);
//
//
// public Inventory inventory = new InventoryImpl(this);
//
//
// public Equipment equipment = new EquipmentImpl(this);
//
//
// public Skills skills = new SkillsImpl(this);
//
//
// public Tabs tabs = new TabsImpl(this);
//
//
// public Camera camera = new CameraImpl(this);
//
//
// public Bank bank = new BankImpl(this);
//
//
// public Magic magic = new MagicImpl(this);
//
//
// public Minimap minimap = new MinimapImpl(this);
//
//
// public Mouse mouse = new MouseImpl(this);
//
//
// public Settings settings = new SettingsImpl(this);
//
// public Shops shops = new ShopsImpl(this);
//
//
// public Prayers prayers = new PrayersImpl(this);
//
//
// public Screen screen = new ScreenImpl(this);
//
// public Hiscores hiscores = new HiscoresImpl(this);
//
// public Composites composites = new CompositesImpl(this);
//
// public UserInterface ui = new UserInterfaceImpl();
//
// public Game game = new GameImpl(this);
//
// public Friends friends = new FriendsImpl(this);
//
// public ClanChat clanChat = new ClanChatImpl(this);
//
// public IClient client() {
// return Session.get().getClient();
// }
//
// public boolean inResizableMode() {
// return client().getViewportWidth() != FIXED_VIEWPORT_WIDTH ||
// client().getViewportHeight() != FIXED_VIEWPORT_HEIGHT;
// }
//
// public boolean isLoggedIn() {
// return client() != null &&
// client().getLoginIndex() >= 30 &&
// widgets.find(378, 6) == null;
// }
//
// }
|
import com.kit.api.MethodContext;
import com.kit.api.MethodContext;
|
package com.kit.api.wrappers;
/**
* A simple class which represents a World ingame.
*
* * @author tobiewarburton
*/
public class World {
private String country;
private int worldNumber;
private int players;
private boolean members;
private String activity;
private String domain;
|
// Path: src/main/java/com/kit/api/MethodContext.java
// public class MethodContext {
//
// public static final int FIXED_VIEWPORT_WIDTH = 512;
// public static final int FIXED_VIEWPORT_HEIGHT = 334;
//
//
// public Logger logger = new LoggerImpl();
//
//
// public LocalPlayer player = new LocalPlayer(this);
//
//
// public Viewport viewport = new ViewportImpl(this);
//
//
// public Widgets widgets = new WidgetsImpl(this);
//
//
// public Players players = new PlayersImpl(this);
//
//
// public Npcs npcs = new NpcsImpl(this);
//
//
// public Objects objects = new ObjectsImpl(this);
//
//
// public Loots loot = new LootsImpl(this);
//
//
// public Menu menu = new MenuImpl(this);
//
//
// public Worlds worlds = new WorldsImpl(this);
//
//
// public Inventory inventory = new InventoryImpl(this);
//
//
// public Equipment equipment = new EquipmentImpl(this);
//
//
// public Skills skills = new SkillsImpl(this);
//
//
// public Tabs tabs = new TabsImpl(this);
//
//
// public Camera camera = new CameraImpl(this);
//
//
// public Bank bank = new BankImpl(this);
//
//
// public Magic magic = new MagicImpl(this);
//
//
// public Minimap minimap = new MinimapImpl(this);
//
//
// public Mouse mouse = new MouseImpl(this);
//
//
// public Settings settings = new SettingsImpl(this);
//
// public Shops shops = new ShopsImpl(this);
//
//
// public Prayers prayers = new PrayersImpl(this);
//
//
// public Screen screen = new ScreenImpl(this);
//
// public Hiscores hiscores = new HiscoresImpl(this);
//
// public Composites composites = new CompositesImpl(this);
//
// public UserInterface ui = new UserInterfaceImpl();
//
// public Game game = new GameImpl(this);
//
// public Friends friends = new FriendsImpl(this);
//
// public ClanChat clanChat = new ClanChatImpl(this);
//
// public IClient client() {
// return Session.get().getClient();
// }
//
// public boolean inResizableMode() {
// return client().getViewportWidth() != FIXED_VIEWPORT_WIDTH ||
// client().getViewportHeight() != FIXED_VIEWPORT_HEIGHT;
// }
//
// public boolean isLoggedIn() {
// return client() != null &&
// client().getLoginIndex() >= 30 &&
// widgets.find(378, 6) == null;
// }
//
// }
//
// Path: src/main/java/com/kit/api/MethodContext.java
// public class MethodContext {
//
// public static final int FIXED_VIEWPORT_WIDTH = 512;
// public static final int FIXED_VIEWPORT_HEIGHT = 334;
//
//
// public Logger logger = new LoggerImpl();
//
//
// public LocalPlayer player = new LocalPlayer(this);
//
//
// public Viewport viewport = new ViewportImpl(this);
//
//
// public Widgets widgets = new WidgetsImpl(this);
//
//
// public Players players = new PlayersImpl(this);
//
//
// public Npcs npcs = new NpcsImpl(this);
//
//
// public Objects objects = new ObjectsImpl(this);
//
//
// public Loots loot = new LootsImpl(this);
//
//
// public Menu menu = new MenuImpl(this);
//
//
// public Worlds worlds = new WorldsImpl(this);
//
//
// public Inventory inventory = new InventoryImpl(this);
//
//
// public Equipment equipment = new EquipmentImpl(this);
//
//
// public Skills skills = new SkillsImpl(this);
//
//
// public Tabs tabs = new TabsImpl(this);
//
//
// public Camera camera = new CameraImpl(this);
//
//
// public Bank bank = new BankImpl(this);
//
//
// public Magic magic = new MagicImpl(this);
//
//
// public Minimap minimap = new MinimapImpl(this);
//
//
// public Mouse mouse = new MouseImpl(this);
//
//
// public Settings settings = new SettingsImpl(this);
//
// public Shops shops = new ShopsImpl(this);
//
//
// public Prayers prayers = new PrayersImpl(this);
//
//
// public Screen screen = new ScreenImpl(this);
//
// public Hiscores hiscores = new HiscoresImpl(this);
//
// public Composites composites = new CompositesImpl(this);
//
// public UserInterface ui = new UserInterfaceImpl();
//
// public Game game = new GameImpl(this);
//
// public Friends friends = new FriendsImpl(this);
//
// public ClanChat clanChat = new ClanChatImpl(this);
//
// public IClient client() {
// return Session.get().getClient();
// }
//
// public boolean inResizableMode() {
// return client().getViewportWidth() != FIXED_VIEWPORT_WIDTH ||
// client().getViewportHeight() != FIXED_VIEWPORT_HEIGHT;
// }
//
// public boolean isLoggedIn() {
// return client() != null &&
// client().getLoginIndex() >= 30 &&
// widgets.find(378, 6) == null;
// }
//
// }
// Path: src/main/java/com/kit/api/wrappers/World.java
import com.kit.api.MethodContext;
import com.kit.api.MethodContext;
package com.kit.api.wrappers;
/**
* A simple class which represents a World ingame.
*
* * @author tobiewarburton
*/
public class World {
private String country;
private int worldNumber;
private int players;
private boolean members;
private String activity;
private String domain;
|
private final MethodContext ctx;
|
07kit/07kit
|
src/main/java/com/kit/api/event/Events.java
|
// Path: src/main/java/com/kit/api/event/exeption/HandlerInvocationException.java
// public class HandlerInvocationException extends RuntimeException {
//
// public HandlerInvocationException(String message, Throwable t) {
// super(message, t);
// }
//
// }
|
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.kit.api.wrappers.Loot;
import com.kit.game.engine.IBitBuffer;
import com.kit.game.engine.extension.CanvasExtension;
import org.apache.log4j.Logger;
import org.apache.log4j.net.SyslogAppender;
import com.kit.api.event.exeption.HandlerInvocationException;
import com.kit.api.wrappers.Loot;
import com.kit.core.Session;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static java.lang.reflect.Modifier.isStatic;
|
private Object object;
private Method method;
public EventHandlerBridge(Object object, Method method) {
this.object = object;
this.method = method;
}
public Class<?> getType() {
return method.getParameterTypes()[0];
}
/**
* Checks if the method is a valid EventHandler
*
* @return true if it is a valid EventHandler else false.
*/
public boolean validate() {
return method.getParameterTypes().length == 1 && !isStatic(method.getModifiers());
}
/**
* Calls the EventHandler method and passes the object as the argument.
*
* @param arg object to pass into the method.
*/
public void handle(Object arg) {
try {
method.invoke(this.object, arg);
} catch (Exception e) {
|
// Path: src/main/java/com/kit/api/event/exeption/HandlerInvocationException.java
// public class HandlerInvocationException extends RuntimeException {
//
// public HandlerInvocationException(String message, Throwable t) {
// super(message, t);
// }
//
// }
// Path: src/main/java/com/kit/api/event/Events.java
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.kit.api.wrappers.Loot;
import com.kit.game.engine.IBitBuffer;
import com.kit.game.engine.extension.CanvasExtension;
import org.apache.log4j.Logger;
import org.apache.log4j.net.SyslogAppender;
import com.kit.api.event.exeption.HandlerInvocationException;
import com.kit.api.wrappers.Loot;
import com.kit.core.Session;
import java.awt.event.FocusEvent;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.lang.reflect.Method;
import java.util.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import static java.lang.reflect.Modifier.isStatic;
private Object object;
private Method method;
public EventHandlerBridge(Object object, Method method) {
this.object = object;
this.method = method;
}
public Class<?> getType() {
return method.getParameterTypes()[0];
}
/**
* Checks if the method is a valid EventHandler
*
* @return true if it is a valid EventHandler else false.
*/
public boolean validate() {
return method.getParameterTypes().length == 1 && !isStatic(method.getModifiers());
}
/**
* Calls the EventHandler method and passes the object as the argument.
*
* @param arg object to pass into the method.
*/
public void handle(Object arg) {
try {
method.invoke(this.object, arg);
} catch (Exception e) {
|
throw new HandlerInvocationException("Handler invocation failed.", e);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.