id
stringlengths 7
14
| text
stringlengths 1
106k
|
---|---|
502000_0
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_1
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_2
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_3
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_4
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_5
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_6
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_7
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_8
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
502000_9
|
public Object setProperty(String name, String value) {
String prev = super.getProperty(name);
super.setProperty(name, value);
replace(name, new HashSet<String>());
return prev;
}
|
505113_0
|
public void setUseLevelAsKey(final boolean useLevelAsKey)
{
this.useLevelAsKey = useLevelAsKey;
}
|
505113_1
|
public void setUseLevelAsPriority(final boolean useLevelAsPriority)
{
this.useLevelAsPriority = useLevelAsPriority;
}
|
505113_2
|
@Override
public void stop()
{
try
{
this.xmpp.disconnect();
}
catch(final Exception ignored)
{
System.err.println("Ignored exception:");
ignored.printStackTrace(System.err);
}
finally
{
super.stop();
}
}
|
508590_0
|
public Vertex addVertex(final Value value) {
return store.addVertex(value);
}
|
508590_1
|
public Vertex getVertex(final Value value) {
return store.getVertex(value);
}
|
508590_2
|
public synchronized void load(final File fileOrDirectory) throws Exception {
LOGGER.info("loading from " + fileOrDirectory);
SailConnection c = sail.getConnection();
try {
c.begin();
long startTime = System.currentTimeMillis();
long count = loadFile(fileOrDirectory, c);
// commit leftover statements
c.commit();
long endTime = System.currentTimeMillis();
LOGGER.info("loaded " + count + " statements in " + (endTime - startTime) + "ms");
} finally {
c.rollback();
c.close();
}
}
|
508590_3
|
void setFirstClassEdges(final boolean firstClassEdges) {
this.firstClassEdges = firstClassEdges;
}
|
511297_0
|
@Override
public Object convertCassTypeToObjType(PropertyMappingDefinition md, byte[] value) {
BigInteger bigInt = new BigInteger(value);
// determine our target integer type and then go from there on the
// conversion method
Class<?> targetClass = md.getPropDesc().getPropertyType();
if (targetClass.equals(Integer.class) || targetClass.equals(int.class)) {
return Integer.valueOf(bigInt.intValue());
} else if (targetClass.equals(Long.class) || targetClass.equals(long.class)) {
return Long.valueOf(bigInt.longValue());
} else if (targetClass.equals(Short.class) || targetClass.equals(short.class)) {
return Short.valueOf(bigInt.shortValue());
} else if (targetClass.equals(Byte.class) || targetClass.equals(byte.class)) {
return Byte.valueOf(bigInt.byteValue());
} else if (targetClass.equals(BigInteger.class)) {
return bigInt;
} else {
throw new HectorObjectMapperException("Column, " + md.getColName()
+ ", cannot be converted using " + getClass().getSimpleName()
+ " because POJO property, " + md.getPropDesc().getName() + ", of type "
+ md.getPropDesc().getPropertyType().getName()
+ " is not an integer type (in a mathematical context)");
}
}
|
511297_1
|
<T> T createObject(CFMappingDef<T> cfMapDef, Object pkObj, ColumnSlice<String, byte[]> slice) {
if (slice.getColumns().isEmpty()) {
return null;
}
CFMappingDef<? extends T> cfMapDefInstance = determineClassType(cfMapDef, slice);
T obj;
try {
try {
obj = cfMapDefInstance.getEffectiveClass().newInstance();
} catch (InstantiationException e) {
throw new HectorObjectMapperException(cfMapDefInstance.getEffectiveClass().getName()
+ ", must have default constructor", e);
}
setIdIfCan(cfMapDef, obj, pkObj);
for (HColumn<String, byte[]> col : slice.getColumns()) {
String colName = col.getName();
PropertyMappingDefinition md = cfMapDefInstance.getPropMapByColumnName(colName);
if (null != md && null != md.getPropDesc()) {
if (!md.isCollectionType()) {
setPropertyUsingColumn(obj, col, md);
} else {
collMapperHelper.instantiateCollection(obj, col, md);
}
} else if (collMapperHelper.addColumnToCollection(cfMapDefInstance, obj, colName,
col.getValue())) {
continue;
}
// if this is a derived class then don't need to save discriminator
// column value
else if (null != cfMapDef.getDiscColumn() && colName.equals(cfMapDef.getDiscColumn())) {
continue;
} else {
addToExtraIfCan(obj, cfMapDef, col);
}
}
return obj;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (SecurityException e) {
throw new RuntimeException(e);
}
}
|
511297_2
|
private Collection<HColumn<String, byte[]>> createColumnSet(Object obj) {
Map<String, HColumn<String, byte[]>> map = createColumnMap(obj);
if (null != map) {
return map.values();
} else {
return null;
}
}
|
511297_3
|
<T> T createObject(CFMappingDef<T> cfMapDef, Object pkObj, ColumnSlice<String, byte[]> slice) {
if (slice.getColumns().isEmpty()) {
return null;
}
CFMappingDef<? extends T> cfMapDefInstance = determineClassType(cfMapDef, slice);
T obj;
try {
try {
obj = cfMapDefInstance.getEffectiveClass().newInstance();
} catch (InstantiationException e) {
throw new HectorObjectMapperException(cfMapDefInstance.getEffectiveClass().getName()
+ ", must have default constructor", e);
}
setIdIfCan(cfMapDef, obj, pkObj);
for (HColumn<String, byte[]> col : slice.getColumns()) {
String colName = col.getName();
PropertyMappingDefinition md = cfMapDefInstance.getPropMapByColumnName(colName);
if (null != md && null != md.getPropDesc()) {
if (!md.isCollectionType()) {
setPropertyUsingColumn(obj, col, md);
} else {
collMapperHelper.instantiateCollection(obj, col, md);
}
} else if (collMapperHelper.addColumnToCollection(cfMapDefInstance, obj, colName,
col.getValue())) {
continue;
}
// if this is a derived class then don't need to save discriminator
// column value
else if (null != cfMapDef.getDiscColumn() && colName.equals(cfMapDef.getDiscColumn())) {
continue;
} else {
addToExtraIfCan(obj, cfMapDef, col);
}
}
return obj;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
} catch (SecurityException e) {
throw new RuntimeException(e);
}
}
|
511297_4
|
public static boolean isSerializable(Class<?> clazz) {
return isImplementedBy(clazz, Serializable.class);
}
|
511297_5
|
public static boolean isSerializable(Class<?> clazz) {
return isImplementedBy(clazz, Serializable.class);
}
|
511297_6
|
<T> Map<String, HColumn<String, byte[]>> createColumnMap(T obj) {
if (null == obj) {
throw new IllegalArgumentException("Class type cannot be null");
}
@SuppressWarnings("unchecked")
CFMappingDef<T> cfMapDef = (CFMappingDef<T>) cacheMgr.getCfMapDef((Class<T>) obj.getClass(),
true);
try {
Map<String, HColumn<String, byte[]>> colSet = new HashMap<String, HColumn<String, byte[]>>();
Collection<PropertyMappingDefinition> coll = cfMapDef.getAllProperties();
for (PropertyMappingDefinition md : coll) {
Collection<HColumn<String, byte[]>> colColl = createColumnsFromProperty(obj, md);
if (null != colColl) {
for (HColumn<String, byte[]> col : colColl) {
colSet.put(col.getName(), col);
}
}
}
if (null != cfMapDef.getCfBaseMapDef()) {
CFMappingDef<?> cfSuperMapDef = cfMapDef.getCfBaseMapDef();
String discColName = cfSuperMapDef.getDiscColumn();
DiscriminatorType discType = cfSuperMapDef.getDiscType();
colSet.put(
discColName,
createHColumn(discColName, convertDiscTypeToColValue(discType, cfMapDef.getDiscValue())));
}
addAnonymousProperties(obj, cfMapDef, colSet);
return colSet;
} catch (SecurityException e) {
throw new RuntimeException(e);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
|
511297_7
|
<T> Map<String, HColumn<String, byte[]>> createColumnMap(T obj) {
if (null == obj) {
throw new IllegalArgumentException("Class type cannot be null");
}
@SuppressWarnings("unchecked")
CFMappingDef<T> cfMapDef = (CFMappingDef<T>) cacheMgr.getCfMapDef((Class<T>) obj.getClass(),
true);
try {
Map<String, HColumn<String, byte[]>> colSet = new HashMap<String, HColumn<String, byte[]>>();
Collection<PropertyMappingDefinition> coll = cfMapDef.getAllProperties();
for (PropertyMappingDefinition md : coll) {
Collection<HColumn<String, byte[]>> colColl = createColumnsFromProperty(obj, md);
if (null != colColl) {
for (HColumn<String, byte[]> col : colColl) {
colSet.put(col.getName(), col);
}
}
}
if (null != cfMapDef.getCfBaseMapDef()) {
CFMappingDef<?> cfSuperMapDef = cfMapDef.getCfBaseMapDef();
String discColName = cfSuperMapDef.getDiscColumn();
DiscriminatorType discType = cfSuperMapDef.getDiscType();
colSet.put(
discColName,
createHColumn(discColName, convertDiscTypeToColValue(discType, cfMapDef.getDiscValue())));
}
addAnonymousProperties(obj, cfMapDef, colSet);
return colSet;
} catch (SecurityException e) {
throw new RuntimeException(e);
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalArgumentException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
|
511297_8
|
@Override
public <T> void parse(ClassCacheMgr cacheMgr, Annotation anno, CFMappingDef<T> cfMapDef) {
if (anno instanceof IdClass) {
parseIdClassAnnotation(cacheMgr, (IdClass) anno, cfMapDef);
} else {
throw new HectorObjectMapperException("This class cannot parse annotation, "
+ anno.getClass().getSimpleName());
}
}
|
511297_9
|
@Override
public <T> void validateAndSetDefaults(ClassCacheMgr cacheMgr, CFMappingDef<T> cfMapDef) {
if (cfMapDef.isBaseEntity()) {
validateBaseClassInheritance(cfMapDef);
} else if (cfMapDef.isPersistableDerivedEntity()) {
validateDerivedClassInheritance(cfMapDef);
} else if (!cfMapDef.isNonPersistableDerivedEntity()) {
if (null != cacheMgr.findBaseClassViaMappings(cfMapDef))
throw new HectorObjectMapperException("@" + Inheritance.class.getSimpleName()
+ " found in class hierarchy, but no @" + DiscriminatorValue.class.getSimpleName()
+ " - quitting");
}
}
|
514315_0
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "vertices")
@ExtensionDescriptor(description = "get a set of vertices from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getVertices(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Vertex vertexFound = graph.getVertex(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (vertexFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertexFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Vertex.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Vertex> verticesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
verticesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Vertex> verticesFound = graph.getVertices(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of vertices [" + values + "]", generateErrorJson());
}
}
|
514315_1
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "vertices")
@ExtensionDescriptor(description = "get a set of vertices from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getVertices(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Vertex vertexFound = graph.getVertex(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (vertexFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertexFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Vertex.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Vertex> verticesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
verticesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Vertex> verticesFound = graph.getVertices(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of vertices [" + values + "]", generateErrorJson());
}
}
|
514315_2
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "vertices")
@ExtensionDescriptor(description = "get a set of vertices from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getVertices(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Vertex vertexFound = graph.getVertex(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (vertexFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertexFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Vertex.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Vertex> verticesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
verticesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Vertex> verticesFound = graph.getVertices(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of vertices [" + values + "]", generateErrorJson());
}
}
|
514315_3
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "vertices")
@ExtensionDescriptor(description = "get a set of vertices from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getVertices(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Vertex vertexFound = graph.getVertex(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (vertexFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertexFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Vertex.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Vertex> verticesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
verticesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Vertex> verticesFound = graph.getVertices(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of vertices [" + values + "]", generateErrorJson());
}
}
|
514315_4
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "vertices")
@ExtensionDescriptor(description = "get a set of vertices from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getVertices(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Vertex vertexFound = graph.getVertex(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (vertexFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertexFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Vertex.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Vertex> verticesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
verticesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Vertex> verticesFound = graph.getVertices(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of vertices [" + values + "]", generateErrorJson());
}
}
|
514315_5
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "vertices")
@ExtensionDescriptor(description = "get a set of vertices from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getVertices(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Vertex vertexFound = graph.getVertex(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (vertexFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertexFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Vertex.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Vertex> verticesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
verticesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Vertex> verticesFound = graph.getVertices(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of vertices [" + values + "]", generateErrorJson());
}
}
|
514315_6
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "vertices")
@ExtensionDescriptor(description = "get a set of vertices from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getVertices(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Vertex vertexFound = graph.getVertex(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (vertexFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertexFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Vertex.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Vertex> verticesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
verticesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Vertex> verticesFound = graph.getVertices(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Vertex vertex : verticesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(vertex, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of vertices [" + values + "]", generateErrorJson());
}
}
|
514315_7
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "edges")
@ExtensionDescriptor(description = "get a set of edges from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getEdges(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Edge edgeFound = graph.getEdge(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (edgeFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(edgeFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Edge.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Edge> edgesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Edge edge : edgesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(edge, returnKeys, mode));
}
edgesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Edge> edgesFound = graph.getEdges(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Edge edge : edgesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(edge, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of edges [" + values + "]", generateErrorJson());
}
}
|
514315_8
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "edges")
@ExtensionDescriptor(description = "get a set of edges from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getEdges(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Edge edgeFound = graph.getEdge(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (edgeFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(edgeFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Edge.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Edge> edgesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Edge edge : edgesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(edge, returnKeys, mode));
}
edgesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Edge> edgesFound = graph.getEdges(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Edge edge : edgesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(edge, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of edges [" + values + "]", generateErrorJson());
}
}
|
514315_9
|
@ExtensionDefinition(extensionPoint = ExtensionPoint.GRAPH, method = HttpMethod.GET, path = "edges")
@ExtensionDescriptor(description = "get a set of edges from the graph.",
api = {
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.SHOW_TYPES, description = API_SHOW_TYPES),
@ExtensionApi(parameterName = Tokens.REXSTER + "." + Tokens.RETURN_KEYS, description = API_RETURN_KEYS),
@ExtensionApi(parameterName = "values", description = API_VALUES),
@ExtensionApi(parameterName = "type", description = API_TYPE),
@ExtensionApi(parameterName = "key", description = API_KEY)
})
public ExtensionResponse getEdges(@RexsterContext final RexsterResourceContext context,
@RexsterContext final Graph graph) {
final JSONObject requestObject = context.getRequestObject();
final JSONArray values = requestObject.optJSONArray("values");
final String type = requestObject.optString("type", "id");
final String key = requestObject.optString("key");
final ExtensionResponse error = checkParameters(context, values, type, key);
if (error != null) {
return error;
}
final boolean showTypes = RequestObjectHelper.getShowTypes(requestObject);
final GraphSONMode mode = showTypes ? GraphSONMode.EXTENDED : GraphSONMode.NORMAL;
final Set<String> returnKeys = RequestObjectHelper.getReturnKeys(requestObject, WILDCARD);
try {
final JSONArray jsonArray = new JSONArray();
if (type.equals("id")) {
for (int ix = 0; ix < values.length(); ix++) {
final Edge edgeFound = graph.getEdge(ElementHelper.getTypedPropertyValue(values.optString(ix)));
if (edgeFound != null) {
jsonArray.put(GraphSONUtility.jsonFromElement(edgeFound, returnKeys, mode));
}
}
} else if (type.equals("index")) {
Index idx = ((IndexableGraph)graph).getIndex(key, Edge.class);
for (int ix = 0; ix < values.length(); ix++) {
CloseableIterable<Edge> edgesFound = idx.get(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Edge edge : edgesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(edge, returnKeys, mode));
}
edgesFound.close();
}
} else if (type.equals("keyindex")) {
for (int ix = 0; ix < values.length(); ix++) {
Iterable<Edge> edgesFound = graph.getEdges(key, ElementHelper.getTypedPropertyValue(values.optString(ix)));
for (Edge edge : edgesFound) {
jsonArray.put(GraphSONUtility.jsonFromElement(edge, returnKeys, mode));
}
}
}
final HashMap<String, Object> resultMap = new HashMap<String, Object>();
resultMap.put(Tokens.SUCCESS, true);
resultMap.put(Tokens.RESULTS, jsonArray);
final JSONObject resultObject = new JSONObject(resultMap);
return ExtensionResponse.ok(resultObject);
} catch (Exception mqe) {
logger.error(mqe);
return ExtensionResponse.error(
"Error retrieving batch of edges [" + values + "]", generateErrorJson());
}
}
|
520116_0
|
@Override
public void validateValue(Property property, Object value) throws ValidationException {
if (value != null || propertyDescriptor.isNotNull()) {
if (!propertyDescriptor.getValueSet().contains(value)) {
throw new ValidationException(MessageFormat.format("Value for ''{0}'' is invalid: ''{1}''",
property.getDescriptor().getDisplayName(), value));
}
}
}
|
520116_1
|
@Override
public void validateValue(Property property, Object value) throws ValidationException {
if (value != null || propertyDescriptor.isNotNull()) {
if (!propertyDescriptor.getValueSet().contains(value)) {
throw new ValidationException(MessageFormat.format("Value for ''{0}'' is invalid: ''{1}''",
property.getDescriptor().getDisplayName(), value));
}
}
}
|
520116_2
|
@Override
public void validateValue(Property property, Object value) throws ValidationException {
if (value != null || propertyDescriptor.isNotNull()) {
if (!propertyDescriptor.getValueSet().contains(value)) {
throw new ValidationException(MessageFormat.format("Value for ''{0}'' is invalid: ''{1}''",
property.getDescriptor().getDisplayName(), value));
}
}
}
|
520116_3
|
@Override
public void validateValue(Property property, Object value) throws ValidationException {
if (value != null || propertyDescriptor.isNotNull()) {
if (!propertyDescriptor.getValueSet().contains(value)) {
throw new ValidationException(MessageFormat.format("Value for ''{0}'' is invalid: ''{1}''",
property.getDescriptor().getDisplayName(), value));
}
}
}
|
520116_4
|
@Override
public Object convertDomToValue(DomElement parentElement, Object value) throws ConversionException, ValidationException {
PropertySet propertySet;
if (value == null) {
value = createValueInstance(parentElement, getValueType());
propertySet = getPropertySet(value);
propertySet.setDefaultValues();
} else {
propertySet = getPropertySet(value);
}
convertDomToPropertySet(parentElement, propertySet);
return value;
}
|
520116_5
|
@Override
public Object convertDomToValue(DomElement parentElement, Object value) throws ConversionException, ValidationException {
PropertySet propertySet;
if (value == null) {
value = createValueInstance(parentElement, getValueType());
propertySet = getPropertySet(value);
propertySet.setDefaultValues();
} else {
propertySet = getPropertySet(value);
}
convertDomToPropertySet(parentElement, propertySet);
return value;
}
|
520116_6
|
@Override
public void convertValueToDom(Object value, DomElement parentElement) throws ConversionException {
PropertySet propertySet = getPropertySet(value);
for (Property property : propertySet.getProperties()) {
convertPropertyToDom(property, parentElement);
}
}
|
520116_7
|
@Override
public void convertValueToDom(Object value, DomElement parentElement) throws ConversionException {
PropertySet propertySet = getPropertySet(value);
for (Property property : propertySet.getProperties()) {
convertPropertyToDom(property, parentElement);
}
}
|
520116_8
|
@Override
public void convertValueToDom(Object value, DomElement parentElement) throws ConversionException {
PropertySet propertySet = getPropertySet(value);
for (Property property : propertySet.getProperties()) {
convertPropertyToDom(property, parentElement);
}
}
|
520116_9
|
@Override
public Object convertDomToValue(DomElement parentElement, Object value) throws ConversionException, ValidationException {
PropertySet propertySet;
if (value == null) {
value = createValueInstance(parentElement, getValueType());
propertySet = getPropertySet(value);
propertySet.setDefaultValues();
} else {
propertySet = getPropertySet(value);
}
convertDomToPropertySet(parentElement, propertySet);
return value;
}
|
520146_0
|
static String getBandName(String name) {
int p1 = name.indexOf("_");
int p2 = name.lastIndexOf('.');
return name.substring(p1 == -1 ? 0 : p1 + 1, p2);
}
|
520146_1
|
static PropertySet readPhysVolDescriptor(File inputFile) throws IOException {
return readKeyValuePairs(inputFile);
}
|
520146_2
|
@Override
public DecodeQualification getDecodeQualification(Object input) {
File file = getFileInput(input);
if (file == null) {
return DecodeQualification.UNABLE;
}
VirtualDir virtualDir = VirtualDir.create(file);
if (virtualDir == null) {
return DecodeQualification.UNABLE;
}
try {
try {
Reader reader = virtualDir.getReader(SpotVgtConstants.PHYS_VOL_FILENAME);
if (reader == null) {
return DecodeQualification.UNABLE;
}
try {
PhysVolDescriptor descriptor = new PhysVolDescriptor(reader);
String[] strings = virtualDir.list(descriptor.getLogVolDirName());
if (strings.length == 0) {
return DecodeQualification.UNABLE;
}
} finally {
reader.close();
}
return DecodeQualification.INTENDED;
} catch (IOException e) {
return DecodeQualification.UNABLE;
}
} finally {
virtualDir.close();
}
}
|
520146_3
|
public URL getCoefficientFile(String sensor, String bandName, AEROSOL_TYPE aerosolType) {
URL url = null;
SensorDb sensorDb;
sensorDb = getSensorDb(sensor);
if (sensorDb != null) {
BandDb bandDb;
bandDb = sensorDb.getBand(bandName, aerosolTypeMap.get(aerosolType));
if (bandDb == null) {
return null;
}
try {
url = new URL(bandDb.getCoefficientFileName());
} catch (MalformedURLException e) {
try {
url = new URL(locationPath + bandDb.getCoefficientFileName());
} catch (MalformedURLException ignored) {
}
}
}
return url;
}
|
520146_4
|
public URL getCoefficientFile(String sensor, String bandName, AEROSOL_TYPE aerosolType) {
URL url = null;
SensorDb sensorDb;
sensorDb = getSensorDb(sensor);
if (sensorDb != null) {
BandDb bandDb;
bandDb = sensorDb.getBand(bandName, aerosolTypeMap.get(aerosolType));
if (bandDb == null) {
return null;
}
try {
url = new URL(bandDb.getCoefficientFileName());
} catch (MalformedURLException e) {
try {
url = new URL(locationPath + bandDb.getCoefficientFileName());
} catch (MalformedURLException ignored) {
}
}
}
return url;
}
|
520146_5
|
public URL getCoefficientFile(String sensor, String bandName, AEROSOL_TYPE aerosolType) {
URL url = null;
SensorDb sensorDb;
sensorDb = getSensorDb(sensor);
if (sensorDb != null) {
BandDb bandDb;
bandDb = sensorDb.getBand(bandName, aerosolTypeMap.get(aerosolType));
if (bandDb == null) {
return null;
}
try {
url = new URL(bandDb.getCoefficientFileName());
} catch (MalformedURLException e) {
try {
url = new URL(locationPath + bandDb.getCoefficientFileName());
} catch (MalformedURLException ignored) {
}
}
}
return url;
}
|
520146_6
|
public void setURL(URL location) throws IOException {
Guardian.assertNotNull("location", location);
URL mapFileURL;
String file = null;
try {
file = SystemUtils.convertToLocalPath(location.getPath() + "/" + mapFileName);
mapFileURL = new URL(location.getProtocol(), location.getHost(), file);
} catch (MalformedURLException e) {
throw new IOException("Unable to open coefficient map file from URL '" + file + "'", e);
}
setLocationPath(location);
try (InputStream in = mapFileURL.openStream()) {
final CsvReader csvReader = new CsvReader(new InputStreamReader(in),
fieldSeparators);
// read sensor map file completely and assemble the database
// ---------------------------------------------------------
String[] record;
SensorDb sensorDb;
BandDb bandDb;
while ((record = csvReader.readRecord()) != null) {
// retrieve the sensor db entry
sensorDb = getSensorDb(record[0]);
if (sensorDb == null) {
// is not in database yet, create and add to database
sensorDb = new SensorDb(record[0]);
sensors.add(sensorDb);
}
// add the band entry to sensorDb
bandDb = new BandDb(record[1], record[2], record[3]);
sensorDb.addBand(bandDb);
}
}
}
|
520146_7
|
@Override
public String toString() {
return String.format("%s{index=%d, numObs=%d, featureValues=%s}",
getClass().getSimpleName(), index, numObs, Arrays.toString(featureValues));
}
|
520146_8
|
public static SpatialBin read(DataInput dataInput) throws IOException {
return read(-1L, dataInput);
}
|
520146_9
|
public final String[] getResultFeatureNames() {
if (hasPostProcessor()) {
return getPostProcessFeatureNames();
} else {
return getOutputFeatureNames();
}
}
|
525255_0
|
public void visit(IndexVisitor<Key, Value> visitor) {
root().visit(this, visitor);
}
|
526139_0
|
@Override
public final List<BandDescriptor> asList() {
return Collections.unmodifiableList(descriptorList);
}
|
526139_1
|
@Override
public final BandDescriptor getMember(String bandName) {
return descriptorMap.get(bandName);
}
|
526139_2
|
@Override
public final List<FlagDescriptor> asList() {
return Collections.unmodifiableList(descriptorList);
}
|
526139_3
|
@Override
public final FlagDescriptor getMember(String flagName) {
return descriptorMap.get(flagName);
}
|
526139_4
|
static String buildPath(String identifier, String root, String appendix) {
final String fc = identifier.substring(12, 16);
final String sd = identifier.substring(16, 22);
return root + "/" + fc + "/" + sd + "/" + identifier + appendix;
}
|
526139_5
|
InputStream getResourceStream(String path) throws FileNotFoundException {
final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME);
if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) {
final File resourceFile = new File(dddbDirFromProperty, path);
if (resourceFile.isFile()) {
return new FileInputStream(resourceFile);
}
}
return getClass().getResourceAsStream(path);
}
|
526139_6
|
InputStream getResourceStream(String path) throws FileNotFoundException {
final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME);
if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) {
final File resourceFile = new File(dddbDirFromProperty, path);
if (resourceFile.isFile()) {
return new FileInputStream(resourceFile);
}
}
return getClass().getResourceAsStream(path);
}
|
526139_7
|
URL getResourceUrl(String path) throws MalformedURLException {
final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME);
if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) {
final File resourceFile = new File(dddbDirFromProperty, path);
if (resourceFile.isFile()) {
return new URL("file", "", 0, resourceFile.getAbsolutePath());
}
}
return getClass().getResource(path);
}
|
526139_8
|
URL getResourceUrl(String path) throws MalformedURLException {
final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME);
if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) {
final File resourceFile = new File(dddbDirFromProperty, path);
if (resourceFile.isFile()) {
return new URL("file", "", 0, resourceFile.getAbsolutePath());
}
}
return getClass().getResource(path);
}
|
526139_9
|
URL getResourceUrl(String path) throws MalformedURLException {
final String dddbDirFromProperty = System.getProperty(SMOS_DDDB_DIR_PROPERTY_NAME);
if (StringUtils.isNotNullAndNotEmpty(dddbDirFromProperty)) {
final File resourceFile = new File(dddbDirFromProperty, path);
if (resourceFile.isFile()) {
return new URL("file", "", 0, resourceFile.getAbsolutePath());
}
}
return getClass().getResource(path);
}
|
533032_0
|
public void andWith(DocIdSetCardinality other) {
min = Math.max(0.0, min + other.min - 1.0); // min - (1.0 - other.min)
max = Math.min(max, other.max);
}
|
533032_1
|
public void orWith(DocIdSetCardinality other) {
min = Math.max(min, other.min);
max = Math.min(1.0, max + other.max);
}
|
533032_2
|
public void invert() {
final double oldMin = min;
min = 1.0 - max;
max = 1.0 - oldMin;
}
|
533032_3
|
static String[] getValsByFrequency(String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd) {
List<Pair<String, DocIdSetCardinality>> valsAndFreqs = new ArrayList<Pair<String, DocIdSetCardinality>>(vals.length);
for (String val : vals) {
int i = valArray.indexOf(val);
if (i >=0) {
DocIdSetCardinality docIdSetCardinality = DocIdSetCardinality.exact(((double) freqs[i]) / (maxDoc + 1));
if (isAnd) {
if (docIdSetCardinality.isOne()) {
optimizedOut.add(val);
continue;
}
total.andWith(docIdSetCardinality);
} else {
if (docIdSetCardinality.isZero()) {
optimizedOut.add(val);
continue;
}
total.orWith(docIdSetCardinality);
}
valsAndFreqs.add(new Pair<String, DocIdSetCardinality>(valArray.get(i), docIdSetCardinality));
}
}
// Lowest cardinality docs go first to optimize the AND case, last for the OR case.
Collections.sort(valsAndFreqs, isAnd ? INCREASING_CARDINALITY_COMPARATOR : DECREASING_CARDINALITY_COMPARATOR);
String[] sortedVals = new String[valsAndFreqs.size()];
int i = 0;
while (i < sortedVals.length) {
sortedVals[i] = valsAndFreqs.get(i).getFirst();
++i;
}
return sortedVals;
}
|
533032_4
|
public SenseiTermFilter(String name,String vals[],String[] not,boolean isAnd,boolean noAutoOptimize){
_name = name;
_vals = vals != null ? vals : new String[0];
_not = not != null ? not : new String[0];
// Bobo silliness: Empty vals means match all, which technically means an AND of an empty set.
// EXCEPT if nots are also empty, but this is handled bellow.
_isAnd = isAnd || vals == null || vals.length == 0;
_noAutoOptimize = noAutoOptimize;
}
|
536958_0
|
String getSrcFileName() {
String name = src.getName();
if(src.isFile()){
name = name.replaceAll("\\.war$", "");
name = name.replaceAll("\\.zip$", "");
}
return name;
}
|
536958_1
|
Node createListenerNode(Document doc) {
Node listenerNode = doc.createElement("listener");
Node listenerClassNode = doc.createElement("listener-class");
listenerClassNode.appendChild(doc.createTextNode(LISTENER_CLASS));
listenerNode.appendChild(listenerClassNode);
return listenerNode;
}
|
536958_2
|
Node createFilterNode(Document doc) {
Node filterNode = doc.createElement("filter");
Node filterNameNode = doc.createElement("filter-name");
filterNameNode.appendChild(doc.createTextNode("infrared"));
Node filterClassNode = doc.createElement("filter-class");
filterClassNode.appendChild(doc.createTextNode(FILTER_CLASS));
filterNode.appendChild(filterNameNode);
filterNode.appendChild(filterClassNode);
return filterNode;
}
|
536958_3
|
Node createFilterMappingNode(Document doc) {
Node filterMappingNode = doc.createElement("filter-mapping");
Node filterNameNode = doc.createElement("filter-name");
filterNameNode.appendChild(doc.createTextNode("infrared"));
Node urlPatternNode = doc.createElement("url-pattern");
urlPatternNode.appendChild(doc.createTextNode("/*"));
filterMappingNode.appendChild(filterNameNode);
filterMappingNode.appendChild(urlPatternNode);
return filterMappingNode;
}
|
540945_0
|
public String getValue(String path) {
return getValue(path,null);
}
|
540945_1
|
public static void start(IDetachedRunnable runnable, Object... args) {
// Prepare child thread
Thread shim = new ShimThread(runnable, args);
shim.start();
}
|
540945_2
|
public static Socket fork(ZContext ctx, IAttachedRunnable runnable, Object... args) {
Socket pipe = ctx.createSocket(ZMQ.PAIR);
if (pipe != null) {
pipe.bind(String.format("inproc://zctx-pipe-%d", pipe.hashCode()));
} else {
return null;
}
// Connect child pipe to our pipe
ZContext ccontext = ZContext.shadow(ctx);
Socket cpipe = ccontext.createSocket(ZMQ.PAIR);
if (cpipe == null)
return null;
cpipe.connect(String.format("inproc://zctx-pipe-%d", pipe.hashCode()));
// Prepare child thread
Thread shim = new ShimThread(ccontext, runnable, args, cpipe);
shim.start();
return pipe;
}
|
540945_3
|
public static ZContext shadow(ZContext ctx) {
ZContext shadow = new ZContext();
shadow.setContext(ctx.getContext());
shadow.setMain(false);
return shadow;
}
|
540945_4
|
public ZFrame duplicate()
{
int length = size();
byte[] copy = new byte[length];
System.arraycopy(this.data, 0, copy, 0, length);
ZFrame frame = new ZFrame();
frame.data = copy;
if (this.buffer != null) {
frame.buffer = this.buffer.duplicate();
}
frame.more = this.more;
return frame;
}
|
540945_5
|
public ZLoop() {
pollers = new ArrayList<SPoller>();
timers = new ArrayList<STimer>();
zombies = new ArrayList<Object>();
newTimers = new ArrayList<STimer>();
}
|
540945_6
|
public static int makeVersion(final int major, final int minor, final int patch) {
return make_version(major, minor, patch);
}
|
540945_7
|
public static Context context(int ioThreads) {
return new Context(ioThreads);
}
|
540945_8
|
public static Context context(int ioThreads) {
return new Context(ioThreads);
}
|
540945_9
|
public static void proxy(Socket frontend, Socket backend, Socket capture) {
if (ZMQ.version_full() < ZMQ.make_version(3, 2, 2))
throw new UnsupportedOperationException();
run_proxy(frontend, backend, capture);
}
|
542927_0
|
@Override
public String toString() {
final StringBuilder sb = new StringBuilder();
if (!providerList.isEmpty()) {
sb.append(PROVIDER_TAG);
for (int i = 0; i < providerList.size(); i++) {
sb.append(providerList.get(i));
if (i < providerList.size() - 1) {
sb.append(VALUE_SEPARATOR);
}
}
}
if (bundleName != null) {
sb.append(PARAMETER_SEPARATOR);
sb.append(BUNDLE_TAG);
sb.append(bundleName);
sb.append(VALUE_SEPARATOR);
sb.append(bundleVersion);
}
if (processorName != null) {
sb.append(PARAMETER_SEPARATOR);
sb.append(PROCESSOR_TAG);
sb.append(processorName);
sb.append(VALUE_SEPARATOR);
sb.append(processorVersion);
}
if (userName != null) {
sb.append(PARAMETER_SEPARATOR);
sb.append(USER_TAG);
sb.append(userName);
}
return sb.toString();
}
|
542927_1
|
public static BundleFilter fromString(String text) {
final String[] parameters = text.split(String.valueOf(PARAMETER_SEPARATOR));
final BundleFilter filter = new BundleFilter();
for (String parameter : parameters) {
if (parameter.startsWith(PROVIDER_TAG)) {
final String[] providers = parameter.substring(PROVIDER_TAG.length()).split(String.valueOf(VALUE_SEPARATOR));
for (String provider : providers) {
filter.withProvider(provider);
}
} else if (parameter.startsWith(BUNDLE_TAG)) {
final String[] bundleInfos = parameter.substring(BUNDLE_TAG.length()).split(String.valueOf(VALUE_SEPARATOR));
filter.withTheBundle(bundleInfos[0], bundleInfos[1]);
} else if (parameter.startsWith(PROCESSOR_TAG)) {
final String[] processorInfos = parameter.substring(PROCESSOR_TAG.length()).split(String.valueOf(VALUE_SEPARATOR));
filter.withTheProcessor(processorInfos[0], processorInfos[1]);
} else if (parameter.startsWith(USER_TAG)) {
filter.withTheUser(parameter.substring(USER_TAG.length()));
} else {
throw new IllegalArgumentException("Tag provider=, bundle= or processor= not found in '" + text + "'");
}
}
return filter;
}
|
542927_2
|
@Override
public final ProcessStatus getStatus() {
return status;
}
|
542927_3
|
@Override
public final void setStatus(ProcessStatus newStatus) {
if (!newStatus.equals(status) && !newStatus.equals(ProcessStatus.UNKNOWN)) {
ProcessStatus oldStatus = status;
status = newStatus;
fireStatusChanged(new WorkflowStatusEvent(this, oldStatus, newStatus, new Date()));
}
}
|
542927_4
|
@Override
public String toString() {
String startString = startDate != null ? DATE_FORMAT.format(startDate) : "null";
String stopString = stopDate != null ? DATE_FORMAT.format(stopDate) : "null";
return OPENING_BRACKET + startString + SEPARATOR + stopString + CLOSING_BRACKET;
}
|
542927_5
|
@Override
public String toString() {
String startString = startDate != null ? DATE_FORMAT.format(startDate) : "null";
String stopString = stopDate != null ? DATE_FORMAT.format(stopDate) : "null";
return OPENING_BRACKET + startString + SEPARATOR + stopString + CLOSING_BRACKET;
}
|
542927_6
|
public static DateRange parseDateRange(String dateRange) throws ParseException {
String[] splits = dateRange.split(SEPARATOR);
String startString = splits[0].replace(OPENING_BRACKET, "");
String stopString = splits[1].replace(CLOSING_BRACKET, "");
return new DateRange(parseDate(startString), parseDate(stopString));
}
|
542927_7
|
public static ProcessStatus aggregate(ProcessStatus... statuses) {
assertStatusesNotNull(statuses);
if (statuses.length == 0) {
return UNKNOWN;
} else if (statuses.length == 1) {
return statuses[0];
}
float averageProgress = getAverageProgress(statuses);
for (ProcessStatus status : statuses) {
if (status.getState() == ProcessState.CANCELLED) {
return new ProcessStatus(status.getState(), averageProgress, status.getMessage());
}
}
for (ProcessStatus status : statuses) {
if (status.getState() == ProcessState.ERROR) {
return new ProcessStatus(status.getState(), averageProgress, status.getMessage());
}
}
String message = "";
for (ProcessStatus status : statuses) {
message = status.getMessage();
if (!message.isEmpty()) {
break;
}
}
final ProcessState state = getCummulativeState(statuses);
return new ProcessStatus(state, averageProgress, message);
}
|
542927_8
|
public static ProcessStatus aggregateUnsustainable(ProcessStatus... statuses) {
assertStatusesNotNull(statuses);
List<ProcessStatus> usable = new ArrayList<ProcessStatus>(statuses.length);
for (ProcessStatus status : statuses) {
if (status.getState() != ProcessState.ERROR && status.getState() != ProcessState.CANCELLED) {
usable.add(status);
}
}
if (statuses.length > 0 && usable.size() == 0) {
return new ProcessStatus(ProcessState.ERROR, 1f, statuses[0].message);
}
return aggregate(usable.toArray(new ProcessStatus[usable.size()]));
}
|
542927_9
|
public boolean isDone() {
return state.isDone();
}
|
551254_0
|
@Override
public void loadFromStream(InputStream is) throws DataSourceException {
Parser parser = new HTMLParse().getParserPublic();
data = new ArrayList<List<String>>();
ParserCallback callback = new DataSourceHtmlParser();
try {
parser.parse(new InputStreamReader(is), callback, true);
is.close();
} catch (IOException e) {
throw new DataSourceException("Error while reading HTML: "
+ e.getMessage(), e);
}
if (hadRowOrColSpan) {
throw new DataSourceException(
"The input table in the HTML file had rowspan or colspan attributes. These are not allowed for a data source!");
}
if (data.size() == 0) {
throw new DataSourceException("No table data found in HTML file!");
}
this.headings = data.remove(0);
}
|
551254_1
|
@Override
public void loadFromStream(InputStream is) throws DataSourceException {
Parser parser = new HTMLParse().getParserPublic();
data = new ArrayList<List<String>>();
ParserCallback callback = new DataSourceHtmlParser();
try {
parser.parse(new InputStreamReader(is), callback, true);
is.close();
} catch (IOException e) {
throw new DataSourceException("Error while reading HTML: "
+ e.getMessage(), e);
}
if (hadRowOrColSpan) {
throw new DataSourceException(
"The input table in the HTML file had rowspan or colspan attributes. These are not allowed for a data source!");
}
if (data.size() == 0) {
throw new DataSourceException("No table data found in HTML file!");
}
this.headings = data.remove(0);
}
|
551254_2
|
@Override
public void loadFromStream(InputStream is) throws DataSourceException {
Parser parser = new HTMLParse().getParserPublic();
data = new ArrayList<List<String>>();
ParserCallback callback = new DataSourceHtmlParser();
try {
parser.parse(new InputStreamReader(is), callback, true);
is.close();
} catch (IOException e) {
throw new DataSourceException("Error while reading HTML: "
+ e.getMessage(), e);
}
if (hadRowOrColSpan) {
throw new DataSourceException(
"The input table in the HTML file had rowspan or colspan attributes. These are not allowed for a data source!");
}
if (data.size() == 0) {
throw new DataSourceException("No table data found in HTML file!");
}
this.headings = data.remove(0);
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.