本文整理汇总了Java中com.orientechnologies.orient.core.command.OCommandContext类的典型用法代码示例。如果您正苦于以下问题:Java OCommandContext类的具体用法?Java OCommandContext怎么用?Java OCommandContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OCommandContext类属于com.orientechnologies.orient.core.command包,在下文中一共展示了OCommandContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public Object execute(final Object iThis,
final OIdentifiable iCurrentRecord,
final Object iCurrentResult,
final Object[] iParams,
final OCommandContext iContext)
{
checkArgument(iParams.length == 1);
final Object param = iParams[0];
if (param == null) {
return null;
}
checkArgument(param instanceof String, "lower() parameter must be a string");
return ((String) param).toLowerCase(Locale.ENGLISH);
}
示例2: execute
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public Object execute(final Object iThis,
final OIdentifiable iCurrentRecord,
final Object iCurrentResult,
final Object[] iParams,
final OCommandContext iContext)
{
OIdentifiable identifiable = (OIdentifiable) iParams[0];
ODocument document = identifiable.getRecord();
String browsedRepositoryName = (String) iParams[1];
boolean jexlOnly = iParams.length > 2 && (boolean) iParams[2];
switch (document.getClassName()) {
case "asset":
return checkAssetPermissions(document, browsedRepositoryName, jexlOnly);
case "component":
return checkComponentAssetPermissions(document, browsedRepositoryName, jexlOnly);
default:
return false;
}
}
示例3: executeIndexQuery
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) {
OIndexCursor cursor;
Object key;
key = keyParams.get(0);
Map<String, Object> queryParams = new HashMap<String, Object>();
queryParams.put(SpatialQueryBuilderAbstract.GEO_FILTER, SpatialQueryBuilderOverlap.NAME);
queryParams.put(SpatialQueryBuilderAbstract.SHAPE, key);
long start = System.currentTimeMillis();
OLuceneAbstractResultSet indexResult = (OLuceneAbstractResultSet) index.get(queryParams);
if (indexResult == null || indexResult instanceof OIdentifiable)
cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, new OSpatialCompositeKey(keyParams));
else
cursor = new OIndexCursorCollectionValue(((Collection<OIdentifiable>) indexResult), new OSpatialCompositeKey(
keyParams));
if (indexResult != null)
indexResult.sendLookupTime(iContext, start);
return cursor;
}
示例4: evaluateRecord
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft,
Object iRight, OCommandContext iContext) {
Shape shape = factory.fromDoc((ODocument) iLeft);
// TODO { 'shape' : { 'type' : 'LineString' , 'coordinates' : [[1,2],[4,6]]} }
// TODO is not translated in map but in array[ { 'type' : 'LineString' , 'coordinates' : [[1,2],[4,6]]} ]
Object filter;
if (iRight instanceof Collection) {
filter = ((Collection) iRight).iterator().next();
} else {
filter = iRight;
}
Shape shape1 = factory.fromObject(filter);
return SpatialOperation.BBoxIntersects.evaluate(shape, shape1.getBoundingBox());
}
示例5: searchIntersect
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
public Object searchIntersect(OCompositeKey key, double distance, OCommandContext context) throws IOException {
double lat = ((Double) OType.convert(((OCompositeKey) key).getKeys().get(0), Double.class)).doubleValue();
double lng = ((Double) OType.convert(((OCompositeKey) key).getKeys().get(1), Double.class)).doubleValue();
SpatialOperation operation = SpatialOperation.Intersects;
Point p = ctx.makePoint(lng, lat);
SpatialArgs args = new SpatialArgs(operation, ctx.makeCircle(lng, lat,
DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM)));
Filter filter = strategy.makeFilter(args);
IndexSearcher searcher = searcher();
ValueSource valueSource = strategy.makeDistanceValueSource(p);
Sort distSort = new Sort(valueSource.getSortField(false)).rewrite(searcher);
return new LuceneResultSet(this,
new SpatialQueryContext(context, searcher, new MatchAllDocsQuery(), filter, distSort).setSpatialArgs(args));
}
示例6: results
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
protected LuceneResultSet results(OFromClause target, OExpression[] args, OCommandContext ctx) {
OIndex oIndex = searchForIndex(target, args);
if (oIndex != null) {
Map<String, Object> queryParams = new HashMap<String, Object>();
queryParams.put(SpatialQueryBuilderAbstract.GEO_FILTER, operator());
Object shape;
if (args[1].getValue() instanceof OJson) {
OJson json = (OJson) args[1].getValue();
ODocument doc = new ODocument().fromJSON(json.toString());
shape = doc.toMap();
} else {
shape = args[1].execute(null, ctx);
}
queryParams.put(SpatialQueryBuilderAbstract.SHAPE, shape);
return (LuceneResultSet) oIndex.get(queryParams);
}
return null;
}
示例7: executeEvent
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
private Object executeEvent(final ODatabaseDocumentTx db, final String iEventName, final OCommandContext iContext) {
if (events == null)
return null;
OCommandScript script = scripts.get(iEventName);
if (script == null) {
final String code = events.get(iEventName);
if (code != null) {
// CACHE IT
script = new OCommandScript(code).setLanguage("Javascript");
scripts.put(iEventName, script);
}
}
if (script != null) {
final Map<String, Object> pars = new HashMap<String, Object>();
pars.put("task", iContext);
pars.put("importer", this);
return db.command(script).execute(pars);
}
return null;
}
示例8: configure
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, OCommandContext iContext) {
super.configure(iProcessor, iConfiguration, iContext);
fieldName = (String) resolve(iConfiguration.field("fieldName"));
fieldNames = (List<String>) resolve(iConfiguration.field("fieldNames"));
if (fieldNames == null && fieldName == null)
throw new IllegalArgumentException("Field transformer must specify 'fieldName' or 'fieldNames'");
expression = iConfiguration.field("expression");
value = iConfiguration.field("value");
if (expression != null && value != null)
throw new IllegalArgumentException("Field transformer cannot specify both 'expression' and 'value'");
if (iConfiguration.containsField("save"))
save = (Boolean) iConfiguration.field("save");
if (iConfiguration.containsField("operation"))
setOperation = "set".equalsIgnoreCase((String) iConfiguration.field("operation"));
}
示例9: configure
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public void configure(OETLProcessor iProcessor, final ODocument iConfiguration, final OCommandContext iContext) {
super.configure(iProcessor, iConfiguration, iContext);
edgeClass = iConfiguration.field("class");
if (iConfiguration.containsField("direction")) {
final String direction = iConfiguration.field("direction");
if ("out".equalsIgnoreCase(direction))
directionOut = true;
else if ("in".equalsIgnoreCase(direction))
directionOut = false;
else
throw new OConfigurationException("Direction can be 'in' or 'out', but found: " + direction);
}
if (iConfiguration.containsField("targetVertexFields"))
targetVertexFields = (ODocument) iConfiguration.field("targetVertexFields");
if (iConfiguration.containsField("edgeFields"))
edgeFields = (ODocument) iConfiguration.field("edgeFields");
if (iConfiguration.containsField("skipDuplicates"))
skipDuplicates = (Boolean) resolve(iConfiguration.field("skipDuplicates"));
}
示例10: sendLookupTime
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
public void sendLookupTime(OCommandContext context, final TopDocs docs, final Integer limit, long startFetching) {
if (context != null) {
final long finalTime = System.currentTimeMillis() - startFetching;
context.setVariable((indexName + ".lookupTime").replace(".", "_"), new HashMap<String, Object>() {
{
put("limit", limit);
put("totalTime", finalTime);
put("totalHits", docs.totalHits);
put("returnedHits", docs.scoreDocs.length);
put("maxScore", docs.getMaxScore());
}
});
}
}
示例11: searchIntersect
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
public Object searchIntersect(OCompositeKey key, double distance, OCommandContext context) throws IOException {
double lat = ((Double) OType.convert(((OCompositeKey) key).getKeys().get(0), Double.class)).doubleValue();
double lng = ((Double) OType.convert(((OCompositeKey) key).getKeys().get(1), Double.class)).doubleValue();
SpatialOperation operation = SpatialOperation.Intersects;
Point p = ctx.makePoint(lng, lat);
SpatialArgs args = new SpatialArgs(operation, ctx.makeCircle(lng, lat,
DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM)));
Filter filter = strategy.makeFilter(args);
IndexSearcher searcher = getSearcher();
ValueSource valueSource = strategy.makeDistanceValueSource(p);
Sort distSort = new Sort(valueSource.getSortField(false)).rewrite(searcher);
return new LuceneResultSet(this,
new SpatialQueryContext(context, searcher, new MatchAllDocsQuery(), filter, distSort).setSpatialArgs(args));
}
示例12: executeIndexQuery
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public OIndexCursor executeIndexQuery(OCommandContext iContext, OIndex<?> index, List<Object> keyParams, boolean ascSortOrder) {
OIndexDefinition definition = index.getDefinition();
int idxSize = definition.getFields().size();
int paramsSize = keyParams.size();
OIndexCursor cursor;
Object indexResult = index.get(new OSpatialCompositeKey(keyParams).setOperation(SpatialOperation.IsWithin));
if (indexResult == null || indexResult instanceof OIdentifiable)
cursor = new OIndexCursorSingleValue((OIdentifiable) indexResult, new OSpatialCompositeKey(keyParams));
else
cursor = new OIndexCursorCollectionValue(((Collection<OIdentifiable>) indexResult).iterator(), new OSpatialCompositeKey(
keyParams));
iContext.setVariable("$luceneIndex", true);
return cursor;
}
示例13: execute
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public Object execute(Object iThis, OIdentifiable iCurrentRecord, Object iCurrentResult, Object[] iParams,
OCommandContext iContext) {
String clazz = (String) iParams[0];
String latField = (String) iParams[1];
String lngField = (String) iParams[2];
ODatabaseDocument databaseRecord = ODatabaseRecordThreadLocal.INSTANCE.get();
Set<OIndex<?>> indexes = databaseRecord.getMetadata().getSchema().getClass(clazz).getInvolvedIndexes(latField, lngField);
for (OIndex i : indexes) {
if (OClass.INDEX_TYPE.SPATIAL.toString().equals(i.getInternal().getType())) {
List<Object> params = new ArrayList<Object>();
params.add(iParams[3]);
params.add(iParams[4]);
double distance = iParams.length > 5 ? ((Number) iParams[5]).doubleValue() : 0;
Object ret = i.get(new OSpatialCompositeKey(params).setMaxDistance(distance));
if (ret instanceof Collection) {
if (context == null)
context = new HashSet<Object>();
context.addAll((Collection<?>) ret);
}
return ret;
}
}
return null;
}
示例14: execute
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public Object execute(final Object iThis,
final OIdentifiable iCurrentRecord,
final Object iCurrentResult,
final Object[] iParams,
final OCommandContext iContext)
{
StringBuilder b = new StringBuilder();
for (Object param : iParams) {
b.append(param);
}
return b.toString();
}
示例15: evaluateRecord
import com.orientechnologies.orient.core.command.OCommandContext; //导入依赖的package包/类
@Override
public Object evaluateRecord(OIdentifiable iRecord, ODocument iCurrentResult, OSQLFilterCondition iCondition, Object iLeft,
Object iRight, OCommandContext iContext) {
List<Number> left = (List<Number>) iLeft;
double lat = left.get(0).doubleValue();
double lon = left.get(1).doubleValue();
Shape shape = factory.context().makePoint(lon, lat);
List<Number> right = (List<Number>) iRight;
double lat1 = right.get(0).doubleValue();
double lon1 = right.get(1).doubleValue();
Shape shape1 = factory.context().makePoint(lon1, lat1);
Map map = (Map) right.get(2);
double distance = 0;
Number n = (Number) map.get("maxDistance");
if (n != null) {
distance = n.doubleValue();
}
Point p = (Point) shape1;
Circle circle = factory.context().makeCircle(p.getX(), p.getY(),
DistanceUtils.dist2Degrees(distance, DistanceUtils.EARTH_MEAN_RADIUS_KM));
double docDistDEG = factory.context().getDistCalc().distance((Point) shape, p);
final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM);
iContext.setVariable("distance", docDistInKM);
return shape.relate(circle) == SpatialRelation.WITHIN;
}