@Override public boolean apply(OProperty input) { return input.getType().isLink(); } };
@Override public boolean apply(OProperty input) { return input!=null?input.getType().isLink():false; } };
private boolean shouldBeDeserializedAsEmbedded(Object record, OType iType) { return record instanceof ODocument && !((ODocument) record).getIdentity().isTemporary() && !((ODocument) record).getIdentity().isPersistent() && (iType == null || !iType.isLink()); }
&& (isEmbedded || type.isLink()))
protected void initMapping(OPersistenceSession session) { mappingFromDocToEntity = new HashMap<>(); mappingFromEntityToDoc = new HashMap<>(); OClass oClass = session.getClass(getSchemaClass()); Class<T> entityClass = getEntityClass(); for(OProperty property : oClass.properties()) { String propertyName = property.getName(); String beanPropertyName = propertyName; boolean isLink = property.getType().isLink(); if(isLink) beanPropertyName+="Id"; IGetAndSet getAndSet = getGetAndSetter(entityClass, beanPropertyName); if(getAndSet!=null) { if(isLink) { IEntityHandler<?> targetHandler = HandlersManager.get().getHandlerBySchemaClass(property.getLinkedClass().getName()); if(targetHandler==null || targetHandler.getPkField()==null) continue; propertyName+="."+targetHandler.getPkField(); } if(getAndSet.getSetter()!=null) mappingFromDocToEntity.put(propertyName, beanPropertyName); if(getAndSet.getGetter()!=null) mappingFromEntityToDoc.put(beanPropertyName, propertyName); } } }
continue; } else if (v instanceof ODocument && type != null && type.isLink()) { String className1 = ((ODocument) v).getClassName(); if (className1 != null && className1.length() > 0)
@Override protected String getDefaultSql() { ODocument doc = getModelObject(); OClass oClass = doc.getSchemaClass(); OProperty multiProperty = null; for(OProperty property : oClass.properties()) { if(property.getType().isLink() && property.getType().isMultiValue()) { multiProperty = property; break; } } if(multiProperty!=null) { return "select expand("+multiProperty.getName()+") from :doc"; } else { return "select from :doc"; } }
@Override protected String getDefaultSql() { ODocument doc = getModelObject(); OClass oClass = doc.getSchemaClass(); OProperty multiProperty = null; for(OProperty property : oClass.properties()) { if(property.getType().isLink() && property.getType().isMultiValue()) { multiProperty = property; break; } } if(multiProperty!=null) { return "select expand("+multiProperty.getName()+") from :doc"; } else { return "select from :doc"; } } };
@Override protected void onConfigure() { super.onConfigure(); String critery = getPropertyObject(); if(OPropertyPrototyper.TYPE.equals(critery)) { OType oType = (OType)getEnteredValue(); // Show Linked Class if type is a some kind of link AbstractMetaPanel<OProperty, String, ?> metaPanel = getMetaComponent(OPropertyPrototyper.LINKED_CLASS); if(metaPanel!=null) metaPanel.setVisibilityAllowed(oType!=null && (oType.isLink() || oType.isEmbedded())); // Show Linked Type if type is a some kind of embedded metaPanel = getMetaComponent(OPropertyPrototyper.LINKED_TYPE); if(metaPanel!=null) metaPanel.setVisibilityAllowed(oType!=null && oType.isEmbedded() && !OType.EMBEDDED.equals(oType)); // Show inverse if current type is a link metaPanel = getMetaComponent(CustomAttribute.PROP_INVERSE.getName()); if(metaPanel!=null) metaPanel.setVisibilityAllowed(oType!=null && oType.isLink()); } else if(CustomAttribute.CALCULABLE.getName().equals(critery)) { Boolean calculable = (Boolean) getEnteredValue(); AbstractMetaPanel<OProperty, String, ?> metaPanel = getMetaComponent(CustomAttribute.CALC_SCRIPT.getName()); if(metaPanel!=null) metaPanel.setVisibilityAllowed(calculable!=null && calculable); } }
@Override public void onInitialize(OrienteerWebApplication app, ODatabaseDocument db) { OSchemaHelper helper = OSchemaHelper.bind(db); helper.oClass(TEST_OCLASS); UIVisualizersRegistry registry = app.getUIVisualizersRegistry(); for(OType type: OType.values()) { if(type == OType.LINKBAG) continue; helper.oProperty(type.name().toLowerCase(), type); if(type.isLink()) helper.linkedClass(TEST_OCLASS); for(String vizualization : registry.getComponentsOptions(type)) { helper.oProperty(type.name().toLowerCase()+vizualization, type).assignVisualization(vizualization); if(type.isLink()) helper.linkedClass(TEST_OCLASS); } } }