Java Code Examples for com.orientechnologies.orient.core.metadata.schema.OProperty#getLinkedClass()
The following examples show how to use
com.orientechnologies.orient.core.metadata.schema.OProperty#getLinkedClass() .
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: 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 2
Source File: OClassIntrospector.java From Orienteer with Apache License 2.0 | 6 votes |
@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; }
Example 3
Source File: LinkEqualsFilterPanel.java From Orienteer with Apache License 2.0 | 6 votes |
private Select2Choice<OClass> createClassChoiceComponent(String id, IModel<OClass> classModel) { Select2Choice<OClass> choice = new Select2Choice<OClass>(id, classModel, new OClassTextChoiceProvider()) { @Override protected void onInitialize() { super.onInitialize(); OProperty property = LinkEqualsFilterPanel.this.getEntityModel().getObject(); if (property != null && property.getLinkedClass() != null) { setModelObject(property.getLinkedClass()); setEnabled(false); } } }; choice.getSettings() .setWidth("100%") .setCloseOnSelect(true) .setTheme(BOOTSTRAP_SELECT2_THEME) .setContainerCssClass("link-filter-class-choice"); choice.add(new AjaxFormSubmitBehavior("change") {}); choice.setOutputMarkupId(true); return choice; }
Example 4
Source File: CollectionLinkFilterPanel.java From Orienteer with Apache License 2.0 | 6 votes |
private Select2MultiChoice<String> createClassChooseComponent(String id, IModel<Collection<String>> classNamesModel) { Select2MultiChoice<String> choice = new Select2MultiChoice<String>(id, classNamesModel, OClassCollectionTextChoiceProvider.INSTANCE) { @Override protected void onInitialize() { super.onInitialize(); OProperty property = CollectionLinkFilterPanel.this.getEntityModel().getObject(); if (property != null && property.getLinkedClass() != null) { setModelObject(Arrays.asList(property.getLinkedClass().getName())); setEnabled(false); } } }; choice.getSettings() .setWidth("100%") .setCloseOnSelect(true) .setTheme(BOOTSTRAP_SELECT2_THEME) .setContainerCssClass("link-filter-class-choice"); choice.add(new AjaxFormSubmitBehavior("change") {}); return choice; }
Example 5
Source File: SuggestVisualizer.java From Orienteer with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { if (DisplayMode.EDIT.equals(mode)) { OProperty property = propertyModel.getObject(); OClass oClass = property.getLinkedClass(); if(oClass!=null) { AbstractSelect2Choice<?, ?> choice = property.getType().isMultiValue() ? new Select2MultiChoice<ODocument>(id, (IModel<Collection<ODocument>>) valueModel, new ODocumentChoiceProvider(oClass)) : new Select2Choice<ODocument>(id, (IModel<ODocument>) valueModel, new ODocumentChoiceProvider(oClass)); choice.getSettings() .setWidth("100%") .setCloseOnSelect(true) .setTheme(OClassMetaPanel.BOOTSTRAP_SELECT2_THEME); return choice; } else { LOG.warn("Property '"+property.getFullName()+"' doesn't have linked class specified."); } } return null; }
Example 6
Source File: OPropertyValueValidator.java From wicket-orientdb with Apache License 2.0 | 5 votes |
protected void validateLink(final IValidatable<T> validatable, final OProperty p, final Object linkValue) { if (linkValue == null) validatable.error(newValidationError("nulllink")); else { ORecord linkedRecord = null; if (linkValue instanceof OIdentifiable) linkedRecord = ((OIdentifiable) linkValue).getRecord(); else if (linkValue instanceof String) linkedRecord = new ORecordId((String) linkValue).getRecord(); else validatable.error(newValidationError("linkwrong")); if (linkedRecord != null && p.getLinkedClass() != null) { if (!(linkedRecord instanceof ODocument)) validatable.error(newValidationError("linktypewrong", "linkedClass", p.getLinkedClass(), "identity", linkedRecord.getIdentity())); final ODocument doc = (ODocument) linkedRecord; // AT THIS POINT CHECK THE CLASS ONLY IF != NULL BECAUSE IN CASE // OF GRAPHS THE RECORD COULD BE PARTIAL if (doc.getSchemaClass() != null && !p.getLinkedClass().isSuperClassOf( doc.getSchemaClass())) validatable.error(newValidationError("linktypewrong", "linkedClass", p.getLinkedClass(), "identity", linkedRecord.getIdentity())); } } }
Example 7
Source File: OPropertyValueValidator.java From wicket-orientdb with Apache License 2.0 | 5 votes |
protected void validateEmbedded(final IValidatable<T> validatable, final OProperty p, final Object fieldValue) { if (fieldValue instanceof ORecordId) { validatable.error(newValidationError("embeddedRecord")); return; } else if (fieldValue instanceof OIdentifiable) { if (((OIdentifiable) fieldValue).getIdentity().isValid()) { validatable.error(newValidationError("embeddedRecord")); return; } final OClass embeddedClass = p.getLinkedClass(); if (embeddedClass != null) { final ORecord rec = ((OIdentifiable) fieldValue).getRecord(); if (!(rec instanceof ODocument)) { validatable.error(newValidationError("embeddedNotDoc")); return; } final ODocument doc = (ODocument) rec; if (doc.getSchemaClass() == null || !(doc.getSchemaClass().isSubClassOf(embeddedClass))) { validatable.error(newValidationError("embeddedWrongType", "expectedType", embeddedClass.getName())); return; } } } else { validatable.error(newValidationError("embeddedNotDoc")); return; } }
Example 8
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 9
Source File: PlantUmlService.java From Orienteer with Apache License 2.0 | 5 votes |
public void describe(Writer writer, OProperty oProperty) { PrintWriter out = toPrintWriter(writer); OType type = oProperty.getType(); String min = oProperty.getMin(); String max = oProperty.getMax(); String range = null; if(min!=null || max!=null) { range = Objects.equal(min, max)?min:(min!=null?min:"0")+".."+(max!=null?max:"*"); } else if(type.isMultiValue()) { range = "*"; } boolean isEmbedded = type.equals(OType.EMBEDDED) || type.equals(OType.EMBEDDEDLIST) || type.equals(OType.EMBEDDEDMAP) || type.equals(OType.EMBEDDEDSET); if(oProperty.getLinkedClass()!=null && (isEmbedded || type.isLink())) { out.append(oProperty.getOwnerClass().getName()); if(isEmbedded) out.append("\"1\" *-- "); else out.append(" -> "); if(range!=null) out.append('"').append(range).append("\" "); out.append(oProperty.getLinkedClass().getName()); out.append(" : ").append(oProperty.getName()); } else { out.append(oProperty.getOwnerClass().getName()) .append(" : ") .append(oProperty.getName()).append(" : ").append(type.name()); } out.println(); }
Example 10
Source File: ListboxVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Override public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { if(DisplayMode.EDIT.equals(mode)) { OProperty property = propertyModel.getObject(); OClass oClass = property.getLinkedClass(); if(oClass!=null) { IModel<List<ODocument>> choicesModel = new OQueryModel<ODocument>("select from "+oClass.getName()+" LIMIT 100"); if(property.getType().isMultiValue()) { return new ListMultipleChoice<ODocument>(id, (IModel<Collection<ODocument>>) valueModel, choicesModel, new ODocumentChoiceRenderer()); } else { return new DropDownChoice<ODocument>(id, (IModel<ODocument>)valueModel, choicesModel, new ODocumentChoiceRenderer()) .setNullValid(!property.isNotNull()); } } else { OrienteerWebSession.get() .warn(OrienteerWebApplication.get().getResourceSettings() .getLocalizer().getString("errors.listbox.linkedclassnotdefined", null, new OPropertyNamingModel(propertyModel))); return new Label(id, ""); } } else { return null; } }
Example 11
Source File: LinksPropertyDataTablePanel.java From Orienteer with Apache License 2.0 | 4 votes |
public LinksPropertyDataTablePanel(String id, IModel<ODocument> documentModel, IModel<OProperty> propertyModel) { super(id, documentModel); this.propertyModel = propertyModel; OProperty property = propertyModel.getObject(); OClass linkedClass = property.getLinkedClass(); boolean isStructureReadonly = (Boolean)CustomAttribute.CALCULABLE.getValue(property) || (Boolean)CustomAttribute.UI_READONLY.getValue(property) || property.isReadonly(); IModel<DisplayMode> modeModel = DisplayMode.VIEW.asModel(); ISortableDataProvider<ODocument, String> provider = oClassIntrospector.prepareDataProviderForProperty(property, documentModel); GenericTablePanel<ODocument> tablePanel = new GenericTablePanel<ODocument>("tablePanel", oClassIntrospector.getColumnsFor(linkedClass, true, modeModel), provider, 20); OrienteerDataTable<ODocument, String> table = tablePanel.getDataTable(); final OPropertyNamingModel propertyNamingModel = new OPropertyNamingModel(propertyModel); table.setCaptionModel(propertyNamingModel); SecurityBehavior securityBehaviour = new SecurityBehavior(documentModel, OrientPermission.UPDATE); if(!isStructureReadonly) { table.addCommand(new CreateODocumentCommand(table, documentModel, propertyModel).add(securityBehaviour)); table.addCommand(new EditODocumentsCommand(table, modeModel, linkedClass).add(securityBehaviour)); table.addCommand(new SaveODocumentsCommand(table, modeModel).add(securityBehaviour)); table.addCommand(new CopyODocumentCommand(table, linkedClass).add(securityBehaviour)); table.addCommand(new DeleteODocumentCommand(table, linkedClass).add(securityBehaviour)); table.addCommand(new SelectODocumentCommand(table, documentModel, propertyModel).add(securityBehaviour)); table.addCommand(new ReleaseODocumentCommand(table, documentModel, propertyModel).add(securityBehaviour)); } else { table.addCommand(new EditODocumentsCommand(table, modeModel, linkedClass).add(securityBehaviour)); table.addCommand(new SaveODocumentsCommand(table, modeModel).add(securityBehaviour)); } table.addCommand(new ExportCommand<>(table, new LoadableDetachableModel<String>() { @Override protected String load() { return oClassIntrospector.getDocumentName(LinksPropertyDataTablePanel.this.getModelObject()) + "."+propertyNamingModel.getObject(); } })); add(tablePanel); }