/* Icon does not have a schema, so we create a synthetic one
It also does not have an id (it has user-defined key instead).
This presents some challenges because a lot of the model-code is tied
to them having an ID. So we add a "synthetic"-ID field

Some other fields are also "synthetic" (eg. does not exist at all on the Icon object).
These fields are needed in different places, eg. in the List etc

    - Access - this is calculated in the IconModelDefinition
    - Name  === key
    - Displayname === key
    - Icon === href . This is mostly because "href"-field is translated to "API URL", and there's no good way to override this
    - User === createdBy
*/

const iconSchemaDefinition = {
    klass: 'org.hisp.dhis.icon',
    shareable: false,
    translatable: false,
    metadata: false,
    identifiableObject: false,
    apiEndpoint: 'http://localhost:8080/dhis/api/29/icons',
    plural: 'icons',
    displayName: 'Icon',
    name: 'icon',
    singular: 'icon',
    authorities: [
        {
            type: 'CREATE_PUBLIC',
            authorities: ['M_dhis-web-maintenance'],
        },
        {
            type: 'CREATE_PRIVATE',
            authorities: ['M_dhis-web-maintenance'],
        },
        {
            type: 'DELETE',
            authorities: ['M_dhis-web-maintenance'],
        },
    ],
    properties: [
        {
            klass: 'java.lang.String',
            propertyType: 'IDENTIFIER',
            name: 'id',
            fieldName: 'key',
            persisted: true,
            description: 'The Unique Identifier for this Object.',
            attribute: true,
            simple: true,
            collection: false,
            ordered: false,
            owner: true,
            identifiableObject: false,
            nameableObject: false,
            embeddedObject: false,
            analyticalObject: false,
            readable: true,
            writable: true,
            unique: true,
            required: false,
            length: 11,
            max: 11,
            min: 11,
            manyToMany: false,
            oneToOne: false,
            manyToOne: false,
            oneToMany: false,
            translatable: false,
            gistPreferences: {
                included: 'AUTO',
                transformation: 'AUTO',
            },
            propertyTransformer: false,
        },
        {
            owner: false,
            ordered: false,
            collection: false,
            required: true,
            writable: true,
            embeddedObject: false,
            propertyType: 'TEXT',
            unique: false,
            name: 'key',
            persisted: true,
        },
        {
            owner: false,
            ordered: false,
            max: 500,
            collection: false,
            required: true,
            writable: true,
            min: 2,
            embeddedObject: false,
            propertyType: 'TEXT',
            unique: true,
            name: 'name',
            persisted: true,
        },
        {
            owner: false,
            ordered: false,
            max: 500,
            collection: false,
            required: true,
            writable: true,
            min: 2,
            embeddedObject: false,
            propertyType: 'TEXT',
            unique: true,
            name: 'displayName',
            persisted: true,
        },
        {
            owner: false,
            ordered: false,
            collection: false,
            required: false,
            writable: true,
            embeddedObject: false,
            propertyType: 'TEXT',
            unique: false,
            name: 'description',
            persisted: true,
        },
        {
            klass: 'java.lang.Boolean',
            propertyType: 'BOOLEAN',
            name: 'custom',
            fieldName: 'custom',
            persisted: false,
            namespace: 'http://dhis2.org/schema/dxf/2.0',
            attribute: false,
            simple: true,
            collection: false,
            ordered: false,
            owner: false,
            identifiableObject: false,
            nameableObject: false,
            embeddedObject: false,
            analyticalObject: false,
            readable: true,
            writable: false,
            unique: false,
            required: false,
            manyToMany: false,
            oneToOne: false,
            manyToOne: false,
            oneToMany: false,
            translatable: false,
            gistPreferences: {
                included: 'AUTO',
                transformation: 'AUTO',
            },
            propertyTransformer: false,
        },
        {
            klass: 'java.util.Set',
            propertyType: 'COLLECTION',
            itemKlass: 'java.lang.String',
            itemPropertyType: 'TEXT',
            name: 'keyword',
            fieldName: 'keywords',
            persisted: false,
            collectionName: 'keywords',
            collectionWrapping: true,
            namespace: 'http://dhis2.org/schema/dxf/2.0',
            attribute: false,
            simple: false,
            collection: true,
            ordered: false,
            owner: false,
            identifiableObject: false,
            nameableObject: false,
            embeddedObject: false,
            analyticalObject: false,
            readable: true,
            writable: true,
            unique: false,
            required: false,
            max: 1.7976931348623157e308,
            min: 0,
            manyToMany: false,
            oneToOne: false,
            manyToOne: false,
            oneToMany: false,
            translatable: false,
            gistPreferences: {
                included: 'FALSE',
                transformation: 'AUTO',
            },
            propertyTransformer: false,
        },

        {
            klass: 'java.lang.String',
            propertyType: 'URL',
            name: 'href',
            fieldName: 'href',
            persisted: false,
            attribute: true,
            simple: true,
            collection: false,
            ordered: false,
            owner: false,
            identifiableObject: false,
            nameableObject: false,
            embeddedObject: false,
            analyticalObject: false,
            readable: true,
            writable: true,
            unique: false,
            required: false,
            max: 1.7976931348623157e308,
            min: 0,
            manyToMany: false,
            oneToOne: false,
            manyToOne: false,
            oneToMany: false,
            translatable: false,
            gistPreferences: {
                included: 'AUTO',
                transformation: 'AUTO',
            },
            propertyTransformer: false,
        },
        {
            klass: 'java.lang.String',
            propertyType: 'URL',
            name: 'icon',
            fieldName: 'href',
            persisted: false,
            attribute: true,
            simple: true,
            collection: false,
            ordered: false,
            owner: false,
            identifiableObject: false,
            nameableObject: false,
            embeddedObject: false,
            analyticalObject: false,
            readable: true,
            writable: true,
            unique: false,
            required: false,
            max: 1.7976931348623157e308,
            min: 0,
            manyToMany: false,
            oneToOne: false,
            manyToOne: false,
            oneToMany: false,
            translatable: false,
            gistPreferences: {
                included: 'AUTO',
                transformation: 'AUTO',
            },
            propertyTransformer: false,
        },
        {
            fieldName: 'created',
            description: 'The date this object was created.',
            simple: true,
            required: false,
            writable: true,
            nameableObject: false,
            klass: 'java.util.Date',
            propertyType: 'DATE',
            oneToOne: false,
            attribute: true,
            owner: true,
            readable: true,
            ordered: false,
            identifiableObject: false,
            manyToMany: false,
            length: 255,
            collection: false,
            embeddedObject: false,
            unique: false,
            name: 'created',
            persisted: true,
            manyToOne: false,
        },
        {
            klass: 'org.hisp.dhis.user.User',
            propertyType: 'REFERENCE',
            name: 'user',
            fieldName: 'user',
            persisted: false,
            namespace: 'http://dhis2.org/schema/dxf/2.0',
            attribute: false,
            simple: false,
            collection: false,
            ordered: false,
            owner: false,
            identifiableObject: true,
            nameableObject: false,
            embeddedObject: false,
            analyticalObject: false,
            readable: true,
            writable: true,
            unique: false,
            required: false,
            manyToMany: false,
            oneToOne: false,
            manyToOne: false,
            oneToMany: false,
            href: 'https://debug.dhis2.org/dev/api/schemas/user',
            relativeApiEndpoint: '/users',
            apiEndpoint: 'https://debug.dhis2.org/dev/api/users',
            translatable: false,
            gistPreferences: {
                included: 'AUTO',
                transformation: 'AUTO',
            },
            propertyTransformer: true,
        },
        {
            fieldName: 'lastUpdated',
            description: 'The date the object was last updated.',
            simple: true,
            required: false,
            writable: true,
            nameableObject: false,
            klass: 'java.util.Date',
            propertyType: 'DATE',
            oneToOne: false,
            attribute: true,
            owner: true,
            readable: true,
            ordered: false,
            identifiableObject: false,
            manyToMany: false,
            length: 255,
            collection: false,
            embeddedObject: false,
            unique: false,
            name: 'lastUpdated',
            persisted: true,
            manyToOne: false,
        },
        {
            klass: 'org.hisp.dhis.fileresource.FileResource',
            propertyType: 'REFERENCE',
            name: 'fileResource',
            fieldName: 'fileResource',
            persisted: true,
            namespace: 'http://dhis2.org/schema/dxf/2.0',
            attribute: false,
            simple: false,
            collection: false,
            ordered: false,
            owner: true,
            identifiableObject: true,
            nameableObject: false,
            embeddedObject: false,
            analyticalObject: false,
            readable: true,
            writable: true,
            unique: false,
            required: true,
            length: 255,
            cascade: 'none',
            manyToMany: false,
            oneToOne: false,
            manyToOne: true,
            oneToMany: false,
            owningRole: 'org.hisp.dhis.user.User.avatar',
            href: 'https://debug.dhis2.org/dev/api/schemas/fileResource',
            relativeApiEndpoint: '/fileResources',
            apiEndpoint: 'https://debug.dhis2.org/dev/api/fileResources',
            translatable: false,
            gistPreferences: {
                included: 'AUTO',
                transformation: 'AUTO',
            },
            propertyTransformer: false,
        },
        {
            fieldName: 'access',
            simple: false,
            required: false,
            writable: true,
            min: 0,
            nameableObject: false,
            klass: 'org.hisp.dhis.security.acl.Access',
            propertyType: 'COMPLEX',
            oneToOne: false,
            attribute: false,
            owner: false,
            readable: true,
            ordered: false,
            identifiableObject: false,
            max: 1.7976931348623157e308,
            manyToMany: false,
            collection: false,
            embeddedObject: false,
            unique: false,
            name: 'access',
            namespace: 'http://dhis2.org/schema/dxf/2.0',
            persisted: false,
            manyToOne: false,
        },
    ],
};

export default iconSchemaDefinition;
