return true;
}

var field = 'StartDate';
var set = FeatureSetByName($datastore, 'UICAuthorization', [field], false);

var fk = $feature.authorization_fk;

// TODO: One day there will be a relationship traversal operation
var authorizations = filter(set, 'GUID=@fk');

if (isempty(authorizations)) {
    return true;
}

var authorization = first(authorizations);

return iif ($feature.AuthorizationActionDate < authorization.startdate, {
    'errorMessage': 'AuthorizationActionDate must be no earlier than the StartDate of the associated Authorization record'
}, true);'''

TABLE = 'UICAuthorizationAction'

GUID = Constant('Authorization Action Guid', 'GUID', 'AuthorizationAction.Guid', 'GUID()')

TYPE = Constraint('Authorization Action Type', 'AuthorizationAction.AuthorizationActionType', common.constrain_to_domain('AuthorizationActionType'))
TYPE.triggers = [config.triggers.insert, config.triggers.update]

ACTION_DATE = Constraint('Authorization Action Date', 'AuthorizationAction.AuthorizationActionDate', constrain_to_parent_start_date)
ACTION_DATE.triggers = [config.triggers.insert, config.triggers.update]
Beispiel #2
0
from services.loader import load_rule_for

from . import common

TABLE = 'UICAuthorization'
FOLDER = 'authorization'

guid_constant = Constant('Authorization Guid', 'GUID', 'GUID()')

id_calculation = Calculation('Authorization Id', 'AuthorizationID',
                             load_rule_for(FOLDER, 'idCalculation'))
id_calculation.triggers = [config.triggers.insert, config.triggers.update]
id_calculation.editable = config.editable.no

start_date_constraint_update = Constraint(
    'Start Date', 'StartDate.update',
    common.constrain_to_required('startdate'))
start_date_constraint_update.triggers = [config.triggers.update]

type_domain_constraint = Constraint(
    'Authorization Type', 'AuthorizationType',
    common.constrain_to_domain('AuthorizationType',
                               allow_null=True,
                               domain='UICAuthorizeTypeDomain'))

type_domain_constraint_update = Constraint(
    'Authorization Type', 'AuthorizationType.update',
    common.constrain_to_domain('AuthorizationType',
                               allow_null=False,
                               domain='UICAuthorizeTypeDomain'))
type_domain_constraint_update.triggers = [config.triggers.update]
Beispiel #3
0
    querystring += "'" + relation.contactguid + "',";
}

querystring = left(querystring, count(querystring) - 1) + ')';

var contacts = filter(contactSet, querystring);

for (var contact in contacts) {
    if (indexof([1, 3], contact.contacttype) > -1) {
        return true;
    }
}

return {
    'errorMessage': 'There is no owner or operator contact type for this facility'
};
'''

TABLE = 'UICContact'

GUID = Constant('Contact Guid', 'GUID', 'Contact.Guid', 'GUID()')

TYPE = Constraint('Contact Type', 'Contact.Type', common.constrain_to_domain('ContactType'))
TYPE.triggers = [config.triggers.insert, config.triggers.update]

STATE = Constraint('Mail State', 'Contact.MailState', common.constrain_to_domain('ContactMailState'))
STATE.triggers = [config.triggers.insert, config.triggers.update]

CONTACT_TYPE = Constraint('Owner Operator', 'Contact.OwnerType', constrain_contact_type)
CONTACT_TYPE.triggers = [config.triggers.insert, config.triggers.update]
'''

from config import config
from models.ruletypes import Constant, Constraint
from services.loader import load_rule_for

from . import common

TABLE = 'UICEnforcement'
FOLDER = 'enforcement'

guid_constant = Constant('Enforcement Guid', 'GUID', 'GUID()')

type_constraint = Constraint(
    'Enforcement Type', 'EnforcementType',
    common.constrain_to_domain('EnforcementType',
                               allow_null=True,
                               domain='UICEnforcementTypeDomain'))

type_constraint_update = Constraint(
    'Enforcement Type', 'EnforcementType.update',
    common.constrain_to_domain('EnforcementType',
                               allow_null=False,
                               domain='UICEnforcementTypeDomain'))
type_constraint_update.triggers = [config.triggers.update]

date_constraint = Constraint('Enforcement Date', 'EnforcementDate',
                             load_rule_for(FOLDER, 'dateConstraint'))
date_constraint.triggers = [config.triggers.insert, config.triggers.update]

comment_constraint = Constraint('Comment', 'Comment',
TABLE = 'UICWell'
FOLDER = 'well'

guid_constant = Constant('Well Guid', 'GUID', 'Guid()')

id_calculation = Calculation('Well Id', 'WellId',
                             load_rule_for(FOLDER, 'idCalculation'))
id_calculation.triggers = [config.triggers.insert, config.triggers.update]
id_calculation.editabe = config.editable.no

facility_calculation = Calculation(
    'Facility Fk', 'Facility_Fk', load_rule_for(FOLDER, 'facilityCalculation'))

class_constraint = Constraint(
    'Well Class', 'Class',
    common.constrain_to_domain('WellClass',
                               allow_null=True,
                               domain='UICWellClassDomain'))

class_constraint_update = Constraint(
    'Well Class', 'Class.update',
    common.constrain_to_domain('WellClass',
                               allow_null=False,
                               domain='UICWellClassDomain'))
class_constraint_update.triggers = [config.triggers.update]

subclass_constraint = Constraint('Well Subclass', 'Subclass',
                                 load_rule_for(FOLDER, 'subClassConstraint'))
subclass_constraint.triggers = [config.triggers.insert, config.triggers.update]

highpriority_constraint = Constraint(
Beispiel #6
0
    return true;
}

return iif (isempty(domainname($feature, 'wellswpz', $feature.wellswpz)), {
    'errorMessage': 'Acceptable values for SWPZ types are Y, S, N, U. Input: ' + $feature.wellswpz
}, true);'''

GUID = Constant('Well Guid', 'GUID', 'Well.Guid', 'Guid()')

ID = Calculation('Well Id', 'WellId', 'Well.Id', create_id)
ID.triggers = [config.triggers.insert, config.triggers.update]

FACILITY = Calculation('Facility Fk', 'Facility_Fk', 'Well.Facility_FK', extract_facility)
AUTHORIZATION = None

CLASS = Constraint('Well Class', 'Well.Class', constrain_wellclass)
CLASS.triggers = [config.triggers.insert, config.triggers.update]

SUBCLASS = Constraint('Well Subclass', 'Well.Subclass', constrain_subclass)
SUBCLASS.triggers = [config.triggers.insert, config.triggers.update]

# TODO: rasters are not supported
# ELEVATION = Calculation('Well Elevation', 'SurfaceElevation', 'Well.SurfaceElevation', extract_elevation)

HIGHPRIORITY = Constraint('High Priority', 'Well.HighPriority', constrain_highpriority)
HIGHPRIORITY.triggers = [config.triggers.insert, config.triggers.update]

INJECTION_AQUIFER_EXEMPT = Constraint('Injection Aquifer Exempt', 'Well.InjectionAquiferExempt', constrain_yes_no_unknown.format('InjectionAquiferExempt'))
INJECTION_AQUIFER_EXEMPT.triggers = [config.triggers.update]

NO_MIGRATION_PET_STATUS = Constraint('No Migration Pet Status', 'Well.NoMigrationPetStatus', constrain_class_one_wells)
Beispiel #7
0
for (var key in keys) {
    if (!haskey($feature, keys[key])) {
        return null;
    }
}

return 'UTU' + right($feature.countyfips, 2) + 'F' + upper(mid($feature.guid, 29, 8))'''

constrain_zip = '''if (!haskey($feature, 'facilityzip') || isempty($feature.facilityzip)) {
    return true;
}

return iif (isempty(domainname($feature, 'facilityzip', $feature.facilityzip)), {
    'errorMessage': 'Zip code is not in the domain. Input: ' + $feature.facilityzip
}, true);'''

GUID = Constant('Facility Guid', 'GUID', 'Facility.Guid', 'Guid()')
FIPS = Calculation('County Fips', 'CountyFIPS', 'Facility.FIPS', extract_fips)
ID = Calculation('Facility Id', 'FacilityID', 'Facility.Id', create_id)
CITY = Calculation('Facility City', 'FacilityCity', 'Facility.City',
                   extract_city)
ZIP = Calculation('Facility Zip', 'FacilityZIP', 'Facility.ZipCode',
                  extract_zip)

ZIP_DOMAIN = Constraint('Facility Zip', 'Facility.ZipCode', constrain_zip)
ZIP_DOMAIN.triggers = [config.triggers.insert, config.triggers.update]

FIPS_DOMAIN = Constraint('County Fips', 'Facility.FIPS', constrain_domain)
FIPS_DOMAIN.triggers = [config.triggers.insert, config.triggers.update]
Beispiel #8
0
#!/usr/bin/env python
# * coding: utf8 *
'''
mit.py
A module that has the UICMIT rules
'''

from . import common
from config import config
from models.ruletypes import Constant, Constraint

TABLE = 'UICMIT'

GUID = Constant('MIT Guid', 'GUID', 'MIT.Guid', 'GUID()')

TYPE = Constraint('MIT Type', 'MIT.Type',
                  common.constrain_to_domain('MITType'))
TYPE.triggers = [config.triggers.insert, config.triggers.update]

ACTION = Constraint('MIT Remediation Action', 'MIT.Remediation Action',
                    common.constrain_to_domain('MITRemediationAction'))
ACTION.triggers = [config.triggers.insert, config.triggers.update]
Beispiel #9
0
enforcement.py
A module that has the UICEnforcement rules
'''

from . import common
from config import config
from models.ruletypes import Constant, Constraint

constrain_other_comment = '''if (!haskey($feature, 'EnforcementType') || !haskey($feature, 'comments')) {
    return true;
}

if (isempty($feature.EnforcementType) || lower(domaincode($feature, 'EnforcementType', $feature.enforcementtype)) != 'otr') {
    return true;
}

return iif (isempty($feature.comments), {
    'errorMessage': 'When Enforcement Type is OTR, a comment is required'
}, true);'''

TABLE = 'UICEnforcement'

GUID = Constant('Enforcement Guid', 'GUID', 'Enforcement.Guid', 'GUID()')

TYPE = Constraint('Enforcement Type', 'Enforcement.EnforcementType',
                  common.constrain_to_domain('EnforcementType'))
TYPE.triggers = [config.triggers.insert, config.triggers.update]

COMMENT = Constraint('Comment', 'Enforcement.Comment', constrain_other_comment)
COMMENT.triggers = [config.triggers.insert, config.triggers.update]
'''

from config import config
from models.ruletypes import Constant, Constraint
from services.loader import load_rule_for

from . import common

TABLE = 'UICAuthorizationAction'
FOLDER = 'authorizationAction'

guid_constant = Constant('Authorization Action Guid', 'GUID', 'GUID()')

action_type_domain_constraint = Constraint(
    'Authorization Action Type', 'AuthorizationActionType',
    common.constrain_to_domain('AuthorizationActionType',
                               allow_null=True,
                               domain='UICAuthorizeActionTypeDomain'))

action_type_domain_constraint_update = Constraint(
    'Authorization Action Type', 'AuthorizationActionType.update',
    common.constrain_to_domain('AuthorizationActionType',
                               allow_null=False,
                               domain='UICAuthorizeActionTypeDomain'))
action_type_domain_constraint_update.triggers = [config.triggers.update]

action_date_constraint = Constraint(
    'Authorization Action Date',
    'AuthorizationActionDate and AuthorizationActionType',
    load_rule_for(FOLDER, 'dateConstraint'))
action_date_constraint.triggers = [
Beispiel #11
0
fips_calculation = Calculation('County Fips', 'CountyFIPS',
                               load_rule_for(FOLDER, 'fipsCalculation'))

id_calculation = Calculation('Facility Id', 'FacilityID',
                             load_rule_for(FOLDER, 'idCalculation'))
id_calculation.triggers = [config.triggers.insert, config.triggers.update]
id_calculation.editable = config.editable.no

city_calculation = Calculation('Facility City', 'FacilityCity',
                               load_rule_for(FOLDER, 'cityCalculation'))

zip_calculation = Calculation('Facility Zip', 'FacilityZIP',
                              load_rule_for(FOLDER, 'zipCalculation'))

fips_domain_constraint = Constraint('County Fips', 'FIPS',
                                    load_rule_for(FOLDER, 'fipsConstraint'))
fips_domain_constraint.triggers = [
    config.triggers.insert, config.triggers.update
]

zip_domain_calculation = Constraint('Facility Zip', 'ZipCode',
                                    load_rule_for(FOLDER, 'zipConstraint'))
zip_domain_calculation.triggers = [
    config.triggers.insert, config.triggers.update
]

name_constraint_update = Constraint(
    'Facility name', 'FacilityName.update',
    common.constrain_to_required('FacilityName'))
name_constraint_update.triggers = [config.triggers.update]
'''

from . import common
from config import config
from models.ruletypes import Constant, Constraint

constrain_date = '''if (!haskey($feature, 'OperatingStatusDate') || isempty($feature.OperatingStatusDate)) {
    return true;
}

if (date('1901-01-01') > $feature.operatingstatusdate || $feature.operatingstatusdate > date()) {
    return {
        'errorMessage': 'Operating status date needs to be between todays date and 1/1/1901'
    };
}

return true;'''

TABLE = 'UICWellOperatingStatus'

GUID = Constant('Well operating status Guid', 'GUID',
                'WellOperatingStatus.Guid', 'GUID()')

TYPE = Constraint('Operating Status Type', 'OperatingStatus.Type',
                  common.constrain_to_domain('OperatingStatusType'))
TYPE.triggers = [config.triggers.insert, config.triggers.update]

DATE = Constraint('Operating Status Date', 'OperatingStatus.Date',
                  constrain_date)
DATE.triggers = [config.triggers.insert, config.triggers.update]
Beispiel #13
0
    }

    var facility = first(facilities);

    if (lower(code) == 'no') {
        code = 'UA';
    }

    return 'UTU' + right(facility[field], 2) + code + upper(mid($feature.guid, 29, 7));
}

var missingRequiredItems = isempty($feature.authorizationtype) || isempty($feature.facility_fk);

return iif(missingRequiredItems, null, generateId($feature.authorizationtype, $feature.facility_fk))
'''

TABLE = 'UICAuthorization'

GUID = Constant('Authorization Guid', 'GUID', 'Authorization.Guid', 'GUID()')
#: UTUCCAAXXXXXXX
#: CC = 2 digit CountyFIPS code of associated Facility
#: AA = 2 digit AuthorizationType code (https://github.com/agrc/uic-attribute-rules/issues/5)
ID = Calculation('Authorization Id', 'AuthorizationID', 'Authorization.Id', create_id)
ID.triggers = [config.triggers.insert, config.triggers.update]

TYPE = Constraint('Authorization Type', 'Authorization.AuthorizationType', common.constrain_to_domain('AuthorizationType'))
TYPE.triggers = [config.triggers.insert, config.triggers.update]

SECTOR_TYPE = Constraint('Owner Sector Type', 'Authorization.OwnerSectorType', common.constrain_to_domain('OwnerSectorType'))
SECTOR_TYPE.triggers = [config.triggers.insert, config.triggers.update]
Beispiel #14
0
A module that has the UICContact rules
'''

from config import config
from models.ruletypes import Constant, Constraint
from services.loader import load_rule_for

from . import common

TABLE = 'UICContact'
FOLDER = 'contact'

guid_constant = Constant('Contact Guid', 'GUID', 'GUID()')

name_constraint_update = Constraint(
    'Contact Name', 'ContactName.update',
    common.constrain_to_required('ContactName'))
name_constraint_update.triggers = [config.triggers.update]

phone_constraint_update = Constraint(
    'Contact phone', 'ContacPhone.update',
    common.constrain_to_required('ContactPhone'))
phone_constraint_update.triggers = [config.triggers.update]

organization_constraint_update = Constraint(
    'Contact Organization', 'ContactOrganization.update',
    common.constrain_to_required('ContactOrganization'))
organization_constraint_update.triggers = [config.triggers.update]

address_constraint_update = Constraint(
    'Contact mailing address', 'ContactMailAddress.update',
Beispiel #15
0
}, true);'''

constrain_ca_date = '''if (!haskey($feature, 'artpen_cadate') || !haskey($feature, 'ident4ca')) {
    return true;
}

if (isempty($feature.ident4ca)) {
    return true;
}

return iif (isempty($feature.artpen_cadate), {
    'errorMessage': 'ArtPen_CADate cannot be empty when Ident4CA has a value'
}, true);'''

GUID = Constant('Art Pen Guid', 'GUID', 'ArtPen.Guid', 'GUID()')

WELL_TYPE = Constraint('Well Type', 'ArtPen.WellType',
                       common.constrain_to_domain('artpen_wellname'))
WELL_TYPE.triggers = [config.triggers.insert, config.triggers.update]

CA_DOMAIN = Constraint('CA', 'ArtPen.Ident4CA',
                       common.constrain_to_domain('ident4ca'))
CA_DOMAIN.triggers = [config.triggers.insert, config.triggers.update]

CA_TYPE_DOMAIN = Constraint('CA Type', 'ArtPen.ArtPen_CAType',
                            constrain_ca_type)
CA_TYPE_DOMAIN.triggers = [config.triggers.insert, config.triggers.update]

CA_DATE = Constraint('CA Date', 'ArtPen.ArtPen_CADate', constrain_ca_date)
CA_DATE.triggers = [config.triggers.insert, config.triggers.update]
Beispiel #16
0
A module that has the UICWellOperatingStatus rules
'''

from config import config
from models.ruletypes import Constant, Constraint
from services.loader import load_rule_for

from . import common

TABLE = 'UICWellOperatingStatus'
FOLDER = 'operatingStatus'

guid_constant = Constant('Well operating status Guid', 'GUID', 'GUID()')

type_domain_constraint = Constraint(
    'Operating Status Type', 'OperatingStatusType', common.constrain_to_domain('OperatingStatusType', allow_null=False, domain='UICOperatingStatusTypeDomain')
)
type_domain_constraint.triggers = [config.triggers.update]

date_constraint = Constraint('Operating Status Date', 'OperatingStatusDate', load_rule_for(FOLDER, 'dateConstraint'))
date_constraint.triggers = [config.triggers.insert, config.triggers.update]

type_constraint = Constraint('Operating status type needs a date', 'OperatingStatusType date requirement', load_rule_for(FOLDER, 'typeConstraint'))
type_constraint.triggers = [config.triggers.insert, config.triggers.update]

RULES = [
    guid_constant,
    type_domain_constraint,
    date_constraint,
    type_constraint,
]
Beispiel #17
0
art_pen.py
A module that has the UICArtPen rules
'''

from config import config
from models.ruletypes import Constant, Constraint
from services.loader import load_rule_for

from . import common

TABLE = 'UICArtPen'
FOLDER = 'artPen'

guid_constraint = Constant('Art Pen Guid', 'GUID', 'GUID()')

name_constraint = Constraint('Art Pen Well Name', 'ArtPen_WellName',
                             common.constrain_to_required('ArtPen_WellName'))
name_constraint.triggers = [config.triggers.update]

well_type_constraint = Constraint(
    'Art Pen Well Type', 'ArtPen_WellType',
    common.constrain_to_domain('ArtPen_WellType',
                               allow_null=True,
                               domain='UICArtPenWellType'))

well_type_constraint_update = Constraint(
    'Art Pen Well Type', 'ArtPen_WellType.update',
    common.constrain_to_domain('ArtPen_WellType',
                               allow_null=False,
                               domain='UICArtPenWellType'))
well_type_constraint_update.triggers = [config.triggers.update]
'''
correction.py
A module that has the UICCorrection rules
'''

from . import common
from config import config
from models.ruletypes import Constant, Constraint

TABLE = 'UICCorrection'

constrain_other_comment = '''if (!haskey($feature, 'correctiveaction') || !haskey($feature, 'comments')) {
    return true;
}

if (isempty($feature.correctiveaction) || lower(domaincode($feature, 'correctiveaction', $feature.correctiveaction)) != 'ot') {
    return true;
}

return iif (isempty($feature.comments), {
    'errorMessage': 'When Corrective action is OT, a comment is required'
}, true);'''

GUID = Constant('Correction Guid', 'GUID', 'Correction.Guid', 'GUID()')

TYPE = Constraint('Corrective Action', 'Correction.CorrectiveAction', common.constrain_to_domain('CorrectiveAction'))
TYPE.triggers = [config.triggers.insert, config.triggers.update]

COMMENT = Constraint('Comment', 'Correction.Comment', constrain_other_comment)
COMMENT.triggers = [config.triggers.insert, config.triggers.update]
'''

from config import config
from models.ruletypes import Constant, Constraint
from services.loader import load_rule_for

from . import common

TABLE = 'UICInspection'
FOLDER = 'inspection'

guid_constant = Constant('Inspection Guid', 'GUID', 'GUID()')

type_domain_constraint = Constraint(
    'Inspection Type', 'InspectionType.domain',
    common.constrain_to_domain('InspectionType',
                               allow_null=True,
                               domain='UICInspectionTypeDomain'))

type_domain_constraint_update = Constraint(
    'Inspection Type', 'InspectionType.update',
    common.constrain_to_domain('InspectionType',
                               allow_null=False,
                               domain='UICInspectionTypeDomain'))
type_domain_constraint_update.triggers = [config.triggers.update]

assistance_domain_constraint = Constraint(
    'Inspection Assistance', 'InspectionAssistance',
    common.constrain_to_domain('InspectionAssistance',
                               allow_null=True,
                               domain='UICComplianceAssistanceDomain'))
Beispiel #20
0
'''

from config import config
from models.ruletypes import Constant, Constraint
from services.loader import load_rule_for

from . import common

TABLE = 'UICMIT'
FOLDER = 'mit'

guid_constant = Constant('MIT Guid', 'GUID', 'GUID()')

type_domain_constraint = Constraint(
    'MIT type', 'Type',
    common.constrain_to_domain('MITType',
                               allow_null=False,
                               domain='UICMITTypeDomain'))
type_domain_constraint.triggers = [config.triggers.update]

date_constraint_update = Constraint('MIT date', 'MITDate.update',
                                    common.constrain_to_required('MITDate'))
date_constraint_update.triggers = [config.triggers.update]

result_constraint_update = Constraint(
    'MIT result', 'MITResult.update',
    common.constrain_to_required('MITResult'))
result_constraint_update.triggers = [config.triggers.update]

type_constraint = Constraint('MIT Date and Type', 'MITDate',
                             load_rule_for(FOLDER, 'typeConstraint'))
var correctionset = featuresetbyname($datastore, 'uiccorrection', ['inspection_fk'], false);

var pk = $feature.guid;
var corrections = filter(correctionset, 'inspection_fk=@pk');

return iif (isempty(corrections), {
    'errorMessage': "If InspectionDeficiency is anything other than 'No Deficiency' or 'Deficiency Not Observed'" +
                    'there must be a Correction record associated with the Inspection record.'
}, true);'''

TABLE = 'UICInspection'

GUID = Constant('Inspection Guid', 'GUID', 'Inspection.Guid', 'GUID()')

TYPE_DOMAIN = Constraint('Inspection Type', 'Inspection.Type', common.constrain_to_domain('InspectionType'))
TYPE_DOMAIN.triggers = [config.triggers.insert, config.triggers.update]

ASSISTANCE_DOMAIN = Constraint('Inspection Assistance', 'Inspection.Assistance', common.constrain_to_domain('InspectionAssistance'))
ASSISTANCE_DOMAIN.triggers = [config.triggers.insert, config.triggers.update]

DEFICIENCY_DOMAIN = Constraint('Inspection Deficiency', 'Inspection.Deficiency', common.constrain_to_domain('InspectionDeficiency'))
DEFICIENCY_DOMAIN.triggers = [config.triggers.insert, config.triggers.update]

FOREIGN_KEY = Constraint('One parent relation', 'FacilityFk.WellFk', constrain_to_one_parent)
FOREIGN_KEY.triggers = [config.triggers.insert, config.triggers.update]

FACILITY_ONLY = Constraint('NW for facility only', 'FacilityOnly.InspectionType', constrain_to_facility)
FACILITY_ONLY.triggers = [config.triggers.insert, config.triggers.update]

INSPECTION_DATE = Constraint('Well operating status date', 'Inspection.InspectionDate', constrain_inspection_date)
'''

from config import config
from models.ruletypes import Calculation, Constant, Constraint
from services.loader import load_rule_for

from . import common

TABLE = 'UICViolation'
FOLDER = 'violation'

guid_constant = Constant('Violation Guid', 'GUID', 'GUID()')

type_domain_constraint = Constraint(
    'Violation Type', 'ViolationType',
    common.constrain_to_domain('ViolationType',
                               allow_null=True,
                               domain='UICViolationTypeDomain'))

type_domain_constraint_update = Constraint(
    'Violation Type', 'ViolationType.update',
    common.constrain_to_domain('ViolationType',
                               allow_null=False,
                               domain='UICViolationTypeDomain'))
type_domain_constraint_update.triggers = [config.triggers.update]

contamination_domain_constraint = Constraint(
    'Contamination', 'USDWContamination.domain',
    common.constrain_to_domain('USDWContamination',
                               allow_null=True,
                               domain='UICYesNoUnknownDomain'))
Beispiel #23
0
set_yes_if_yes = '''if (!haskey($feature, 'USDWContamination') || isempty($feature.USDWContamination)) {
    return;
}

if (lower(domainname($feature, 'USDWContamination')) != 'yes') {
    return;
}

return 'Y';
'''

TABLE = 'UICViolation'

GUID = Constant('Violation Guid', 'GUID', 'Violation.Guid', 'GUID()')

TYPE = Constraint('Violation Type', 'Violation.Type', common.constrain_to_domain('ViolationType'))
TYPE.triggers = [config.triggers.insert, config.triggers.update]

CONTAMINATION = Constraint('Contamination', 'Violation.Contamination', common.constrain_to_domain('USDWContamination'))
CONTAMINATION.triggers = [config.triggers.insert, config.triggers.update]

CONTAMINATION_CALC = Calculation('Significant Non Compliance', 'SignificantNonCompliance', 'Violation.SignificantNonCompliance', set_yes_if_yes)
CONTAMINATION_CALC.triggers = [config.triggers.insert, config.triggers.update]

ENDANGER = Constraint('Endanger', 'Violation.Endanger', common.constrain_to_domain('Endanger'))
ENDANGER.triggers = [config.triggers.insert, config.triggers.update]

NONCOMPLIANCE = Constraint('SignificantNonCompliance', 'Violation.SignificantNonCompliance', common.constrain_to_domain('SignificantNonCompliance'))
NONCOMPLIANCE.triggers = [config.triggers.insert, config.triggers.update]

COMMENT = Constraint('Comments', 'Violation.Comments', constrain_other_comment)