Class AssemblingUtils

java.lang.Object
com.priint.pubserver.plugin.entitydata.utils.AssemblingUtils

public class AssemblingUtils extends Object
Helper methods for assembling lists of KeyValue.
Since:
4.1.0
  • Field Details

  • Constructor Details

    • AssemblingUtils

      public AssemblingUtils()
  • Method Details

    • deleteIntersectionKVs

      public List<List<KeyValue>> deleteIntersectionKVs(List<List<KeyValue>> pListOfKeyValuesList, List<String> compareCriteria) throws PubServerException
      If there is one KV's in all lists, they will be deleted in all lists.
      Parameters:
      pListOfKeyValuesList - The list of key value lists where double entries will be deleted.
      compareCriteria - The actual compare criteria to be able to decide when one KV is identical.
      Returns:
      The reduced pListOfKeyValuesList.
      Throws:
      PubServerException
      Since:
      4.1.0
    • deleteKVsWhereInMoreLists

      public List<List<KeyValue>> deleteKVsWhereInMoreLists(List<List<KeyValue>> pListOfKeyValuesList, List<String> compareCriteria, int[][] arrToRemember) throws PubServerException
      If there is one KV's in at least one more lists, they will be deleted in all this lists.
      Parameters:
      pListOfKeyValuesList - The list of key value lists where double entries will be deleted.
      compareCriteria - The actual compare criteria to be able to decide when one KV is identical.
      Returns:
      The reduced pListOfKeyValuesList.
      Throws:
      PubServerException
      Since:
      4.1.0
    • deleteIntersectionKVsWithMissingKey

      public List<List<KeyValue>> deleteIntersectionKVsWithMissingKey(List<List<KeyValue>> pListOfKeyValuesList, List<String> compareCriteria) throws PubServerException
      If the actual KV was found in every other list (where the key exist in that list) but there is also at least one list without that key.
      Parameters:
      pListOfKeyValuesList - The list of key value lists where entries may may be deleted.
      compareCriteria - List of elements those who will be checked for equality.
      Returns:
      The reduced pListOfKeyValuesList if the actual KV was found in every list and there is at least one list without that key otherwise the unchanged pListOfKeyValuesList.
      Throws:
      PubServerException
      Since:
      4.1.0
    • getIDsOfIntersectionWithMissingKey

      public int[] getIDsOfIntersectionWithMissingKey(KeyValue pCompKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> compareCriteria, int pIndexOfAktList, int pPosInAktList) throws PubServerException
      Look in pListOfKeyValuesList where to find the current key value in other lists and write the indexes of the found KV in an array to give them back.
      Here also is indicated if the Key of that current key value is NOT found in a list.
      Parameters:
      pCompKeyValue - The current key value to look for in every list.
      pListOfKeyValuesList - The list of key value lists where to look for the current key value.
      compareCriteria - List of elements those who will be checked for equality.
      pIndexOfAktList - The index of the actual list of ListOfKeyValuesList.
      pPosInAktList - The index of the actual KV in the actual list.
      Returns:
      array of indices of every KV-list where pAktKeyValue was found
      or -1 if the key of pAktKeyValue was not found.
      or -2 if the key of pAktKeyValue was found but with an other value.
      Throws:
      PubServerException
      Since:
      4.1.0
    • getIDsOfIntersectionWithMissingKey_UH

      public int[] getIDsOfIntersectionWithMissingKey_UH(KeyValue pCompKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> compareCriteria, int pIndexOfAktList, int pPosInAktList, int[][] arrToRemember) throws PubServerException
      Look in pListOfKeyValuesList for all unhandled KV's where to find the current key value in other lists and write the indexes of the found KV in an array to give them back.
      Here also is indicated if the Key of that current key value is NOT found in a list.
      Parameters:
      pCompKeyValue - The current key value to look for in every list.
      pListOfKeyValuesList - The list of key value lists where to look for the current key value.
      compareCriteria - List of elements those who will be checked for equality.
      pIndexOfAktList - The index of the actual list of ListOfKeyValuesList.
      pPosInAktList - The index of the actual KV in the actual list.
      Returns:
      array of indices of every KV-list where pAktKeyValue was found
      or -1 if the key of pAktKeyValue was not found.
      or -2 if the key of pAktKeyValue was found but with an other value.
      Throws:
      PubServerException
      Since:
      4.1.0
    • countValuesForVerglKey

      public int[] countValuesForVerglKey(KeyValue pCompKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> compareCriteria, int[][] arrToRemember) throws PubServerException
      Go throw all unhandled KV's of pListOfKeyValuesList and simply look for the amount of occurrence of a unhandled KV with the same key as from pCompKeyValue.
      Parameters:
      pCompKeyValue - The current key value to look for in every list.
      pListOfKeyValuesList - The list of key value lists where to look for the current key value.
      compareCriteria - List of elements those who will be checked for equality.
      arrToRemember - The help array with the same dimension as pListOfKeyValuesList to be able to find the handled KV's.
      Returns:
      Array, which shows for every list of List<List<KeyValue>> the amount of remaining KV with the same key as pCompKeyValue.
      Throws:
      PubServerException
      Since:
      4.1.0
    • markAktKeyAsHandeled

      public int[][] markAktKeyAsHandeled(KeyValue pCompKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> compareCriteria, int[][] arrToRemember) throws PubServerException
      Go throw all unhandled KV's pListOfKeyValuesList and mark all KV's which have the same key as verglKeyValue as handled.
      Parameters:
      pCompKeyValue - The current key value to look for in every list.
      pListOfKeyValuesList - The list of key value lists where to look for the current key value.
      compareCriteria - List of elements those who will be checked for equality.
      arrToRemember - The help array with the same dimension as pListOfKeyValuesList where to mark KV's as handled.
      Returns:
      Refreshed arrToRemember (refreshed for all KV's from pCompKeyValue).
      Throws:
      PubServerException
      Since:
      4.1.0
    • isNoMoreKVInOtherLists

      public boolean isNoMoreKVInOtherLists(KeyValue pOriKeyValue, List<KeyValue> pFoundArrListKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> compareCriteria) throws PubServerException
      Look in pListOfKeyValuesList if there is an value of the key of pOriKeyValue which is not in pFoundArrListKeyValue.
      This means intersection of all values of the key from pOriKeyValue is not allowed.
      Parameters:
      pOriKeyValue - The KV from the first list where intersection was found for.
      pFoundArrListKeyValue - The list of KV's with the same key as pOriKeyValue, where intersection was found for also.
      pListOfKeyValuesList - The list of key value lists we are working with.
      compareCriteria - List of elements those who will be checked for equality.
      Returns:
      isAlsoValueIdentical.
      Throws:
      PubServerException
      Since:
      4.1.0
    • markAsHandeled

      public int[][] markAsHandeled(int[][] arrToRemember, KeyValue verglKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> pCriteria, int pFrom) throws PubServerException
      Every KV which is identical with KV of verglKeyValue will be marked as handled.
      Parameters:
      arrToRemember - The help array with the same dimension as pListOfKeyValuesList where to mark KV's as handled.
      verglKeyValue - The current key value that was found in some more lists.
      pListOfKeyValuesList - The list of key value lists we are working with.
      pCriteria - List of elements those who will be checked for equality.
      pFrom - List index of pListOfKeyValuesList which tells where to begin searching.
      Returns:
      Refreshed arrToRemember (refreshed for all KV's from verglKeyValue).
      Throws:
      PubServerException
      Since:
      4.1.0
    • getAmountOfAktKeyInAktList

      public int getAmountOfAktKeyInAktList(KeyValue verglKeyValue, List<KeyValue> curKeyValueList, List<String> pCriteria) throws PubServerException
      Counts in curKeyValueList the amount of Keys of verglKeyValue.
      Parameters:
      verglKeyValue - The current key value of which the key have to be count.
      curKeyValueList - The list where to look for amount of key.
      pCriteria - List of elements those who will be checked for equality.
      Returns:
      the amount of Keys.
      Throws:
      PubServerException
      Since:
      4.1.0
    • getAmountOfAktKeyInAllLists

      public int[] getAmountOfAktKeyInAllLists(KeyValue verglKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> pCriteria, int[][] arrToRemember, boolean pBreakCondition) throws PubServerException
      Counts the amount of Keys of verglKeyValue in ALL lists.
      Parameters:
      verglKeyValue - The current key value of which the key have to be count.
      pListOfKeyValuesList - The listOfList where to look for amount of key.
      pCriteria - List of elements those who will be checked for equality.
      arrToRemember - The help array with the same dimension as pListOfKeyValuesList where already handled KV's are marked out.
      pBreakCondition - To decide if to stop looping if amount of key > 1.
      Returns:
      array with the amount of Keys for every listOfList.
      Throws:
      PubServerException
      Since:
      4.1.0
    • isAmountOfAktKeyGreaterOne

      public boolean isAmountOfAktKeyGreaterOne(KeyValue verglKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> pCriteria, int[][] arrToRemember) throws PubServerException
      Check if the key of verglKeyValue occurs more then once in at least one listOfList.
      Parameters:
      verglKeyValue - The current key value which has to be checked.
      pListOfKeyValuesList - The listOfList where to look for.
      pCriteria - List of elements those who will be checked for equality.
      arrToRemember - The help array with the same dimension as pListOfKeyValuesList where already handled KV's are marked out.
      Returns:
      true, if the key of verglKeyValue occurs more then once in at least one listOfList.
      Throws:
      PubServerException
      Since:
      4.1.0
    • areAllKVsIdentical

      public boolean areAllKVsIdentical(KeyValue verglKeyValue, List<List<KeyValue>> pListOfKeyValuesList, List<String> pCriteria) throws PubServerException
      Check if the value of verglKeyValue occurs in every list where is a key from verglKeyValue.
      Parameters:
      verglKeyValue - The current key value which has to be checked.
      pListOfKeyValuesList - The listOfList where to look for.
      pCriteria - List of elements those who will be checked for equality.
      Returns:
      true, if the value exist everywhere.
      Throws:
      PubServerException
      Since:
      4.1.0
    • getNextVerglKV

      public KeyValue getNextVerglKV(KeyValue verglKeyValue, List<KeyValue> curKeyValueList, List<String> compareCriteria, int[][] arrToRemember, int curIndex, int[] arrToHoldIDs) throws PubServerException
      Search for the next unhandled KV with the same key out of curKeyValueList and his index.
      Parameters:
      verglKeyValue - The current key value which holds the key (or keylabel) which should be found again.
      curKeyValueList - The list where to look for the next same unhandled key (or keylabel).
      compareCriteria - List of elements those who will be checked for equality.
      arrToRemember - The help array with the same dimension as pListOfKeyValuesList where already handled KV's are marked out.
      curIndex - The beginning-condition from where on the key (or keylabel) chould be found again.
      arrToHoldIDs - The array where the index of the found next KV is written to.
      Returns:
      the next unhandled KV with the same key out of curKeyValueList and the index of this KV.
      Throws:
      PubServerException
      Since:
      4.1.0
    • isAnotherKV

      public boolean isAnotherKV(KeyValue curKeyValue, List<KeyValue> unionArrListKeyValue, List<String> criteria) throws PubServerException
      Look if curKeyValue is not jet found in any list depending on the criteria.
      Parameters:
      curKeyValue - The current key value to look for in every list.
      unionArrListKeyValue - All up till now fitting keyValues.
      criteria - List of elements those who will be checked for equality. It can be checked for the criteria - key, - keyvalue, - keylabel.
      Returns:
      true, if the current key value was not found in any list, otherwise false.
      Throws:
      PubServerException
      Since:
      4.1.0
    • checkCriteria

      public List<String> checkCriteria(List<String> curCriteria, List<String> defaultCriteria) throws PubServerException
      Check if the parameter holds the correct criteria-values.
      Parameters:
      curCriteria - The criteria which have to be checked.
      defaultCriteria - If empty criteria list is received the default one must be used.
      Returns:
      List of the used criteria or a errormessage if wrong criteria are found.
      Throws:
      PubServerException
      Since:
      4.1.0