Java Code Examples for com.orientechnologies.orient.core.metadata.schema.OProperty#getName()
The following examples show how to use
com.orientechnologies.orient.core.metadata.schema.OProperty#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractEntityHandler.java From Orienteer with Apache License 2.0 | 6 votes |
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); } } }
Example 2
Source File: ODocumentPivotTableWidget.java From Orienteer with Apache License 2.0 | 6 votes |
@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"; } }
Example 3
Source File: OArchitectOProperty.java From Orienteer with Apache License 2.0 | 6 votes |
public static OArchitectOProperty toArchitectOProperty(OClass oClass, OProperty property) { OArchitectOProperty architectProperty = new OArchitectOProperty(property.getName(), property.getType()); if (property.getLinkedClass() != null) { architectProperty.setLinkedClass(property.getLinkedClass().getName()); OProperty inverse = CustomAttribute.PROP_INVERSE.getValue(property); if (inverse != null) { OArchitectOProperty prop = new OArchitectOProperty(inverse.getName(), inverse.getType()); prop.setExistsInDb(true); architectProperty.setInversePropertyEnable(true); architectProperty.setInverseProperty(prop); } } int order = CustomAttribute.ORDER.getValue(property); architectProperty.setOrder(order); architectProperty.setPageUrl("/property/" + oClass.getName() + "/" + property.getName()); architectProperty.setExistsInDb(true); return architectProperty; }
Example 4
Source File: OPropertyModel.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override protected void handleObject(OProperty object) { if(object!=null) { classModel = new OClassModel(object.getOwnerClass()); propertyName = object.getName(); } else { classModel=null; propertyName=null; } }
Example 5
Source File: OPropertyModel.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Override protected void onDetach() { if(classModel!=null) { OProperty property = getObject(); if(property!=null && !property.getName().equals(propertyName)) { propertyName=property.getName(); } classModel.detach(); } }
Example 6
Source File: BrowsePivotTableWidget.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public String getDefaultSql() { String thisLang = getLocale().getLanguage(); String systemLang = Locale.getDefault().getLanguage(); OClass oClass = getModelObject(); StringBuilder sb = new StringBuilder(); Collection<OProperty> properties = oClass.properties(); for(OProperty property: properties) { OType type = property.getType(); if(OType.LINK.equals(type)) { OClass linkedClass = property.getLinkedClass(); OProperty nameProperty = oClassIntrospector.getNameProperty(linkedClass); if(nameProperty!=null) { OType linkedClassType = nameProperty.getType(); String map = property.getName()+'.'+nameProperty.getName(); if (OType.EMBEDDEDMAP.equals(linkedClassType)) { sb.append("coalesce(").append(map).append('[').append(thisLang).append("], "); if(!thisLang.equals(systemLang)) { sb.append(map).append('[').append(systemLang).append("], "); } sb.append("first(").append(map).append(")) as ").append(property.getName()).append(", "); }else if(Comparable.class.isAssignableFrom(linkedClassType.getDefaultJavaType())) { sb.append(map).append(", "); } } }else if(Comparable.class.isAssignableFrom(type.getDefaultJavaType())) { sb.append(property.getName()).append(", "); } } if(sb.length()>0) sb.setLength(sb.length()-2); sb.insert(0, "SELECT "); sb.append(" FROM ").append(oClass.getName()); return sb.toString(); }
Example 7
Source File: ReferencesConsistencyHook.java From Orienteer with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void addLink(ODocument doc, OProperty property, ODocument value) { if(doc==null || property ==null || value == null || isUnderTheLock(doc)) return; String field = property.getName(); if(doc.getSchemaClass().isSubClassOf(property.getOwnerClass())) { Object wrappedValue = value.getIdentity().isPersistent()?value.getIdentity():value; Object oldValue = doc.field(field); if(property.getType().isMultiValue()) { Collection<Object> objects = (Collection<Object>) oldValue; if(objects==null) { objects = new ArrayList<Object>(1); objects.add(wrappedValue); doc.field(field, objects); //It's safe of fields with multivalue saveOutOfHook(doc); } else if(!objects.contains(wrappedValue)) { objects.add(wrappedValue); //It's safe of fields with multivalue saveOutOfHook(doc); } } else { if (oldValue==null || !oldValue.equals(wrappedValue)){ doc.field(field, wrappedValue); doc.save(); } } } }
Example 8
Source File: ReferencesConsistencyHook.java From Orienteer with Apache License 2.0 | 5 votes |
private void removeLink(ODocument doc, OProperty property, ODocument value) { if(doc==null || property ==null || value == null || isUnderTheLock(doc)) return; String field = property.getName(); if(doc.getSchemaClass().isSubClassOf(property.getOwnerClass())) { Object wrappedValue = value.getIdentity().isPersistent()?value.getIdentity():value; if(property.getType().isMultiValue()) { Collection<Object> objects = doc.field(field); if(objects!=null && objects.remove(wrappedValue)) { doc.field(field, objects); //It's safe for multivalue docs saveOutOfHook(doc); } } else { if(value.getIdentity().equals(doc.field(field, ORID.class))) { doc.field(field, (Object) null); doc.save(); } } } }
Example 9
Source File: OPropertyValueColumn.java From Orienteer with Apache License 2.0 | 5 votes |
private static String resolveSortExpression(OProperty property) { if(property==null || property.getType()==null) return null; Class<?> javaType = property.getType().getDefaultJavaType(); if(javaType!=null && Comparable.class.isAssignableFrom(javaType)) { return property.getName(); } else if (LocalizationVisualizer.NAME.equals(CustomAttribute.VISUALIZATION_TYPE.getValue(property))) { return String.format("%s['%s']", property.getName(), OrienteerWebSession.get().getLocale().getLanguage()); } else { return null; } }
Example 10
Source File: FilterCriteriaManager.java From wicket-orientdb with Apache License 2.0 | 4 votes |
public FilterCriteriaManager(OProperty property) { this(property.getName()); }
Example 11
Source File: OChoiceRenderer.java From wicket-orientdb with Apache License 2.0 | 4 votes |
public OChoiceRenderer(OProperty displayProperty) { this(displayProperty.getName()); }
Example 12
Source File: OChoiceRenderer.java From wicket-orientdb with Apache License 2.0 | 4 votes |
public OChoiceRenderer(OProperty displayProperty, OProperty idProperty) { this(displayProperty.getName(), idProperty.getName()); }
Example 13
Source File: ODocumentLinksQueryDataProvider.java From wicket-orientdb with Apache License 2.0 | 4 votes |
public ODocumentLinksQueryDataProvider(IModel<ODocument> docModel, OProperty property) { super("select expand("+property.getName()+") from "+property.getOwnerClass().getName()+" where @rid = :doc"); setParameter("doc", docModel); }
Example 14
Source File: LinksCollectionEditPanel.java From Orienteer with Apache License 2.0 | 4 votes |
public LinksCollectionEditPanel(String id, final IModel<ODocument> documentModel, OProperty property) { super(id, new DynamicPropertyValueModel<M>(documentModel, new OPropertyModel(property))); ISortableDataProvider<ODocument, String> provider = oClassIntrospector.prepareDataProviderForProperty(property, documentModel); final String propertyName = property.getName(); List<IColumn<ODocument, String>> columns = new ArrayList<IColumn<ODocument,String>>(); columns.add(new OEntityColumn(property.getLinkedClass(), DisplayMode.VIEW.asModel())); columns.add(new AbstractColumn<ODocument, String>(null) { @Override public void populateItem(Item<ICellPopulator<ODocument>> cellItem, String componentId, final IModel<ODocument> rowModel) { cellItem.add(new AjaxFormCommand<Object>(componentId, new ResourceModel("command.release")) { { setBootstrapType(BootstrapType.WARNING); setBootstrapSize(BootstrapSize.EXTRA_SMALL); } @Override public void onClick(Optional<AjaxRequestTarget> targetOptional) { ODocument doc = documentModel.getObject(); Collection<ODocument> values = doc.field(propertyName); if(values!=null) { values.remove(rowModel.getObject()); } doc.save(); } }); } }); GenericTablePanel<ODocument> tablePanel = new GenericTablePanel<>("links", columns, provider, 10); OrienteerDataTable<ODocument, String> table = tablePanel.getDataTable(); table.getHeadersToolbar().setVisibilityAllowed(false); table.getNoRecordsToolbar().setVisibilityAllowed(false); table.addCommand(new SelectODocumentCommand(table, documentModel, new OPropertyModel(property)) .setBootstrapSize(BootstrapSize.EXTRA_SMALL) .setIcon((String)null)); add(tablePanel); }