public static String provideSequence (Table table) {
PrimaryKeyPolicy primaryKeyPolicy = table.getDatabase().getDataModel().getPrimaryKeyPolicy();
if (primaryKeyPolicy==null) {
return "NO LOOK UP for PK";
}
PrimaryKeyPolicyPattern primaryKeyPolicyPattern = primaryKeyPolicy.getFirstPrimaryKeyPolicyPattern();
if (primaryKeyPolicyPattern==null) {
return "NO LOOK UP for PK : no pattern found";
}
if (primaryKeyPolicy.isOneGlobal()) {
return provideSequenceOneGlobal(primaryKeyPolicyPattern);
} else if (primaryKeyPolicy.isOneForEachTable()){
String seq = initSequence(primaryKeyPolicyPattern, table);
if (primaryKeyPolicyPattern.getPrefix()!=null || primaryKeyPolicyPattern.getSuffix()!=null) {
if (primaryKeyPolicyPattern.getPrefix()!=null)
seq = primaryKeyPolicyPattern.getPrefix() + seq;
if (primaryKeyPolicyPattern.getSuffix()!=null)
seq = seq+primaryKeyPolicyPattern.getSuffix();
return seq;
} else
return seq + "_SEQ";
}
else