Revision 8
Added by Matt Wheeler over 14 years ago
Entity.php | ||
---|---|---|
569 | 569 |
" db_table = u'$tabName'\n\n"; |
570 | 570 |
} |
571 | 571 |
|
572 |
#there is a tablename resolution conflict between taxonNames/TaxonNames, taxonConcepts/TaxonConcepts, |
|
573 |
#temporalCoverage/TemporalCoverage in |
|
574 |
#that Django & Postgres store the table names in a case-insensitive way. Need to force the table name |
|
575 |
#to be something different here. |
|
576 |
if($this->tableName == 'taxonNames') { |
|
577 |
$str .= "\n\n class Meta:\n". |
|
578 |
" db_table = u'v_taxonnames_lc'\n\n"; |
|
579 |
} else if($this->tableName == 'TaxonNames') { |
|
580 |
$str .= "\n\n class Meta:\n". |
|
581 |
" db_table = u'v_taxonnames_uc'\n\n"; |
|
582 |
} else if($this->tableName == 'taxonConcepts') { |
|
583 |
$str .= "\n\n class Meta:\n". |
|
584 |
" db_table = u'v_taxonconcepts_lc'\n\n"; |
|
585 |
} else if($this->tableName == 'TaxonConcepts') { |
|
586 |
$str .= "\n\n class Meta:\n". |
|
587 |
" db_table = u'v_taxonconcepts_uc'\n\n"; |
|
588 |
} else if($this->tableName == 'temporalCoverage') { |
|
589 |
$str .= "\n\n class Meta:\n". |
|
590 |
" db_table = u'v_temporalcoverage_lc'\n\n"; |
|
591 |
} else if($this->tableName == 'TemporalCoverage') { |
|
592 |
$str .= "\n\n class Meta:\n". |
|
593 |
" db_table = u'v_temporalcoverage_uc'\n\n"; |
|
594 |
} |
|
595 |
|
|
572 | 596 |
return $str; |
573 | 597 |
} |
574 | 598 |
|
... | ... | |
693 | 717 |
$colDef = $this->references[$colName]; |
694 | 718 |
|
695 | 719 |
if(preg_match("/(ForeignKey\(')([a-zA-Z]*)/",$colDef,$matches) > 0 && |
696 |
preg_match("/Complex one2Many/",$colDef) > 0 && preg_match("/_extend/",$colDef) == 0) { |
|
720 |
preg_match("/Complex one2Many/",$colDef) > 0 && preg_match("/_extend/",$colDef) == 0 && |
|
721 |
preg_match("/_id/",$colName) == 0) { |
|
697 | 722 |
$i += 1; |
698 | 723 |
$def .= " $ifStmt cName == '$colName':\n". |
699 | 724 |
" newEl = $matches[2]().retrieveOrNew(child)\n". |
... | ... | |
837 | 862 |
$colDef = $this->references[$colName]; |
838 | 863 |
|
839 | 864 |
if(preg_match("/(ForeignKey\(')([a-zA-Z]*)/",$colDef,$matches) > 0 && |
840 |
(preg_match("/Complex one2Many/",$colDef) > 0 || preg_match("/_extend/",$colName) > 0)) { |
|
865 |
(preg_match("/Complex one2Many/",$colDef) > 0 || preg_match("/_extend/",$colName) > 0) && |
|
866 |
preg_match("/_id/",$colName) == 0) { |
|
841 | 867 |
if(preg_match("/_extend/",$colName) == 0) { |
842 | 868 |
$def .= " if self.$colName != None:\n". |
843 | 869 |
" newEl = doc.createElement('$colName')\n". |
... | ... | |
855 | 881 |
} |
856 | 882 |
|
857 | 883 |
foreach(array_keys($this->referrers) as $nodeName) { |
858 |
$nodeNameToUse = $nodeName;
|
|
884 |
$nodeNameToUse = $this->referrers[$nodeName];
|
|
859 | 885 |
if($nodeName == 'anyAttribute') { |
860 |
$nodeNameToUse = 'any_attr';
|
|
861 |
$relatedName = $this->tableName . '_' . $nodeNameToUse . '_' . $this->tableName . '_id';
|
|
886 |
$nodeNameToUse = $this->tableName . '_any_attr';
|
|
887 |
$relatedName = $nodeNameToUse . '_' . $this->tableName . '_id'; |
|
862 | 888 |
$def .= " for childRef in self.$relatedName.all():\n". |
863 | 889 |
" newEl = doc.createAttribute('$nodeName')\n". |
864 | 890 |
" myNode.setAttributeNode(childRef.exportVegX(newEl,doc))\n\n"; |
865 | 891 |
} else { |
866 | 892 |
if($nodeName == 'anyNode') { |
867 |
$nodeNameToUse = 'any_nodes';
|
|
893 |
$nodeNameToUse = $this->tableName . '_any_nodes';
|
|
868 | 894 |
} |
869 |
$relatedName = $this->tableName . '_' . $nodeNameToUse . '_' . $this->tableName . '_id';
|
|
895 |
$relatedName = $nodeNameToUse . '_' . $this->tableName . '_id'; |
|
870 | 896 |
$def .= " for childRef in self.$relatedName.all():\n". |
871 | 897 |
" newEl = doc.createElement('$nodeName')\n". |
872 | 898 |
" myNode.appendChild(childRef.exportVegX(newEl,doc))\n\n"; |
... | ... | |
945 | 971 |
$colDef = $this->references[$colName]; |
946 | 972 |
|
947 | 973 |
if(preg_match("/(ForeignKey\(')([a-zA-Z]*)/",$colDef,$matches) > 0 && |
948 |
(preg_match("/Complex one2Many/",$colDef) > 0 || preg_match("/_extend/",$colName) > 0)) { |
|
974 |
(preg_match("/Complex one2Many/",$colDef) > 0 || preg_match("/_extend/",$colName) > 0) && |
|
975 |
preg_match("/_id/",$colName) == 0) { |
|
949 | 976 |
if(preg_match("/_extend/",$colName) == 0) { |
950 | 977 |
$def .= " if '$matches[2]' not in usedObjectsStack:\n". |
951 | 978 |
" usedObjectsStack.append('$matches[2]')\n". |
Also available in: Unified diff
Some bug fixes.
Slight hack in eml-coverage and veg.xsd to get around Django case-insensitivity & VegX entities that only differ by case.
Changed default db relationship to one2many from many2many