private static String getTrackName(ClassDescriptor cd) { return cd.getUnqualifiedName(); }
/** * Creates a table name for a class descriptor * * @param cld ClassDescriptor * @return a valid table name */ public static String getTableName(ClassDescriptor cld) { return generateSqlCompatibleName(cld.getUnqualifiedName()); }
/** * Creates a table name for a class descriptor * * @param cld ClassDescriptor * @return a valid table name */ public static String getTableName(ClassDescriptor cld) { return generateSqlCompatibleName(cld.getUnqualifiedName()); }
/** * Returns a representation of the Path as a String, with no class constraint markers. eg. * "Department.employees.seniority" * @return a String version of the Path */ public String toStringNoConstraints() { StringBuffer sb = new StringBuffer(); for (int i = 0; i < elements.size(); i++) { sb.append(outers.get(i).booleanValue() ? ":" : "."); sb.append(elements.get(i)); } return getStartClassDescriptor().getUnqualifiedName() + sb.toString(); }
/** * Returns a representation of the Path as a String, with no class constraint markers. eg. * "Department.employees.seniority" * @return a String version of the Path */ public String toStringNoConstraints() { StringBuffer sb = new StringBuffer(); for (int i = 0; i < elements.size(); i++) { sb.append(outers.get(i).booleanValue() ? ":" : "."); sb.append(elements.get(i)); } return getStartClassDescriptor().getUnqualifiedName() + sb.toString(); }
/** * Generate the SQL for removing a default constraint on the class column. * * @param cd * The ClassDescriptor for the affected table * @return SQL for removing the table constraint. */ private static String getRemoveDefaultClassConstraint(final ClassDescriptor cd) { String tableName = getDBName(cd.getUnqualifiedName()); return "ALTER TABLE " + tableName + " ALTER COLUMN class DROP NOT NULL;\n" + "ALTER TABLE " + tableName + " ALTER COLUMN class DROP DEFAULT;\n" + "ALTER TABLE " + tableName + " ALTER COLUMN id DROP DEFAULT;\n"; }
/** * Generate the SQL for removing a default constraint on the class column. * * @param cd * The ClassDescriptor for the affected table * @return SQL for removing the table constraint. */ private static String getRemoveDefaultClassConstraint(final ClassDescriptor cd) { String tableName = getDBName(cd.getUnqualifiedName()); return "ALTER TABLE " + tableName + " ALTER COLUMN class DROP NOT NULL;\n" + "ALTER TABLE " + tableName + " ALTER COLUMN class DROP DEFAULT;\n" + "ALTER TABLE " + tableName + " ALTER COLUMN id DROP DEFAULT;\n"; }
private Vector<ClassAttributes> getClassAttributes(Model model, Class<?> baseClass) { Vector<ClassAttributes> attributes = decomposedClassesCache.get(baseClass); if (attributes == null) { LOG.info("decomposedClassesCache: No entry for " + baseClass + ", adding..."); attributes = new Vector<ClassAttributes>(); for (Class<?> cls : Util.decomposeClass(baseClass)) { ClassDescriptor cld = model.getClassDescriptorByName(cls.getName()); attributes.add(new ClassAttributes(cld.getUnqualifiedName(), cld .getAllAttributeDescriptors())); } decomposedClassesCache.put(baseClass, attributes); } return attributes; }
/** * Generate the SQL for adding a default constraint on the class column. * * @param cd * The ClassDescriptor for the affected table * @return SQL for adding the table constraint. */ private static String getAddDefaultClassConstraint(final ClassDescriptor cd) { String tableName = getDBName(cd.getUnqualifiedName()); return "ALTER TABLE " + tableName + " ALTER COLUMN class SET NOT NULL;\n" + "ALTER TABLE " + tableName + " ALTER COLUMN class SET DEFAULT '" + cd.getName() + "';\n" + "ALTER TABLE " + tableName + " ALTER COLUMN id SET DEFAULT nextval('im_post_build_insert_serial');\n"; }
/** * Generate the SQL for adding a default constraint on the class column. * * @param cd * The ClassDescriptor for the affected table * @return SQL for adding the table constraint. */ private static String getAddDefaultClassConstraint(final ClassDescriptor cd) { String tableName = getDBName(cd.getUnqualifiedName()); return "ALTER TABLE " + tableName + " ALTER COLUMN class SET NOT NULL;\n" + "ALTER TABLE " + tableName + " ALTER COLUMN class SET DEFAULT '" + cd.getName() + "';\n" + "ALTER TABLE " + tableName + " ALTER COLUMN id SET DEFAULT nextval('im_post_build_insert_serial');\n"; }
private SolrInputDocument createDocument(InterMineObject object, ClassDescriptor classDescriptor) { SolrInputDocument doc = new SolrInputDocument(); // id has to be stored so we can fetch the actual objects for the // results doc.addField("id", object.getId().toString()); // special case for faceting doc.addField("Category", classDescriptor.getUnqualifiedName()); addToDocument(doc, "classname", classDescriptor.getUnqualifiedName(), false); addObjectToDocument(object, classDescriptor, doc); return doc; }
private SolrInputDocument createDocument(InterMineObject object, ClassDescriptor classDescriptor) { SolrInputDocument doc = new SolrInputDocument(); // id has to be stored so we can fetch the actual objects for the // results doc.addField("id", object.getId().toString()); // special case for faceting doc.addField("Category", classDescriptor.getUnqualifiedName()); addToDocument(doc, "classname", classDescriptor.getUnqualifiedName(), false); addObjectToDocument(object, classDescriptor, doc); return doc; }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findSumType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findSumType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findIntersectionType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findSumType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findIntersectionType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public String getNewBagType() throws IncompatibleTypes { try { return DescriptorUtils.findSumType(getClasses()).getUnqualifiedName(); } catch (MetaDataException e) { throw new IncompatibleTypes(e); } }
@Override public Void visitRight(SubTable b) { System.out.printf(spacer + "%d %s\n", b.getRows().size(), b.getJoinPath()); System.out.println(spacer + " " + b.getColumns()); int c = 0; for (List<Either<ResultCell, SubTable>> row: b.getRows()) { System.out.printf(spacer + " %s %d\n", b.getJoinPath().getLastClassDescriptor().getUnqualifiedName(), c++); for (Either<ResultCell, SubTable> item: row) { item.accept(new IndentingPrinter(indent, depth + 1)); } } return null; }
@Test public void testSingleMember() throws MetaDataException { withClass("Employee"); String common = DescriptorUtils.findSumType(classes).getUnqualifiedName(); assertEquals(common, "Employee"); }