server/checkintegrity.py
branchstable
changeset 7686 6580b5a0f1cf
parent 7685 902909e5f733
child 7687 4f5ab60e71cc
equal deleted inserted replaced
7685:902909e5f733 7686:6580b5a0f1cf
   281                     rql = 'Any X WHERE NOT X %s Y, X is %s' % (rschema, etype)
   281                     rql = 'Any X WHERE NOT X %s Y, X is %s' % (rschema, etype)
   282                 else:
   282                 else:
   283                     rql = 'Any X WHERE NOT Y %s X, X is %s' % (rschema, etype)
   283                     rql = 'Any X WHERE NOT Y %s X, X is %s' % (rschema, etype)
   284                 for entity in session.execute(rql).entities():
   284                 for entity in session.execute(rql).entities():
   285                     print >> sys.stderr, '%s #%s is missing mandatory %s relation %s' % (
   285                     print >> sys.stderr, '%s #%s is missing mandatory %s relation %s' % (
   286                         entity.__regid__, entity.eid, role, rschema)
   286                         entity.__regid__, entity.eid, role, rschema),
   287                     if fix:
   287                     if fix:
   288                         #if entity.cw_describe()['source']['uri'] == 'system': XXX
   288                         #if entity.cw_describe()['source']['uri'] == 'system': XXX
   289                         entity.cw_delete()
   289                         entity.cw_delete()
   290                     notify_fixed(fix)
   290                     notify_fixed(fix)
   291 
   291 
   302             if rdef.cardinality[0] in '1+':
   302             if rdef.cardinality[0] in '1+':
   303                 rql = 'Any X WHERE X %s NULL, X is %s, X cw_source S, S name "system"' % (
   303                 rql = 'Any X WHERE X %s NULL, X is %s, X cw_source S, S name "system"' % (
   304                     rschema, rdef.subject)
   304                     rschema, rdef.subject)
   305                 for entity in session.execute(rql).entities():
   305                 for entity in session.execute(rql).entities():
   306                     print >> sys.stderr, '%s #%s is missing mandatory attribute %s' % (
   306                     print >> sys.stderr, '%s #%s is missing mandatory attribute %s' % (
   307                         entity.__regid__, entity.eid, rschema)
   307                         entity.__regid__, entity.eid, rschema),
   308                     if fix:
   308                     if fix:
   309                         entity.cw_delete()
   309                         entity.cw_delete()
   310                     notify_fixed(fix)
   310                     notify_fixed(fix)
   311 
   311 
   312 
   312