@Override public Class<? extends IObject> apply(String className) { final int lastDot = className.lastIndexOf('.'); if (lastDot > 0) { className = className.substring(lastDot + 1); } return graphPathBean.getClassForSimpleName(className); } };
for (final String superclassName : model.getSuperclassesOfReflexive(object.className)) { for (final Entry<String, String> forwardLink : model.getLinkedTo(superclassName)) { for (final Entry<String, String> backwardLink : model.getLinkedBy(superclassName)) {
/** * Get the <q>simple</q> non-nested properties for the given class, not linking to other mapped classes. * @param className the name of a class * @return the <q>simple</q> properties of the given class; never {@code null} * @deprecated instead use {@link #getSimpleProperties(String, boolean)} setting {@code isNested} to {@code false} */ @Deprecated public Set<String> getSimpleProperties(String className) { return getSimpleProperties(className, false); }
out.write("---------\n\n"); final SortedMap<String, String> classNames = new TreeMap<String, String>(); for (final String className : model.getAllClasses()) { classNames.put(getSimpleName(className), className); for (final String subclass : model.getDirectSubclassesOf(className)) { superclassOf.add(linkTo(getSimpleName(subclass))); for (final Map.Entry<String, String> linker : model.getLinkedBy(className)) { linkerText.add(linkTo(getSimpleName(linker.getKey()), linker.getValue())); final SortedMap<String, String> declaredBy = new TreeMap<String, String>(); final Map<String, String> valueText = new HashMap<String, String>(); for (final String superclassName : model.getSuperclassesOfReflexive(className)) { for (final Map.Entry<String, String> classAndPropertyNames : model.getLinkedTo(superclassName)) { final String valueClassName = classAndPropertyNames.getKey(); final String propertyName = classAndPropertyNames.getValue(); for (final String propertyName : model.getSimpleProperties(superclassName, true)) { declaredBy.put(propertyName, superclassName); valueText.put(propertyName, reportType(superclassName, propertyName)); final String declarerName = propertyAndDeclarerNames.getValue(); out.write(" | " + propertyName + ": " + valueText.get(propertyName)); switch (model.getPropertyKind(declarerName, propertyName)) { case OPTIONAL: out.write(" (optional)"); out.write(" from " + linkTo(getSimpleName(declarerName)));
final Map<String, Set<Details>> linkedToDetails = new HashMap<String, Set<Details>>(); final Set<String> notNullable = new HashSet<String>(); for (final String superclassName : model.getSuperclassesOfReflexive(object.className)) { for (final Entry<String, String> forwardLink : model.getLinkedTo(superclassName)) { if (model.getPropertyKind(linkProperty.className, linkProperty.propertyName) == PropertyKind.REQUIRED) { notNullable.add(linkProperty.toString()); for (final Entry<String, String> backwardLink : model.getLinkedBy(superclassName)) { if (model.getPropertyKind(linkProperty.className, linkProperty.propertyName) == PropertyKind.REQUIRED) { notNullable.add(linkProperty.toString());
for (final String superclassName : graphPathBean.getSuperclassesOfReflexive(originalClass)) { for (final String property : graphPathBean.getSimpleProperties(superclassName)) { if (!graphPathBean.isPropertyAccessible(superclassName, property)) { continue;
for (final String superclassName : graphPathBean.getSuperclassesOfReflexive(originalClass)) { for (final Entry<String, String> backwardLink : graphPathBean.getLinkedBy(superclassName)) { if (!graphPathBean.isPropertyAccessible(linkingClass, property)) { continue;
for (final String superclassName : graphPathBean.getSuperclassesOfReflexive(originalClass)) { for (final Entry<String, String> forwardLink : graphPathBean.getLinkedTo(superclassName)) { if (graphPathBean.isPropertyAccessible(superclassName, property)) {
for (final String className : graphPathBean.getAllClasses()) { if (graphPathBean.getSubclassesOf(className).isEmpty()) { try { leafClasses.add(Class.forName(className).asSubclass(IObject.class));
for (final String superclassName : model.getSuperclassesOfReflexive(className)) { final Set<Entry<String, String>> forwardLinks = model.getLinkedTo(superclassName); for (final Entry<String, String> forwardLink : forwardLinks) { linkProperties.add(forwardLink.getValue());
/** * Look up the identifier property for the given class. * @param className a class name * @return the identifier property, never {@code null} * @throws Cancel if an identifier property could not be found for the given class */ private String getIdPropertyFor(String className) throws Cancel { String idProperty = classIdProperties.get(className); if (idProperty == null) { final Class<? extends IObject> actualClass = graphPathBean.getClassForSimpleName(className); if (actualClass == null) { final Exception e = new IllegalArgumentException("class " + className + " is unknown"); throw helper.cancel(new ERR(), e, "bad-class"); } idProperty = graphPathBean.getIdentifierProperty(actualClass.getName()); if (idProperty == null) { final Exception e = new IllegalArgumentException("no identifier property is known for class " + className); throw helper.cancel(new ERR(), e, "bad-class"); } classIdProperties.put(className, idProperty); } return idProperty; }
/** * Note a linked object to remove from a linker property's {@link Collection} value. * @param linkerToIdToLinked the map from linker property to linker ID to objects in {@link Collection}s * @param linker the linker object * @param linked the linked object */ private void addRemoval(Map<CP, SetMultimap<Long, Entry<String, Long>>> linkerToIdToLinked, CPI linker, CI linked) { if (model.isPropertyAccessible(linker.className, linker.propertyName)) { SetMultimap<Long, Entry<String, Long>> idMap = linkerToIdToLinked.get(linker.toCP()); if (idMap == null) { idMap = HashMultimap.create(); linkerToIdToLinked.put(linker.toCP(), idMap); } idMap.put(linker.id, Maps.immutableEntry(linked.className, linked.id)); } }
/** * Given a class and a property of that class, determine to which class it links. * @param linkProperty a class and property name * @return the class linked to */ private String getLinkedClass(CP linkProperty) { for (final Entry<String, String> forwardLink : model.getLinkedTo(linkProperty.className)) { if (linkProperty.propertyName.equals(forwardLink.getValue())) { return forwardLink.getKey(); } } return null; }
/** * Given a class and a property linking to that class, determine from which class it is linked. * @param linkProperty a class and property name * @return the linking class */ @SuppressWarnings("unused") private String getLinkerClass(CP linkProperty) { for (final Entry<String, String> backwardLink : model.getLinkedBy(linkProperty.className)) { if (linkProperty.propertyName.equals(backwardLink.getValue())) { return backwardLink.getKey(); } } return null; }
/** * Get the name of this class and of its mapped subclasses. * @param className the name of a class * @return the class and its subclasses, never {@code null} */ public Collection<String> getSubclassesOfReflexive(String className) { final Collection<String> subclasses = getSubclassesOf(className); final Collection<String> subclassesReflexive = new ArrayList<String>(subclasses.size() + 1); subclassesReflexive.add(className); subclassesReflexive.addAll(subclasses); return subclassesReflexive; }
final String idProperty = graphPathBean.getIdentifierProperty(queryClassName); String hql = "SELECT " + idProperty + " FROM " + queryClassName + " WHERE details.owner.id IN (:owners)"; if (acceptableGroupsFrom != null) {
new HashMap<CP, SetMultimap<Long, Entry<String, Long>>>(); for (final CI object : planning.included) { for (final String superclassName : model.getSuperclassesOfReflexive(object.className)) { for (final Entry<String, String> forwardLink : model.getLinkedTo(superclassName)) { final CP linkProperty = new CP(superclassName, forwardLink.getValue()); final boolean isCollection = model.getPropertyKind(linkProperty.className, linkProperty.propertyName) == PropertyKind.COLLECTION; final CPI linkSource = linkProperty.toCPI(object.id); for (final CI linked : planning.forwardLinksCached.get(linkSource)) { for (final Entry<String, String> backwardLink : model.getLinkedBy(superclassName)) { final CP linkProperty = new CP(backwardLink.getKey(), backwardLink.getValue()); final boolean isCollection = model.getPropertyKind(linkProperty.className, linkProperty.propertyName) == PropertyKind.COLLECTION; final CPI linkTarget = linkProperty.toCPI(object.id); for (final CI linker : planning.backwardLinksCached.get(linkTarget)) { for (final String superclassName : model.getSuperclassesOfReflexive(object.className)) { for (final Entry<String, String> backwardLink : model.getLinkedBy(superclassName)) { final CP linkProperty = new CP(backwardLink.getKey(), backwardLink.getValue()); final boolean isCollection = model.getPropertyKind(linkProperty.className, linkProperty.propertyName) == PropertyKind.COLLECTION; final CPI linkTarget = linkProperty.toCPI(object.id); for (final CI linker : planning.backwardLinksCached.get(linkTarget)) { final CP linker = nullCurr.getKey(); if (unnullable.get(linker.className).contains(linker.propertyName) || model.getPropertyKind(linker.className, linker.propertyName) == PropertyKind.REQUIRED) { throw new GraphException("cannot null " + linker);
final boolean propertyIsAccessible = model.isPropertyAccessible(linkProperty.className, linkProperty.propertyName); final SetMultimap<Long, Long> linkerToLinked = HashMultimap.create(); for (final List<Long> idsBatch : Iterables.partition(ids, BATCH_SIZE)) {
final SetMultimap<CP, Long> backwardLinksWanted = HashMultimap.create(); for (final CI inclusionCandidate : toCache) { for (final String inclusionCandidateSuperclassName : model.getSuperclassesOfReflexive(inclusionCandidate.className)) { for (final Entry<String, String> forwardLink : model.getLinkedTo(inclusionCandidateSuperclassName)) { final CP linkProperty = new CP(inclusionCandidateSuperclassName, forwardLink.getValue()); forwardLinksWanted.put(linkProperty, inclusionCandidate.id); for (final Entry<String, String> backwardLink : model.getLinkedBy(inclusionCandidateSuperclassName)) { final CP linkProperty = new CP(backwardLink.getKey(), backwardLink.getValue()); backwardLinksWanted.put(linkProperty, inclusionCandidate.id);
@Override public Class<? extends IObject> apply(String className) { final int lastDot = className.lastIndexOf('.'); if (lastDot > 0) { className = className.substring(lastDot + 1); } return graphPathBean.getClassForSimpleName(className); } };