com.orientechnologies.orient.core.metadata.schema.OProperty Java Examples
The following examples show how to use
com.orientechnologies.orient.core.metadata.schema.OProperty.
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: OrientDbLoader.java From nextreports-server with Apache License 2.0 | 6 votes |
protected void createProperties(Row row) { OClass clazz; if (className != null) { clazz = getOrCreateClass(className); } else { clazz = ((ODocument) row.getPayload()).getSchemaClass(); } int count = row.getFieldCount(); for (int i = 0; i < count; i++) { String fieldName = row.getFieldName(i); OProperty property = clazz.getProperty(fieldName); if (property == null) { OType type = OType.getTypeByClass(row.getFieldType(i)); try { clazz.createProperty(fieldName, type); } catch (OSchemaException e) { log.error(e.getMessage(), e); } log.debug("Created property '{}' of type '{}'", fieldName, type); } } }
Example #2
Source File: CollectionLinkFilterPanel.java From Orienteer with Apache License 2.0 | 6 votes |
public CollectionLinkFilterPanel(String id, IModel<Collection<ODocument>> model, String filterId, IModel<OProperty> propertyModel, IVisualizer visualizer, IFilterCriteriaManager manager) { super(id, model, filterId, propertyModel, visualizer, manager, Model.of(true)); WebMarkupContainer container = new WebMarkupContainer(getFilterId()) { @Override public IMarkupFragment getMarkup(Component child) { if (child != null && (child.getId().equals("classes") || child.getId().equals("documents"))) return markupProvider.provideMarkup(child); return super.getMarkup(child); } }; IModel<Collection<String>> classNamesModel = new CollectionModel<>(); Label classLabel = new Label("classLabel", new ResourceModel("widget.document.filter.linkCollection.class")); classLabel.add(AttributeModifier.append("style", "display: block")); Label documentLabel = new Label("documentLabel", new ResourceModel("widget.document.filter.linkCollection.document")); documentLabel.add(AttributeModifier.append("style", "display: block")); container.add(classesFormComponent = createClassChooseComponent("classes", classNamesModel)); container.add(docsFormComponent = createODocumentChooseComponent("documents", classNamesModel, getModel())); container.add(classLabel); container.add(documentLabel); add(container); }
Example #3
Source File: OAuth2ProviderVisualizer.java From Orienteer with Apache License 2.0 | 6 votes |
@Override @SuppressWarnings("unchecked") public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { if (mode == DisplayMode.EDIT) { return new Select2Choice<>(id, (IModel<String>) valueModel, createProvider()); } return new Label(id, valueModel) { @Override public void onComponentTagBody(MarkupStream markupStream, ComponentTag openTag) { String name = (String) getDefaultModelObject(); IOAuth2Provider provider = getProviderByName(name); String label = createProviderLabelModel(provider).getObject(); replaceComponentTagBody(markupStream, openTag, label); } }; }
Example #4
Source File: LegacyKeyStoreUpgradeServiceTest.java From nexus-public with Eclipse Public License 1.0 | 6 votes |
@Test public void testUpgradeSchema_TypeDoesNotYetExist() throws Exception { service.upgradeSchema(); try (ODatabaseDocumentTx db = database.getInstance().connect()) { OSchema schema = db.getMetadata().getSchema(); OClass type = schema.getClass("key_store"); assertThat(type, is(notNullValue())); OProperty prop = type.getProperty("name"); assertThat(prop, is(notNullValue())); assertThat(prop.isMandatory(), is(true)); assertThat(prop.isNotNull(), is(true)); assertThat(prop.getType(), is(OType.STRING)); prop = type.getProperty("bytes"); assertThat(prop, is(notNullValue())); assertThat(prop.isMandatory(), is(true)); assertThat(prop.isNotNull(), is(true)); assertThat(prop.getType(), is(OType.BINARY)); assertThat(type.getInvolvedIndexes("name"), hasSize(1)); assertThat(type.getInvolvedIndexes("name").iterator().next().getType(), is("UNIQUE")); } }
Example #5
Source File: AbstractMetaColumn.java From Orienteer with Apache License 2.0 | 6 votes |
/** * Get component for supported filtering column * @param id - component id * @param propertyModel - property model for view * @param filterForm - form for filters * @return component which support filtering */ protected Component getComponentForFiltering(String id, IModel<OProperty> propertyModel, FilterForm<OQueryModel<?>> filterForm) { UIVisualizersRegistry registry = OrienteerWebApplication.lookupApplication().getUIVisualizersRegistry(); String visualizerName = CustomAttribute.VISUALIZATION_TYPE.getValue(propertyModel.getObject()); if (visualizerName == null) { visualizerName = "default"; } IVisualizer visualizer = registry.getComponentFactory(propertyModel.getObject().getType(), visualizerName); if (visualizer == null) { visualizer = registry.getComponentFactory(propertyModel.getObject().getType(), "default"); } Component component = visualizer.createFilterComponent(id, propertyModel, filterForm); if (component == null) { visualizer = registry.getComponentFactory(propertyModel.getObject().getType(), "default"); component = visualizer.createFilterComponent(id, propertyModel, filterForm); } return component; }
Example #6
Source File: AbstractFormWidget.java From Orienteer with Apache License 2.0 | 6 votes |
public AbstractFormWidget(String id, IModel<ODocument> model, IModel<ODocument> widgetDocumentModel) { super(id, model, widgetDocumentModel); formKey = obtainFormKey(); String formKeyStr = formKey.toString(); add(new Label("formKey", formKeyStr)); setVisible(formKey.isValid()); formDocumentModel = new ODocumentModel(resolveODocument(formKey)); Form<ODocument> form = new Form<ODocument>("form", getModel()); IModel<List<OProperty>> propertiesModel = new LoadableDetachableModel<List<OProperty>>() { @Override protected List<OProperty> load() { return oClassIntrospector.listProperties(formDocumentModel.getObject().getSchemaClass(), IOClassIntrospector.DEFAULT_TAB, false); } }; propertiesStructureTable = new OrienteerStructureTable<ODocument, OProperty>("properties", formDocumentModel, propertiesModel){ @Override protected Component getValueComponent(String id, IModel<OProperty> rowModel) { return new ODocumentMetaPanel<Object>(id, getModeModel(), formDocumentModel, rowModel); } }; form.add(propertiesStructureTable); add(form); }
Example #7
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 #8
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@Test public void testListModels() { IModel<String> classNameModel = Model.of(); IModel<OClass> classModel = new OClassModel(classNameModel); IModel<List<OProperty>> propertiesModel = new ListOPropertiesModel(classModel, null); IModel<List<OIndex<?>>> indexesModel = new ListOIndexesModel(classModel, null); List<OProperty> properties = propertiesModel.getObject(); List<OIndex<?>> indexes = indexesModel.getObject(); assertNotNull(properties); assertNotNull(indexes); assertTrue(properties.isEmpty()); assertTrue(indexes.isEmpty()); classModel.detach(); propertiesModel.detach(); indexesModel.detach(); classNameModel.setObject("OUser"); properties = propertiesModel.getObject(); indexes = indexesModel.getObject(); assertNotNull(properties); assertNotNull(indexes); assertFalse(properties.isEmpty()); assertFalse(indexes.isEmpty()); }
Example #9
Source File: TestModels.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@Test public void testOPropertiesDataProvider() { OSchema schema = wicket.getTester().getSchema(); OClass oClass = schema.getClass("ClassA"); OPropertiesDataProvider provider = new OPropertiesDataProvider(oClass, true); provider.setSort("name", SortOrder.ASCENDING); Iterator<? extends OProperty> it = provider.iterator(0, -1); List<OProperty> allProperties = new ArrayList<OProperty>(oClass.properties()); while(it.hasNext()) { OProperty oProperty = it.next(); assertTrue(allProperties.remove(provider.model(oProperty).getObject())); } assertTrue(allProperties.size()==0); provider.detach(); }
Example #10
Source File: ODocumentMetaPanel.java From Orienteer with Apache License 2.0 | 6 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) @Override protected Component resolveComponent(String id, DisplayMode mode, OProperty property) { OType oType = property.getType(); UIVisualizersRegistry registry = OrienteerWebApplication.get().getUIVisualizersRegistry(); Function<String, Component> createComp = (String vis) -> { if(vis==null) return null; IVisualizer visualizer = registry.getComponentFactory(oType, vis); return visualizer!=null?visualizer.createComponent(id, mode, getEntityModel(), getPropertyModel(), getModel()):null; }; Component ret = null; if(this.visualization!=null) ret = createComp.apply(this.visualization); if(ret==null) { String visualizationComponent = CustomAttribute.VISUALIZATION_TYPE.getValue(property); ret = createComp.apply(visualizationComponent); } return ret!=null?ret:createComp.apply(IVisualizer.DEFAULT_VISUALIZER); }
Example #11
Source File: DynamicPropertyValueModel.java From wicket-orientdb with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override protected T load() { ODocument doc = docModel.getObject(); OProperty prop = propertyModel!=null?propertyModel.getObject():null; if(doc==null) return null; if(prop==null) return (T) doc; if(valueType==null) { return (T) doc.field(prop.getName()); } else { Object ret = doc.field(prop.getName(), valueType); if(ORecord.class.isAssignableFrom(valueType) && ret instanceof ORID) { ret = ((ORID)ret).getRecord(); } return (T) ret; } }
Example #12
Source File: CustomAttribute.java From Orienteer with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") public <V> V getValue(OProperty property, V defaultValue) { String stringValue = property.getCustom(name); if(encode) stringValue = decodeCustomValue(stringValue); V ret; if(OProperty.class.isAssignableFrom(javaClass)) { ret = (V)resolveProperty(property.getOwnerClass(), stringValue); } else { ret = (V) OType.convert(stringValue, javaClass); } return ret!=null?ret:defaultValue; }
Example #13
Source File: CreateODocumentCommand.java From Orienteer with Apache License 2.0 | 6 votes |
protected void redirectToCreateODocumentPage(AjaxRequestTarget target, OClass oClass) { ODocument doc = new ODocument(oClass); if(propertyModel!=null && documentModel!=null) { OProperty property = propertyModel.getObject(); if(property!=null) { OProperty inverseProperty = CustomAttribute.PROP_INVERSE.getValue(property); if(inverseProperty!=null) { doc.field(inverseProperty.getName(), documentModel.getObject()); } } } // target.add(new ODocumentPage(doc).setModeObject(DisplayMode.EDIT)); setResponsePage(new ODocumentPage(doc).setModeObject(DisplayMode.EDIT)); }
Example #14
Source File: ReleaseODocumentCommand.java From Orienteer with Apache License 2.0 | 6 votes |
@Override protected void performMultiAction(AjaxRequestTarget target, List<ODocument> objects) { if(objects==null || objects.isEmpty()) return; ODocument doc = documentModel.getObject(); if(doc!=null) { OProperty property = propertyModel.getObject(); if(property!=null) { Collection<ODocument> collection = doc.field(property.getName()); if(collection!=null) { for (ODocument oDocument : objects) { collection.remove(oDocument); } // collection.removeAll(objects); // doc.field(property.getName(), collection); doc.save(); } } } }
Example #15
Source File: DefaultFilterPredicateFactory.java From Orienteer with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public SerializablePredicate<OProperty> getPredicateForTableProperties() { return compose( CustomAttribute.DISPLAYABLE::getValue, getPredicateByFeatureProp(OrientPermission.READ) ); }
Example #16
Source File: LocalizationVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
@Override public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { switch (mode) { case VIEW: return new Label(id, new FunctionModel<>(new DynamicPropertyValueModel<>(documentModel, propertyModel), LocalizeFunction.getInstance())); case EDIT: return new OLocalizationEditPanel<V>(id, documentModel, propertyModel).setType(String.class); default: return null; } }
Example #17
Source File: TestFilters.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testContainsTextFilterCriteria() { IModel<OProperty> property = wicket.getProperty(STRING_FIELD); IFilterCriteriaManager manager = new FilterCriteriaManager(property); IModel<String> model = Model.of("summer"); manager.addFilterCriteria(manager.createContainsStringFilterCriteria(model, Model.of(true))); queryModel.addFilterCriteriaManager(property.getObject().getName(), manager); assertTrue(queryModel.size() == 1); assertTrue(queryModel.getObject().get(0).field(STRING_FIELD).equals(STR_VALUE_2)); }
Example #18
Source File: OrienteerMainTest.java From Orienteer with Apache License 2.0 | 5 votes |
@Test public void testViewClassesAndPropertiesPages() throws Exception { ODatabaseDocument db = getDatabase(); Collection<OClass> classes = db.getMetadata().getSchema().getClasses(); PageParameters parameters = new PageParameters(); tester.iterativelyTest(classes, oClass -> { parameters.clearNamed(); parameters.set("className", oClass.getName()); LOG.info("Rendering page for class '"+oClass.getName()+"'"); tester.startPage(OClassPage.class, parameters); tester.assertRenderedPage(OClassPage.class); Collection<OProperty> properties = oClass.properties(); for (OProperty oProperty : properties) { parameters.set("propertyName", oProperty.getName()); LOG.info("Rendering page for property '"+oProperty.getFullName()+"'"); tester.startPage(OPropertyPage.class, parameters); tester.assertRenderedPage(OPropertyPage.class); } Collection<OIndex<?>> indexes = oClass.getIndexes(); for (OIndex<?> oIndex : indexes) { parameters.set("indexName", oIndex.getName()); LOG.info("Rendering page for index '"+oIndex.getName()+"'"); tester.startPage(OIndexPage.class, parameters); tester.assertRenderedPage(OIndexPage.class); } return null; }).log(LOG, "Stats of rendering schema related pages: class, property, indexes"); }
Example #19
Source File: ODocumentPropertiesWidget.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected void onConfigure() { super.onConfigure(); IModel<? extends List<? extends OProperty>> propertiesModel = propertiesStructureTable.getCriteriesModel(); List<? extends OProperty> properties = propertiesModel.getObject(); setVisible((properties!=null && !properties.isEmpty()) ||getModel().getObject().getIdentity().isNew()); if(DisplayMode.EDIT.equals(getModeObject())) { saveODocumentCommand.configure(); if(!saveODocumentCommand.determineVisibility()) { setModeObject(DisplayMode.VIEW); } } }
Example #20
Source File: TestFilters.java From wicket-orientdb with Apache License 2.0 | 5 votes |
@Test public void testLinkMapKey() { String key = MAP_KEYS.get(0); IModel<OProperty> property = wicket.getProperty(LINK_MAP_FIELD); IFilterCriteriaManager manager = new FilterCriteriaManager(property); manager.addFilterCriteria(manager.createMapContainsKeyCriteria(Model.of(key), Model.<Boolean>of(true))); queryModel.addFilterCriteriaManager(LINK_MAP_FIELD, manager); assertTrue("size must be 1 but it is - " + queryModel.getObject().size() , queryModel.getObject().size() == 1); }
Example #21
Source File: OEntityColumn.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected <V> AbstractMetaPanel<ODocument, OProperty, V> newMetaPanel( String componentId, IModel<OProperty> criteryModel, IModel<ODocument> rowModel) { return new ODocumentMetaPanel<V>(componentId, getModeModel(), rowModel, criteryModel) { @Override protected Component resolveComponent(String id, DisplayMode mode, OProperty property) { if (DisplayMode.VIEW.equals(mode) || property == null) return new LinkViewPanel(id, getEntityModel(), new ODocumentNameModel(getEntityModel(), getCriteryModel())); else return super.resolveComponent(id, mode, property); } }; }
Example #22
Source File: ReadonlyFieldExtension.java From guice-persist-orient with MIT License | 5 votes |
@Override public void afterRegistration(final ODatabaseObject db, final SchemeDescriptor descriptor, final Field field, final Readonly annotation) { final String name = field.getName(); final boolean readonly = annotation.value(); final OProperty property = db.getMetadata().getSchema() .getClass(descriptor.schemeClass).getProperty(name); if (property.isReadonly() != readonly) { property.setReadonly(readonly); logger.debug("Set {}.{} property readonly={}", descriptor.schemeClass, name, readonly); } }
Example #23
Source File: EmbeddedCollectionFilterPanel.java From Orienteer with Apache License 2.0 | 5 votes |
public EmbeddedCollectionFilterPanel(String id, IModel<Collection<String>> model, String filterId, IModel<OProperty> propertyModel, IVisualizer visualizer, IFilterCriteriaManager manager, boolean isList) { super(id, model, filterId, propertyModel, visualizer, manager, Model.of(true)); this.isList = isList; collectionInput = Lists.newArrayList(); fieldFilter = new TextField<>("filter", Model.<String>of()); fieldFilter.setOutputMarkupPlaceholderTag(true); }
Example #24
Source File: MandatoryPropertyExtension.java From guice-persist-orient with MIT License | 5 votes |
@Override public void afterRegistration(final ODatabaseObject db, final SchemeDescriptor descriptor, final Field field, final Mandatory annotation) { final String name = field.getName(); final boolean mandatory = annotation.value(); final OProperty property = db.getMetadata().getSchema() .getClass(descriptor.schemeClass).getProperty(name); if (property.isMandatory() != mandatory) { property.setMandatory(mandatory); logger.debug("Set {}.{} property mandatory={}", descriptor.schemeClass, name, mandatory); } }
Example #25
Source File: CaseInsensitiveFieldExtension.java From guice-persist-orient with MIT License | 5 votes |
@Override public void afterRegistration(final ODatabaseObject db, final SchemeDescriptor descriptor, final Field field, final CaseInsensitive annotation) { final String name = field.getName(); final boolean ci = annotation.value(); final String collate = ci ? OCaseInsensitiveCollate.NAME : ODefaultCollate.NAME; final OProperty property = db.getMetadata().getSchema() .getClass(descriptor.schemeClass).getProperty(name); if (!property.getCollate().getName().equals(collate)) { property.setCollate(collate); logger.debug("Set {}.{} property case insensitive={}", descriptor.schemeClass, name, ci); } }
Example #26
Source File: ODocumentMetaPanel.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected void onPostResolveComponent(Component component, OProperty critery) { super.onPostResolveComponent(component, critery); if(component instanceof FormComponent) { if(critery.isNotNull()) ((FormComponent<?>)component).setRequired(true); ((FormComponent<?>)component).add(new OPropertyValueValidator<Object>(critery, getEntityModel())); } }
Example #27
Source File: HTMLVisualizer.java From Orienteer with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("unchecked") public <V> Component createComponent(String id, DisplayMode mode, IModel<ODocument> documentModel, IModel<OProperty> propertyModel, IModel<V> valueModel) { switch (mode) { case VIEW: return new Label(id, valueModel).setEscapeModelStrings(false); case EDIT: return new HtmlCssJsEditorPanel(id, (IModel<String>) valueModel, Model.of(mode)); default: return null; } }
Example #28
Source File: OPropertyValueComboBoxColumn.java From Orienteer with Apache License 2.0 | 5 votes |
@Override protected <V> AbstractMetaPanel<ODocument, OProperty, V> newMetaPanel(String componentId, final IModel<OProperty> criteryModel, final IModel<ODocument> rowModel) { return new AbstractMetaPanel<ODocument, OProperty, V>(componentId, rowModel, criteryModel) { @Override protected IModel<String> newLabelModel() { return new OPropertyNamingModel(getCriteryModel()); } @Override protected Component resolveComponent(String id, OProperty critery) { Select2Choice<T> comp = new Select2Choice<T>(id, (IModel<T>)getValueModel(), choiceProvider); comp.getSettings() .setCloseOnSelect(true) .setTheme(OClassMetaPanel.BOOTSTRAP_SELECT2_THEME) .setWidth("100%"); return comp; } @Override protected void onConfigure() { super.onConfigure(); setEnabled(getModeModel().getObject().equals(DisplayMode.EDIT)); } @Override protected IModel<V> resolveValueModel() { return new DynamicPropertyValueModel<V>(getEntityModel(), getPropertyModel()); } }; }
Example #29
Source File: ComponentDatabaseUpgrade_1_5.java From nexus-public with Eclipse Public License 1.0 | 5 votes |
private void modifyCaseInsensitiveNameField(final OClass type) { log.info("Modifying case-insensitive name field on component"); OProperty ciNameProperty = type.getProperty(P_CI_NAME); if (!ciNameProperty.isMandatory()) { ciNameProperty.setMandatory(true); } if (!ciNameProperty.isNotNull()) { ciNameProperty.setNotNull(true); } }
Example #30
Source File: OSchemaHelper.java From Orienteer with Apache License 2.0 | 5 votes |
public OSchemaHelper orderProperties(String... fields) { checkOClass(); for(int i=0; i<fields.length; i++) { String field = fields[i]; OProperty oProperty = lastClass.getProperty(field); if(oProperty!=null) { CustomAttribute.ORDER.setValue(oProperty, i*10); } } return this; }