@Override public boolean apply(OType input) { return !input.isMultiValue(); } }));
public void checkPersistentPropertyType(final ODatabaseInternal<ORecord> database, final String propertyName, final OType type) { if (OType.ANY.equals(type)) { return; } final boolean strictSQL = database.getStorage().getConfiguration().isStrictSql(); final StringBuilder builder = new StringBuilder(256); builder.append("select count(*) as count from "); builder.append(getEscapedName(name, strictSQL)); builder.append(" where "); builder.append(getEscapedName(propertyName, strictSQL)); builder.append(".type() not in ["); final Iterator<OType> cur = type.getCastable().iterator(); while (cur.hasNext()) { builder.append('"').append(cur.next().name()).append('"'); if (cur.hasNext()) builder.append(","); } builder.append("] and ").append(getEscapedName(propertyName, strictSQL)).append(" is not null "); if (type.isMultiValue()) builder.append(" and ").append(getEscapedName(propertyName, strictSQL)).append(".size() <> 0 limit 1"); try (final OResultSet res = database.command(builder.toString())) { if (((Long) res.next().getProperty("count")) > 0) throw new OSchemaException("The database contains some schema-less data in the property '" + name + "." + propertyName + "' that is not compatible with the type " + type + ". Fix those records and change the schema again"); } }
public Array getArray(String columnLabel) throws SQLException { OType columnType = result.toElement().getSchemaType().map(t -> t.getProperty(columnLabel).getType()).orElse(OType.EMBEDDEDLIST); assert columnType.isEmbedded() && columnType.isMultiValue(); // System.out.println("columnType.name() = " + columnType.getDefaultJavaType()); Array array = new OrientJdbcArray(result.getProperty(columnLabel)); lastReadWasNull = array == null; return array; }
OType oType = propertyModel.getObject().getType(); if(!oType.isMultiValue() && objects.size()>1) if(oType.isMultiValue())
else if(type.isMultiValue())
@Override public OProperty getNameProperty(OClass oClass) { if(oClass==null) return null; OProperty ret = CustomAttribute.PROP_NAME.getValue(oClass); if(ret!=null) return ret; ret = oClass.getProperty("name"); if(ret!=null) return ret; for(OProperty p: oClass.properties()) { if(!p.getType().isMultiValue()) { ret = p; if(OType.STRING.equals(p.getType())) break; } } return ret; }
@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"; } } };
if(property.getType().isMultiValue())
if(type.isMultiValue())
@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; }
@Override protected void initializeContent(ModalWindow modal) { modal.setTitle(new ResourceModel("command.select.modal.title")); boolean multiValue = propertyModel.getObject().getType().isMultiValue(); modal.setContent(new SelectDialogPanel(modal.getContentId(), modal, new PropertyModel<OClass>(propertyModel, "linkedClass"), multiValue) {
OProperty property = ((ODocument) record).getSchemaClass() .getProperty(fieldName); if(property!=null && property.getType().isMultiValue()){ type = property.getLinkedType();
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(); } } } }
if(oClass!=null) { IModel<List<ODocument>> choicesModel = new OQueryModel<ODocument>("select from "+oClass.getName()+" LIMIT 100"); if(property.getType().isMultiValue())
if (record instanceof ODocument) { OProperty property = ((ODocument) record).getSchemaClass().getProperty(fieldName); if (property != null && property.getType().isMultiValue()) { type = property.getLinkedType();
if(changedProperty.getType().isMultiValue())