ph-dev-tools
Version:
Development Tools for PHibernate
107 lines (98 loc) • 2.4 kB
text/typescript
import {PropertyDocEntry} from "../parser/DocEntry";
/**
* Created by Papa on 4/25/2016.
*/
export interface QBuilder {
build(
...args:any[]
):string;
}
export function getPropertyFieldType( //
propertyDocEntry:PropertyDocEntry //
):string {
switch (propertyDocEntry.primitive) {
case 'boolean':
return 'BOOLEAN';
case 'Date':
return 'DATE';
case 'number':
return 'NUMBER';
case 'string':
return 'STRING';
default:
throw `Unexpected primitive ${propertyDocEntry.primitive}`;
}
}
export function getPropertyJSONOperationInterface( //
propertyDocEntry:PropertyDocEntry //
):string {
switch (propertyDocEntry.primitive) {
case 'boolean':
return 'JSONBooleanOperation';
case 'Date':
return 'JSONDateOperation';
case 'number':
return 'JSONNumberOperation';
case 'string':
return 'JSONStringOperation';
default:
throw `Unexpected primitive ${propertyDocEntry.primitive}`;
}
}
export function getPropertyTypedOperationInterface( //
propertyDocEntry:PropertyDocEntry //
):string {
switch (propertyDocEntry.primitive) {
case 'boolean':
return 'IBooleanOperation';
case 'Date':
return 'IDateOperation';
case 'number':
return 'INumberOperation';
case 'string':
return 'IStringOperation';
default:
throw `Unexpected primitive ${propertyDocEntry.primitive}`;
}
}
export function getPropertyFieldInterface( //
propertyDocEntry:PropertyDocEntry //
):string {
switch (propertyDocEntry.primitive) {
case 'boolean':
return 'IQBooleanField';
case 'Date':
return 'IQDateField';
case 'number':
return 'IQNumberField';
case 'string':
return 'IQStringField';
default:
throw `Unexpected primitive ${propertyDocEntry.primitive}`;
}
}
export function getPropertyFieldClass( //
propertyDocEntry:PropertyDocEntry //
):string {
switch (propertyDocEntry.primitive) {
case 'boolean':
return 'QBooleanField';
case 'Date':
return 'QDateField';
case 'number':
return 'QNumberField';
case 'string':
return 'QStringField';
default:
throw `Unexpected primitive ${propertyDocEntry.primitive}`;
}
}
export function getRelationFieldType( //
entityProperty:PropertyDocEntry //
):string {
if(entityProperty.isArray) {
return 'ONE_TO_MANY';
} else {
return 'MANY_TO_ONE';
}
}