33#include "moc_qgsauxiliarystorage.cpp"
35using namespace Qt::StringLiterals;
37#define AS_JOINFIELD u"ASPK"_s
38#define AS_EXTENSION u"qgd"_s
39#define AS_JOINPREFIX u"auxiliary_storage_"_s
84 u
"%1_auxiliarystorage"_s.arg( table ), u
"ogr"_s )
85 , mFileName( filename )
91 mJoinInfo.setJoinLayer(
this );
93 mJoinInfo.setTargetFieldName( pkField );
94 mJoinInfo.setEditable(
true );
95 mJoinInfo.setUpsertOnEdit(
true );
96 mJoinInfo.setCascadedDelete(
true );
97 mJoinInfo.setJoinFieldNamesBlockList( QStringList() << u
"rowid"_s );
103 return new QgsAuxiliaryLayer( mJoinInfo.targetFieldName(), mFileName, target->
id(), target );
118 const QString pkField = mJoinInfo.targetFieldName();
119 QgsFeature joinFeature;
120 QgsFeature targetFeature;
128 QgsFeatureRequest request;
131 mLayer->getFeatures( request ).nextFeature( targetFeature );
135 QgsFeature newFeature( joinFeature );
136 newFeature.setGeometry( targetFeature.
geometry() );
157 if ( ( definition.
name().isEmpty() && definition.
comment().isEmpty() ) ||
exists( definition ) )
163 mLayer->updateFields();
168 const int index = mLayer->fields().indexOf(
nameFromProperty( definition,
true ) );
170 if ( index >= 0 && auxIndex >= 0 )
175 const QgsEditorWidgetSetup setup = QgsEditorWidgetSetup( u
"Hidden"_s, QVariantMap() );
179 QgsAttributeTableConfig attrCfg = mLayer->attributeTableConfig();
180 attrCfg.
update( mLayer->fields() );
181 QVector<QgsAttributeTableConfig::ColumnConfig> columns = attrCfg.
columns();
182 QVector<QgsAttributeTableConfig::ColumnConfig>::iterator it;
184 for ( it = columns.begin(); it != columns.end(); ++it )
186 if ( it->name.compare( mLayer->fields().field( index ).name() ) == 0 )
191 mLayer->setAttributeTableConfig( attrCfg );
196 const QgsEditorWidgetSetup setup = QgsEditorWidgetSetup( u
"Color"_s, QVariantMap() );
254 for (
const QString &providerId : subProviderIds )
256 QgsPalLayerSettings *settings =
new QgsPalLayerSettings( layer->
labeling()->
settings( providerId ) );
261 const QgsProperty existingProperty =
c.
property( property );
265 || overwriteExisting )
268 c.setProperty( property, prop );
275 c.setProperty( property, prop );
305 const QgsProperty existingProperty =
c.property( property );
309 c.setProperty( property, prop );
316 c.setProperty( property, prop );
343 for (
const QString &providerId : subProviderIds )
345 QgsPalLayerSettings *settings =
new QgsPalLayerSettings( layer->
labeling()->
settings( providerId ) );
350 const QgsProperty existingProperty =
c.property( property );
354 c.setProperty( property, prop );
361 c.setProperty( property, prop );
380 if ( def.
origin().compare(
"labeling"_L1 ) == 0 )
383 for (
const int p : palProps )
386 if ( propName.compare( def.
name() ) == 0 )
393 else if ( def.
origin().compare(
"symbol"_L1 ) == 0 )
396 for (
int p : symbolProps )
399 if ( propName.compare( def.
name() ) == 0 )
415 if ( aDef.
origin().compare(
"labeling"_L1 ) == 0 )
418 QgsPropertiesDefinition::const_iterator it = defs.constBegin();
419 for ( ; it != defs.constEnd(); ++it )
421 if ( it->name().compare( aDef.
name(), Qt::CaseInsensitive ) == 0 )
428 else if ( aDef.
origin().compare(
"symbol"_L1 ) == 0 )
431 QgsPropertiesDefinition::const_iterator it = defs.constBegin();
432 for ( ; it != defs.constEnd(); ++it )
434 if ( it->name().compare( aDef.
name(), Qt::CaseInsensitive ) == 0 )
441 else if ( aDef.
origin().compare(
"diagram"_L1 ) == 0 )
444 QgsPropertiesDefinition::const_iterator it = defs.constBegin();
445 for ( ; it != defs.constEnd(); ++it )
447 if ( it->name().compare( aDef.
name(), Qt::CaseInsensitive ) == 0 )
470 QString fieldName = def.
origin();
472 if ( !def.
name().isEmpty() )
473 fieldName = u
"%1_%2"_s.arg( fieldName, def.
name().toLower() );
475 if ( !def.
comment().isEmpty() )
476 fieldName = u
"%1_%2"_s.arg( fieldName, def.
comment() );
488 if ( !def.
name().isEmpty() || !def.
comment().isEmpty() )
490 QMetaType::Type
type = QMetaType::Type::UnknownType;
492 int len( 0 ), precision( 0 );
496 type = QMetaType::Type::QString;
498 typeName = u
"String"_s;
501 type = QMetaType::Type::Double;
504 typeName = u
"Real"_s;
507 type = QMetaType::Type::Int;
508 typeName = u
"Integer"_s;
524 QgsPropertyDefinition def;
525 const QStringList parts = f.
name().split(
'_' );
527 if ( parts.size() <= 1 )
530 const QString origin = parts[0];
531 const QString propertyName = parts[1];
533 if ( origin.compare(
"labeling"_L1, Qt::CaseInsensitive ) == 0 )
536 for (
auto it = props.constBegin(); it != props.constEnd(); ++it )
538 if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
541 if ( parts.size() >= 3 )
547 else if ( origin.compare(
"symbol"_L1, Qt::CaseInsensitive ) == 0 )
550 for (
auto it = props.constBegin(); it != props.constEnd(); ++it )
552 if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
555 if ( parts.size() >= 3 )
561 else if ( origin.compare(
"diagram"_L1, Qt::CaseInsensitive ) == 0 )
564 for (
auto it = props.constBegin(); it != props.constEnd(); ++it )
566 if ( it.value().name().compare( propertyName, Qt::CaseInsensitive ) == 0 )
569 if ( parts.size() >= 3 )
581 case QMetaType::Type::Double:
585 case QMetaType::Type::Bool:
589 case QMetaType::Type::QString:
595 if ( parts.size() >= 3 )
607 if ( !def.
name().isEmpty() || !def.
comment().isEmpty() )
627 mFileName = filenameForProject( project );
634 : mFileName( filename )
644 if ( QFile::exists( mTmpFileName ) )
645 QFile::remove( mTmpFileName );
660 if ( mFileName.isEmpty() )
667 if ( QFile::exists( mFileName ) )
668 QFile::remove( mFileName );
670 return QFile::copy( mTmpFileName, mFileName );
683 QgsAuxiliaryLayer *alayer =
nullptr;
685 if ( mValid && layer )
687 const QString table( layer->
id() );
688 sqlite3_database_unique_ptr database;
691 if ( !tableExists( table, database.get() ) )
693 if ( !createTable( field.
typeName(), table, database.get(), mErrorString ) )
709 const QgsDataSourceUri uri = parseOgrUri( ogrUri );
713 sqlite3_database_unique_ptr database;
714 database = openDB( uri.
database() );
718 QString sql = u
"DROP TABLE %1"_s.arg( uri.
table() );
719 rc = exec( sql, database.get() );
722 rc = exec( sql, database.get() );
731 const QgsDataSourceUri uri = parseOgrUri( ogrUri );
736 sqlite3_database_unique_ptr database;
737 database = openDB( uri.
database() );
741 const QString sql = u
"CREATE TABLE %1 AS SELECT * FROM %2"_s.arg( newTable, uri.
table() );
742 rc = exec( sql, database.get() );
756 mErrorString.clear();
758 QFile dest( filename );
759 if ( dest.exists() && !dest.remove() )
761 mErrorString = dest.errorString();
766 if ( !origin.copy( filename ) )
768 mErrorString = origin.errorString();
777 return saveAs( filenameForProject( project ) );
787 const QFileInfo fileinfo( filenameForProject( project ) );
788 return fileinfo.exists() && fileinfo.isFile();
791bool QgsAuxiliaryStorage::exec(
const QString &sql,
sqlite3 *handler )
797 const int err = sqlite3_exec( handler, sql.toStdString().c_str(),
nullptr,
nullptr,
nullptr );
799 if ( err == SQLITE_OK )
802 debugMsg( sql, handler );
808QString QgsAuxiliaryStorage::debugMsg(
const QString &sql,
sqlite3 *handler )
810 const QString err = QString::fromUtf8( sqlite3_errmsg( handler ) );
811 const QString msg = QObject::tr(
"Unable to execute" );
812 const QString errMsg = QObject::tr(
"%1 '%2': %3" ).arg( msg, sql, err );
817bool QgsAuxiliaryStorage::createTable(
const QString &type,
const QString &table,
sqlite3 *handler, QString &errorMsg )
819 const QString sql = u
"CREATE TABLE IF NOT EXISTS '%1' ( '%2' %3 )"_s.arg( table,
AS_JOINFIELD, type );
821 if ( !exec( sql, handler ) )
823 errorMsg = QgsAuxiliaryStorage::debugMsg( sql, handler );
832 sqlite3_database_unique_ptr database;
835 rc = database.
open_v2( filename, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
nullptr );
838 debugMsg( u
"sqlite3_open_v2"_s, database.get() );
842 exec( u
"PRAGMA foreign_keys = 1"_s, database.get() );
849 sqlite3_database_unique_ptr database;
850 const int rc = database.
open_v2( filename, SQLITE_OPEN_READWRITE,
nullptr );
854 debugMsg( u
"sqlite3_open_v2"_s, database.get() );
860bool QgsAuxiliaryStorage::tableExists(
const QString &table,
sqlite3 *handler )
862 const QString sql = u
"SELECT 1 FROM sqlite_master WHERE type='table' AND name='%1'"_s.arg( table );
865 char **results =
nullptr;
866 const int rc = sqlite3_get_table( handler, sql.toStdString().c_str(), &results, &rows, &columns,
nullptr );
867 if ( rc != SQLITE_OK )
869 debugMsg( sql, handler );
873 sqlite3_free_table( results );
882 sqlite3_database_unique_ptr database;
884 if ( filename.isEmpty() )
889 else if ( QFile::exists( filename ) )
892 QFile::copy( filename, mTmpFileName );
908 return open( filenameForProject( project ) );
911QString QgsAuxiliaryStorage::filenameForProject(
const QgsProject &project )
914 const QString path = info.path() + QDir::separator() + info.baseName();
918void QgsAuxiliaryStorage::initTmpFileName()
920 QTemporaryFile tmpFile;
921 if ( !tmpFile.open() )
927 mTmpFileName = tmpFile.fileName();
932 if ( mCopy || mFileName.isEmpty() )
940 QgsDataSourceUri newUri;
944 QStringList uriParts = uri.
uri().split(
'|' );
945 if ( uriParts.count() < 2 )
948 const QString databasePath = uriParts[0].replace(
' ', QString() );
950 const QString table = uriParts[1];
951 QStringList tableParts = table.split(
' ' );
953 if ( tableParts.count() < 1 )
956 const QString tableName = tableParts[0].replace(
"layername="_L1, QString() );
@ Invalid
Invalid (not set) property.
@ Field
Field based property.
@ Expression
Expression based property.
virtual QStringList subProviders() const
Gets list of sub-providers within the layer's labeling.
virtual void setSettings(QgsPalLayerSettings *settings, const QString &providerId=QString())=0
Set pal settings for a specific provider (takes ownership).
virtual QgsPalLayerSettings settings(const QString &providerId=QString()) const =0
Gets associated label settings.
QVector< QgsAttributeTableConfig::ColumnConfig > columns() const
Gets the list with all columns and their configuration.
void update(const QgsFields &fields)
Update the configuration with the given fields.
void setColumns(const QVector< QgsAttributeTableConfig::ColumnConfig > &columns)
Set the list of columns visible in the attribute table.
Allows managing the auxiliary storage for a vector layer.
static QString nameFromProperty(const QgsPropertyDefinition &def, bool joined=false)
Returns the name of the auxiliary field for a property definition.
static QgsField createAuxiliaryField(const QgsPropertyDefinition &definition)
Creates a new auxiliary field from a property definition.
static QgsPropertyDefinition propertyDefinitionFromField(const QgsField &field)
Returns the property definition from an auxiliary field.
bool clear()
Deletes all features from the layer.
bool addAuxiliaryField(const QgsPropertyDefinition &definition)
Adds an auxiliary field for the given property.
bool isHiddenProperty(int index) const
Returns true if the underlying field has to be hidden from editing tools like attribute table,...
QgsVectorLayer * toSpatialLayer() const
An auxiliary layer is not spatial.
bool deleteAttribute(int attr) override
Removes attribute from the layer and commits changes.
QgsFields auxiliaryFields() const
Returns a list of all auxiliary fields currently managed by the layer.
QgsAuxiliaryLayer(const QString &pkField, const QString &filename, const QString &table, QgsVectorLayer *vlayer)
Constructor.
bool save()
Commits changes and starts editing then.
int propertyFromIndex(int index) const
Returns the underlying property key for the field index.
QgsVectorLayerJoinInfo joinInfo() const
Returns information to use for joining with primary key and so on.
QgsVectorLayer * clone() const override
Returns a new instance equivalent to this one.
QgsPropertyDefinition propertyDefinitionFromIndex(int index) const
Returns the property definition for the underlying field index.
bool exists(const QgsPropertyDefinition &definition) const
Returns true if the property is stored in the layer already, false otherwise.
static int createProperty(QgsPalLayerSettings::Property property, QgsVectorLayer *vlayer, bool overwriteExisting=true)
Creates if necessary a new auxiliary field for a PAL property and activates this property in settings...
int indexOfPropertyDefinition(const QgsPropertyDefinition &definition) const
Returns the index of the auxiliary field for a specific property definition.
static QString extension()
Returns the extension used for auxiliary databases.
QString errorString() const
Returns the underlying error string describing potential errors happening in saveAs().
bool save() const
Saves the current database.
static bool exists(const QgsProject &project)
Returns true if the auxiliary database yet exists for a project, false otherwise.
QgsAuxiliaryLayer * createAuxiliaryLayer(const QgsField &field, QgsVectorLayer *layer) const
Creates an auxiliary layer for a vector layer.
virtual ~QgsAuxiliaryStorage()
bool saveAs(const QString &filename)
Saves the current database to a new path.
bool isValid() const
Returns the status of the auxiliary storage currently defined.
QString currentFileName() const
Returns the path of the current database used.
QgsAuxiliaryStorage(const QgsProject &project, bool copy=true)
Constructor.
QString fileName() const
Returns the target filename of the database.
static bool deleteTable(const QgsDataSourceUri &uri)
Removes a table from the auxiliary storage.
static bool duplicateTable(const QgsDataSourceUri &uri, const QString &newTable)
Duplicates a table and its content.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the callout's property collection, used for data defined overrides.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the callout's property collection, used for data defined overrides.
static QgsPropertiesDefinition propertyDefinitions()
Returns the definitions for data defined properties available for use in callouts.
Property
Data definable properties.
Stores the component parts of a data source URI (e.g.
QString table() const
Returns the table name stored in the URI.
QString uri(bool expandAuthConfig=true) const
Returns the complete URI as a string.
void setDataSource(const QString &aSchema, const QString &aTable, const QString &aGeometryColumn, const QString &aSql=QString(), const QString &aKeyColumn=QString())
Sets all data source related members at once.
QString database() const
Returns the database name stored in the URI.
void setDatabase(const QString &database)
Sets the URI database name.
Property
Data definable properties.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the diagram property definitions.
static QString createFieldEqualityExpression(const QString &fieldName, const QVariant &value, QMetaType::Type fieldType=QMetaType::Type::UnknownType)
Create an expression allowing to evaluate if a field is equal to a value.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes).
bool nextFeature(QgsFeature &f)
Fetch next feature and stores in f, returns true on success.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
virtual QgsFeatureIds allFeatureIds() const
Returns a list of all feature IDs for features present in the source.
bool isValid() const
Returns the validity of this feature.
Q_INVOKABLE QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
Encapsulate a field in an attribute table or data source.
QString typeName() const
Gets the field type.
void setPrecision(int precision)
Set the field precision.
void setName(const QString &name)
Set the field name.
void setType(QMetaType::Type type)
Set variant type.
void setLength(int len)
Set the field length.
void setTypeName(const QString &typeName)
Set the field type.
Container of fields for a vector layer.
bool append(const QgsField &field, Qgis::FieldOrigin origin=Qgis::FieldOrigin::Provider, int originIndex=-1)
Appends a field.
Q_INVOKABLE int indexOf(const QString &fieldName) const
Gets the field index from the field name.
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
QString source() const
Returns the source for the layer.
friend class QgsVectorLayer
static QgsVectorLayer * createMemoryLayer(const QString &name, const QgsFields &fields, Qgis::WkbType geometryType=Qgis::WkbType::NoGeometry, const QgsCoordinateReferenceSystem &crs=QgsCoordinateReferenceSystem(), bool loadDefaultStyle=true) SIP_FACTORY
Creates a new memory layer using the specified parameters.
QgsPropertyCollection & dataDefinedProperties()
Returns a reference to the label's property collection, used for data defined overrides.
QgsCallout * callout() const
Returns the label callout renderer, responsible for drawing label callouts.
void setDataDefinedProperties(const QgsPropertyCollection &collection)
Sets the label's property collection, used for data defined overrides.
Property
Data definable properties.
@ PositionX
X-coordinate data defined label position.
@ MinScale
Min scale (deprecated, for old project compatibility only).
@ LabelRotation
Label rotation.
@ FontStyle
Font style name.
@ Italic
Use italic style.
@ PositionY
Y-coordinate data defined label position.
@ Vali
Vertical alignment for data defined label position (Bottom, Base, Half, Cap, Top).
@ MaxScale
Max scale (deprecated, for old project compatibility only).
@ Strikeout
Use strikeout.
@ LabelAllParts
Multipart geometry behavior.
@ Underline
Use underline.
@ Hali
Horizontal alignment for data defined label position (Left, Center, Right).
@ CalloutDraw
Show callout.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the labeling property definitions.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QString absoluteFilePath() const
Returns full absolute path to the project file if the project is stored in a file system - derived fr...
QgsProperty property(int key) const final
Returns a matching property from the collection, if one exists.
Definition for a property.
StandardPropertyTemplate standardTemplate() const
Returns the property's standard template, if applicable.
QString comment() const
Returns the comment of the property.
DataType dataType() const
Returns the allowable field/value data type for the property.
void setOrigin(const QString &origin)
Sets the origin of the property.
@ ColorNoAlpha
Color with no alpha channel.
@ ColorWithAlpha
Color with alpha channel.
QString name() const
Returns the name of the property.
void setDataType(DataType type)
Sets the data type.
void setName(const QString &name)
Sets the name of the property.
QString origin() const
Returns the origin of the property.
void setComment(const QString &comment)
Sets comment of the property.
@ DataTypeString
Property requires a string value.
@ DataTypeBoolean
Property requires a boolean value.
@ DataTypeNumeric
Property requires a numeric value.
QString asExpression() const
Returns an expression string representing the state of the property, or an empty string if the proper...
QString expressionString() const
Returns the expression used for the property value.
Qgis::PropertyType propertyType() const
Returns the property type.
QString field() const
Returns the current field name the property references.
static QgsProperty fromExpression(const QString &expression, bool isActive=true)
Returns a new ExpressionBasedProperty created from the specified expression.
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
static const QgsPropertiesDefinition & propertyDefinitions()
Returns the symbol layer property definitions.
Defines left outer join from our vector layer to some other vector layer.
Represents a vector layer which manages a vector based dataset.
bool isEditable() const final
Returns true if the provider is in editing mode.
Q_INVOKABLE bool deleteFeatures(const QgsFeatureIds &fids, QgsVectorLayer::DeleteContext *context=nullptr)
Deletes a set of features from the layer (but does not commit it).
Q_INVOKABLE bool startEditing()
Makes the layer editable.
Q_INVOKABLE bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
void updateFields()
Will regenerate the fields property of this layer by obtaining all fields from the dataProvider,...
const QgsDiagramLayerSettings * diagramLayerSettings() const
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
virtual Q_INVOKABLE bool deleteAttribute(int attr)
Deletes an attribute field (but does not commit it).
void setEditorWidgetSetup(int index, const QgsEditorWidgetSetup &setup)
Sets the editor widget setup for the field at the specified index.
Q_INVOKABLE bool commitChanges(bool stopEditing=true)
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
QgsEditorWidgetSetup editorWidgetSetup(int index) const
Returns the editor widget setup for the field at the specified index.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const final
Queries the layer for features specified in request.
void setDiagramLayerSettings(const QgsDiagramLayerSettings &s)
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) final
Adds a single feature to the sink.
Unique pointer for sqlite3 databases, which automatically closes the database when the pointer goes o...
int open_v2(const QString &path, int flags, const char *zVfs)
Opens the database at the specified file path.
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
Q_GLOBAL_STATIC_WITH_ARGS(PalPropertyList, palHiddenProperties,({ static_cast< int >(QgsPalLayerSettings::Property::PositionX), static_cast< int >(QgsPalLayerSettings::Property::PositionY), static_cast< int >(QgsPalLayerSettings::Property::Show), static_cast< int >(QgsPalLayerSettings::Property::LabelRotation), static_cast< int >(QgsPalLayerSettings::Property::Family), static_cast< int >(QgsPalLayerSettings::Property::FontStyle), static_cast< int >(QgsPalLayerSettings::Property::Size), static_cast< int >(QgsPalLayerSettings::Property::Bold), static_cast< int >(QgsPalLayerSettings::Property::Italic), static_cast< int >(QgsPalLayerSettings::Property::Underline), static_cast< int >(QgsPalLayerSettings::Property::Color), static_cast< int >(QgsPalLayerSettings::Property::Strikeout), static_cast< int >(QgsPalLayerSettings::Property::MultiLineAlignment), static_cast< int >(QgsPalLayerSettings::Property::BufferSize), static_cast< int >(QgsPalLayerSettings::Property::BufferDraw), static_cast< int >(QgsPalLayerSettings::Property::BufferColor), static_cast< int >(QgsPalLayerSettings::Property::LabelDistance), static_cast< int >(QgsPalLayerSettings::Property::Hali), static_cast< int >(QgsPalLayerSettings::Property::Vali), static_cast< int >(QgsPalLayerSettings::Property::ScaleVisibility), static_cast< int >(QgsPalLayerSettings::Property::MinScale), static_cast< int >(QgsPalLayerSettings::Property::MaxScale), static_cast< int >(QgsPalLayerSettings::Property::AlwaysShow), static_cast< int >(QgsPalLayerSettings::Property::CalloutDraw), static_cast< int >(QgsPalLayerSettings::Property::LabelAllParts) })) Q_GLOBAL_STATIC_WITH_ARGS(SymbolPropertyList
QVector< int > SymbolPropertyList
QVector< int > PalPropertyList
#define QgsDebugError(str)
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.