src/main/java/cz/diribet/aqdef/model/AqdefObjectModel.java
/**
	 * Normalize the AQDEF content.
	 * <ul>
	 * <li>Apply all /0 K-keys on all parts / characteristics / values and then
	 * remove them from object model.</li>
	 * <li>Complement the hierarchy so there are no nodes/characteristics wihout a
	 * parent part node. This may happen when hierarchy was created from simple
	 * characteristics grouping (K2030/K2031).</li>
	 * </ul>
	 */
Normalize the AQDEF content.

Apply all /0 K-keys on all parts / characteristics / values and then
remove them from object model.
Complement the hierarchy so there are no nodes/characteristics wihout a
parent part node. This may happen when hierarchy was created from simple
characteristics grouping (K2030/K2031).

Normalize the AQDEF content . Apply all / 0 K - keys on all parts / characteristics / values and then remove them from object model . Complement the hierarchy so there are no nodes / characteristics wihout a parent part node . This may happen when hierarchy was created from simple characteristics grouping ( K2030 / K2031 ) .
public void normalize() {
		PartEntries entriesForAllParts = removePartEntries(PartIndex.of(0));
		if (MapUtils.isNotEmpty(entriesForAllParts)) {
			if (getPartIndexes().isEmpty()) {
				PartIndex partIndex = PartIndex.of(1);
				partEntries.put(partIndex, entriesForAllParts.withIndex(partIndex));
			} else {
				forEachPart((part) -> {
					part.putAll(entriesForAllParts.withIndex(part.getIndex()), false);
				});
			}
		}
		CharacteristicIndex indexForAllCharacteristicsOfAllParts = CharacteristicIndex.of(PartIndex.of(0), 0);
		CharacteristicEntries entriesForAllCharacteristicsOfAllParts = new CharacteristicEntries(indexForAllCharacteristicsOfAllParts);
		CharacteristicEntries characteristicEntriesForAllCharacteristicsOfAllParts =
				removeCharacteristicEntries(indexForAllCharacteristicsOfAllParts);
		if (MapUtils.isNotEmpty(characteristicEntriesForAllCharacteristicsOfAllParts)) {
			entriesForAllCharacteristicsOfAllParts.putAll(characteristicEntriesForAllCharacteristicsOfAllParts, false);
		}
		List<ValueEntries> entriesForAllValuesOfAllParts = removeValueEntries(indexForAllCharacteristicsOfAllParts);
		Map<Integer, List<ValueEntries>> entriesForAllValuesByValueIndex =
				entriesForAllValuesOfAllParts
											.stream()
											.collect(groupingBy(e -> e.getIndex().getValueIndex()));
		forEachPart((part) -> {
			CharacteristicIndex indexForAllCharacteristics = CharacteristicIndex.of(part.getIndex(), 0);
			CharacteristicEntries entriesForAllCharacteristics = removeCharacteristicEntries(indexForAllCharacteristics);
			if (MapUtils.isNotEmpty(entriesForAllCharacteristics)) {
				entriesForAllCharacteristicsOfAllParts.putAll(entriesForAllCharacteristics, false);
			}
		});
		forEachCharacteristic((part, characteristic) -> {
			characteristic.putAll(entriesForAllCharacteristicsOfAllParts.withIndex(characteristic.getIndex()), false);
			forEachValue(part, characteristic, (value) -> {
				List<ValueEntries> entriesForValueIndex = entriesForAllValuesByValueIndex.get(value.getIndex().getValueIndex());
				if (entriesForValueIndex != null) {
					for (ValueEntries valueEntries : entriesForValueIndex) {
						value.putAll(valueEntries.withIndex(value.getIndex()), false);
					}
				}
			});
		});
		hierarchy = hierarchy.normalize(this);
	}
public void normalize ( ) { PartEntries entriesForAllParts = removePartEntries ( PartIndex . of ( 0 ) ) ; if ( MapUtils . isNotEmpty ( entriesForAllParts ) ) { if ( getPartIndexes ( ) . isEmpty ( ) ) { PartIndex partIndex = PartIndex . of ( 1 ) ; partEntries . put ( partIndex , entriesForAllParts . withIndex ( partIndex ) ) ; } else { forEachPart ( ( part ) -> { part . putAll ( entriesForAllParts . withIndex ( part . getIndex ( ) ) , false ) ; } ) ; } } CharacteristicIndex indexForAllCharacteristicsOfAllParts = CharacteristicIndex . of ( PartIndex . of ( 0 ) , 0 ) ; CharacteristicEntries entriesForAllCharacteristicsOfAllParts = new CharacteristicEntries ( indexForAllCharacteristicsOfAllParts ) ; CharacteristicEntries characteristicEntriesForAllCharacteristicsOfAllParts = removeCharacteristicEntries ( indexForAllCharacteristicsOfAllParts ) ; if ( MapUtils . isNotEmpty ( characteristicEntriesForAllCharacteristicsOfAllParts ) ) { entriesForAllCharacteristicsOfAllParts . putAll ( characteristicEntriesForAllCharacteristicsOfAllParts , false ) ; } List < ValueEntries > entriesForAllValuesOfAllParts = removeValueEntries ( indexForAllCharacteristicsOfAllParts ) ; Map < Integer , List < ValueEntries > > entriesForAllValuesByValueIndex = entriesForAllValuesOfAllParts . stream ( ) . collect ( groupingBy ( e -> e . getIndex ( ) . getValueIndex ( ) ) ) ; forEachPart ( ( part ) -> { CharacteristicIndex indexForAllCharacteristics = CharacteristicIndex . of ( part . getIndex ( ) , 0 ) ; CharacteristicEntries entriesForAllCharacteristics = removeCharacteristicEntries ( indexForAllCharacteristics ) ; if ( MapUtils . isNotEmpty ( entriesForAllCharacteristics ) ) { entriesForAllCharacteristicsOfAllParts . putAll ( entriesForAllCharacteristics , false ) ; } } ) ; forEachCharacteristic ( ( part , characteristic ) -> { characteristic . putAll ( entriesForAllCharacteristicsOfAllParts . withIndex ( characteristic . getIndex ( ) ) , false ) ; forEachValue ( part , characteristic , ( value ) -> { List < ValueEntries > entriesForValueIndex = entriesForAllValuesByValueIndex . get ( value . getIndex ( ) . getValueIndex ( ) ) ; if ( entriesForValueIndex != null ) { for ( ValueEntries valueEntries : entriesForValueIndex ) { value . putAll ( valueEntries . withIndex ( value . getIndex ( ) ) , false ) ; } } } ) ; } ) ; hierarchy = hierarchy . normalize ( this ) ; }
Normalize the AQDEF content.
Normalize the AQDEF content .
// normalize part entries // if there are no part entries then /0 entries become /1 entries // put /0 entries to all existing parts // normalize characteristic and value entries // value entries for all values are applied to single value set for all characteristic values