/** * If for some reason cardinalities of keys are different, we report it. * * @param leftKeys the left hand key * @param kjvKeys the kjv qualified key */ private void reportCardinalityError(final VerseKey leftKeys, final VerseKey kjvKeys) { // TODO (CJB): change this to a neater exception // then something went wrong, as we have remaining verses throw new LucidRuntimeException(String.format("%s has a cardinality of %s whilst %s has a cardinality of %s.", leftKeys, Integer.toString(leftKeys.getCardinality()), kjvKeys, Integer.toString(kjvKeys.getCardinality()))); }
/** * Adds the data into the reverse mappings. Caters for 1-2-1 and 1-2-Many mappings * * @param leftHand the reference of the left hand reference * @param kjvHand the kjv reference/key, qualified with the part */ private void addReverse1ToManyMappings(final Verse leftHand, final QualifiedKey kjvHand) { //add the reverse mapping, for 1-1 mappings if (kjvHand.getAbsentType() == QualifiedKey.Qualifier.ABSENT_IN_KJV || kjvHand.getKey().getCardinality() == 1) { // TODO(CJB): deal with parts addKJVToMapping(kjvHand, leftHand); } else { //add the 1-many mappings //expand the key and add them all //Parts are not supported on ranges... Iterator<Key> kjvKeys = kjvHand.getKey().iterator(); while (kjvKeys.hasNext()) { addKJVToMapping(new QualifiedKey(KeyUtil.getVerse(kjvKeys.next())), leftHand); } } }
Iterator<Key> leftIter = leftKeys.iterator(); if (kjvKeys != null && kjvKeys.getCardinality() != 1) { int diff = Math.abs(leftKeys.getCardinality() - kjvKeys.getCardinality());
/** * Adds a 1-Many mapping, by simply listing out all the properties. There is probably * a better way for storing this, perhaps in a tree - but for simplicity, we're going to list them out. * * @param leftHand the left hand side operand * @param kjvVerses the verses that are mapped by the left hand side */ private void addMappings(final QualifiedKey leftHand, final QualifiedKey kjvVerses) throws NoSuchVerseException { if (leftHand.getAbsentType() == QualifiedKey.Qualifier.ABSENT_IN_LEFT) { this.absentVerses.addAll(kjvVerses.getKey()); } else if (leftHand.getKey().getCardinality() == 1) { add1ToManyMappings(leftHand.getVerse(), kjvVerses); } else { addManyToMany(leftHand, kjvVerses); } }
if (offsetBasis == null || offsetBasis.getCardinality() == 0) {