Java Code Examples for com.orientechnologies.orient.core.metadata.schema.OProperty#isReadonly()

The following examples show how to use com.orientechnologies.orient.core.metadata.schema.OProperty#isReadonly() . 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: ReadonlyFieldExtension.java    From guice-persist-orient with MIT License 5 votes vote down vote up
@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 2
Source File: ODocumentMetaPanel.java    From Orienteer with Apache License 2.0 5 votes vote down vote up
@Override
protected DisplayMode getEffectiveMode(DisplayMode mode, OProperty property) {
	if(mode.canModify() && property!= null
               && ((property.isReadonly() || (Boolean)CustomAttribute.UI_READONLY.getValue(property))
               		&& !(property.isMandatory() && !getEntityObject().containsField(property.getName())))
               	|| (!Strings.isEmpty(featureSpecification) 
               		&& !OSecurityHelper.isAllowed(OSecurityHelper.FEATURE_RESOURCE, featureSpecification, OrientPermission.UPDATE)))
	{
		return DisplayMode.VIEW;
	}
	return mode;
}
 
Example 3
Source File: LinksPropertyDataTablePanel.java    From Orienteer with Apache License 2.0 4 votes vote down vote up
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);
}