@Override public OClass getLinkedClass() { return delegate.getLinkedClass(); }
@Override protected void onConfigure() { super.onConfigure(); setVisible(propertyModel.getObject()!=null && propertyModel.getObject().getLinkedClass()!=null); }
@Override protected void onInitialize() { super.onInitialize(); OProperty property = LinkEqualsFilterPanel.this.getPropertyModel().getObject(); if (property != null && property.getLinkedClass() != null) { setModelObject(property.getLinkedClass()); setEnabled(false); } } };
@Override protected void onInitialize() { super.onInitialize(); OProperty property = CollectionLinkFilterPanel.this.getPropertyModel().getObject(); if (property != null && property.getLinkedClass() != null) { setModelObject(Arrays.asList(property.getLinkedClass().getName())); setEnabled(false); } } };
private OType calculateTypeForThisItem(OClass clazz, String propName, OModifier modifier, OCommandContext ctx) { OProperty prop = clazz.getProperty(propName); if (prop == null) { return null; } OType type = prop.getType(); if (type == OType.LINKMAP && modifier != null) { if (prop.getLinkedClass() != null && modifier.next != null) { if (modifier.suffix == null) { return null; } return calculateTypeForThisItem(prop.getLinkedClass(), modifier.suffix.toString(), modifier.next, ctx); } return OType.LINK; } //TODO specialize more return null; }
public OSchemaHelper setupRelationship(String class1Name, String property1Name, String class2Name, String property2Name) { OClass class1 = schema.getClass(class1Name); OProperty property1 = class1.getProperty(property1Name); OClass class2 = schema.getClass(class2Name); OProperty property2 = class2.getProperty(property2Name); if(!Objects.equals(property1.getLinkedClass(), class2)) property1.setLinkedClass(class2); if(!Objects.equals(property2.getLinkedClass(), class1)) property2.setLinkedClass(class1); CustomAttribute.PROP_INVERSE.setValue(property1, property2); CustomAttribute.PROP_INVERSE.setValue(property2, property1); return this; }
public OSchemaHelper setupRelationship(String class1Name, String propertyName, String class2Name) { OClass class1 = schema.getClass(class1Name); OProperty property = class1.getProperty(propertyName); OClass class2 = schema.getClass(class2Name); if (!Objects.equals(property.getLinkedClass(), class2)) property.setLinkedClass(class2); return this; }
private boolean checkIndexChainExistence(OClass iSchemaClass, OIndexSearchResult result) { final int fieldCount = result.lastField.getItemCount(); OClass cls = iSchemaClass.getProperty(result.lastField.getItemName(0)).getLinkedClass(); for (int i = 1; i < fieldCount; i++) { if (cls == null || !cls.areIndexed(result.lastField.getItemName(i))) { return false; } cls = cls.getProperty(result.lastField.getItemName(i)).getLinkedClass(); } return true; } }
/** * Set linked class to a current property * @param className class name to set as a linked class * @return this helper */ public OSchemaHelper linkedClass(String className) { checkOProperty(); OClass linkedToClass = schema.getClass(className); if(linkedToClass==null) throw new IllegalArgumentException("Target OClass '"+className+"' to link to not found"); if(!Objects.equal(linkedToClass, lastProperty.getLinkedClass())) { lastProperty.setLinkedClass(linkedToClass); } return this; }
/** * Set linked class to a current property * @param className class name to set as a linked class * @return this helper */ public OSchemaHelper linkedClass(String className) { checkOProperty(); OClass linkedToClass = schema.getClass(className); if(linkedToClass==null) throw new IllegalArgumentException("Target OClass '"+className+"' to link to not found"); if(!Objects.equal(linkedToClass, lastProperty.getLinkedClass())) { lastProperty.setLinkedClass(linkedToClass); } return this; }
public boolean isIndexChain(OCommandContext ctx, OClass clazz) { if (suffix != null && suffix.isBaseIdentifier()) { OProperty prop = clazz.getProperty(suffix.identifier.getStringValue()); if (prop != null && prop.getAllIndexes().stream().anyMatch(idx -> idx.getDefinition().getFields().size() == 1)) { if (next != null) { OClass linkedClazz = prop.getLinkedClass(); return next.isIndexChain(ctx, linkedClazz); } return true; } } return false; } }
public static Object convertToPropertyType(OResultInternal res, OIdentifier attrName, Object newValue, OCommandContext ctx) { OElement doc = res.toElement(); Optional<OClass> optSchema = doc.getSchemaType(); if (!optSchema.isPresent()) { return newValue; } OProperty prop = optSchema.get().getProperty(attrName.getStringValue()); if (prop == null) { return newValue; } OType type = prop.getType(); OClass linkedClass = prop.getLinkedClass(); return convertToType(newValue, type, linkedClass, ctx); }
private static List<OIndex<?>> prepareBaseIndexes(OClass iSchemaClass, OSQLFilterItemField.FieldChain fieldChain) { List<OIndex<?>> result = new ArrayList<OIndex<?>>(fieldChain.getItemCount() - 1); OClass oClass = iSchemaClass; for (int i = 0; i < fieldChain.getItemCount() - 1; i++) { final Set<OIndex<?>> involvedIndexes = oClass.getInvolvedIndexes(fieldChain.getItemName(i)); final OIndex<?> bestIndex = findBestIndex(involvedIndexes); if (bestIndex == null) return null; result.add(bestIndex); oClass = oClass.getProperty(fieldChain.getItemName(i)).getLinkedClass(); } return result; }
public boolean isIndexChain(OCommandContext ctx, OClass clazz) { if (modifier == null) { return false; } if (identifier.isIndexChain(ctx, clazz)) { OProperty prop = clazz.getProperty(identifier.getSuffix().identifier.getStringValue()); OClass linkedClass = prop.getLinkedClass(); if (linkedClass != null) { return modifier.isIndexChain(ctx, linkedClass); } } return false; }
@Override public SortableDataProvider<ODocument, String> prepareDataProviderForProperty( OProperty property, IModel<ODocument> documentModel) { SortableDataProvider<ODocument, String> provider; if(CustomAttribute.CALCULABLE.getValue(property, false)) { String sql = CustomAttribute.CALC_SCRIPT.getValue(property); sql = sql.replace("?", ":doc"); provider = new OQueryDataProvider<ODocument>(sql).setParameter("doc", documentModel); } else { provider = new ODocumentLinksDataProvider(documentModel, property); } OClass linkedClass = property.getLinkedClass(); defineDefaultSorting(provider, linkedClass); return provider; }
public static boolean checkIndexExistence(final OClass iSchemaClass, final OIndexSearchResult result) { if (!iSchemaClass.areIndexed(result.fields())) return false; if (result.lastField.isLong()) { final int fieldCount = result.lastField.getItemCount(); OClass cls = iSchemaClass.getProperty(result.lastField.getItemName(0)).getLinkedClass(); for (int i = 1; i < fieldCount; i++) { if (cls == null || !cls.areIndexed(result.lastField.getItemName(i))) { return false; } cls = cls.getProperty(result.lastField.getItemName(i)).getLinkedClass(); } } return true; }
public static boolean checkIndexExistence(final OClass iSchemaClass, final OIndexSearchResult result) { if (!iSchemaClass.areIndexed(result.fields())) return false; if (result.lastField.isLong()) { final int fieldCount = result.lastField.getItemCount(); OClass cls = iSchemaClass.getProperty(result.lastField.getItemName(0)).getLinkedClass(); for (int i = 1; i < fieldCount; i++) { if (cls == null || !cls.areIndexed(result.lastField.getItemName(i))) { return false; } cls = cls.getProperty(result.lastField.getItemName(i)).getLinkedClass(); } } return true; }
public SpatialStrategy createStrategy(SpatialContext ctx, ODatabaseDocumentInternal db, OIndexDefinition indexDefinition, ODocument metadata) { OClass aClass = db.getMetadata().getSchema().getClass(indexDefinition.getClassName()); OProperty property = aClass.getProperty(indexDefinition.getFields().get(0)); OClass linkedClass = property.getLinkedClass(); if ("OPoint".equalsIgnoreCase(linkedClass.getName())) { RecursivePrefixTreeStrategy strategy = new RecursivePrefixTreeStrategy(new GeohashPrefixTree(ctx, 11), "location"); strategy.setDistErrPct(0); return strategy; } return BBoxStrategy.newInstance(ctx, "location"); } }
public LinksCollectionViewPanel(String id, IModel<ODocument> documentModel, OProperty property) { super(id, new DynamicPropertyValueModel<M>(documentModel, new OPropertyModel(property))); ISortableDataProvider<ODocument, String> provider = oClassIntrospector.prepareDataProviderForProperty(property, documentModel); List<IColumn<ODocument, String>> columns = new ArrayList<IColumn<ODocument,String>>(); columns.add(new OEntityColumn(property.getLinkedClass(), DisplayMode.VIEW.asModel())); GenericTablePanel<ODocument> tablePanel = new GenericTablePanel<ODocument>("tablePanel", columns, provider, 10); OrienteerDataTable<ODocument, String> table = tablePanel.getDataTable(); table.getHeadersToolbar().setVisibilityAllowed(false); table.getNoRecordsToolbar().setVisibilityAllowed(false); add(tablePanel); }
@Override public OBooleanExpression rewriteIndexChainsAsSubqueries(OCommandContext ctx, OClass clazz) { if (operator instanceof OEqualsCompareOperator && right.isEarlyCalculated(ctx) && left.isIndexChain(ctx, clazz)) { OInCondition result = new OInCondition(-1); result.left = new OExpression(-1); OBaseExpression base = new OBaseExpression(-1); base.identifier = new OBaseIdentifier(-1); base.identifier.suffix = new OSuffixIdentifier(-1); base.identifier.suffix.identifier = ((OBaseExpression) left.mathExpression).identifier.suffix.identifier; result.left.mathExpression = base; result.operator = new OInOperator(-1); OClass nextClazz = clazz.getProperty(base.identifier.suffix.identifier.getStringValue()).getLinkedClass(); result.rightStatement = indexChainToStatement(((OBaseExpression) left.mathExpression).modifier, nextClazz, right, ctx); return result; } return this; }