Java Code Examples for java.util.HashMap.clear()

The following are Jave code examples for showing how to use clear() of the java.util.HashMap class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: HashMapCloneLeak.java   View Source Code Vote up 6 votes
public static void main(String[] args) throws Exception {
    HashMap<Integer, Object> hm = makeMap();
    hm = (HashMap<Integer, Object>)hm.clone();
    hm.clear();
    // There should no longer be a strong reference to testObject
    // the WeakReference should be nulled out by GC. If not,
    // we will hang here until timed out by the test harness.
    Object[] chain = null;
    while (wr.get() != null) {
        try {
            Object[] allocate = new Object[1000000];
            allocate[0] = chain;
            chain = allocate;
        } catch (OutOfMemoryError oome) {
            chain = null;
        }
        System.gc();
        Thread.sleep(100);
    }
}
 
Example 2
Project: javaide   File: EmptyHashMapExample.java   View Source Code Vote up 6 votes
public static void main(String[] args) {

    //create HashMap object
    HashMap hMap = new HashMap();

    //add key value pairs to HashMap
    hMap.put("1", "One");
    hMap.put("2", "Two");
    hMap.put("3", "Three");

    /*
      To remove all values or clear HashMap use
      void clear method() of HashMap class. Clear method removes all
      key value pairs contained in HashMap.
    */

    hMap.clear();

    System.out.println("Total key value pairs in HashMap are : " + hMap.size());
  }
 
Example 3
Project: QDrill   File: ParquetRecordReaderTest.java   View Source Code Vote up 6 votes
/**
 * Tests the attribute in a scan node to limit the columns read by a scan.
 *
 * The functionality of selecting all columns is tested in all of the other tests that leave out the attribute.
 * @throws Exception
 */
@Test
public void testSelectColumnRead() throws Exception {
  HashMap<String, FieldInfo> fields = new HashMap<>();
  ParquetTestProperties props = new ParquetTestProperties(4, 3000, DEFAULT_BYTES_PER_PAGE, fields);
  // generate metatdata for a series of test columns, these columns are all generated in the test file
  populateFieldInfoMap(props);
  TestFileGenerator.generateParquetFile("/tmp/test.parquet", props);
  fields.clear();
  // create a new object to describe the dataset expected out of the scan operation
  // the fields added below match those requested in the plan specified in parquet_selective_column_read.json
  // that is used below in the test query
  props = new ParquetTestProperties(4, 3000, DEFAULT_BYTES_PER_PAGE, fields);
  props.fields.put("integer", new FieldInfo("int32", "integer", 32, TestFileGenerator.intVals, TypeProtos.MinorType.INT, props));
  props.fields.put("bigInt", new FieldInfo("int64", "bigInt", 64, TestFileGenerator.longVals, TypeProtos.MinorType.BIGINT, props));
  props.fields.put("bin", new FieldInfo("binary", "bin", -1, TestFileGenerator.binVals, TypeProtos.MinorType.VARBINARY, props));
  props.fields.put("bin2", new FieldInfo("binary", "bin2", -1, TestFileGenerator.bin2Vals, TypeProtos.MinorType.VARBINARY, props));
  testParquetFullEngineEventBased(true, false, "/parquet/parquet_selective_column_read.json", null, "/tmp/test.parquet", 1, props, QueryType.PHYSICAL);
}
 
Example 4
Project: GitHub   File: RecyclerViewCacheUtil.java   View Source Code Vote up 5 votes
/**
 * init the cache on your own.
 *
 * @param recyclerView
 * @param items
 */
public void apply(RecyclerView recyclerView, Iterable<Item> items) {
    if (items != null) {
        //we pre-create the views for our cache
        HashMap<Integer, Stack<RecyclerView.ViewHolder>> cache = new HashMap<>();
        for (Item d : items) {
            if (!cache.containsKey(d.getType())) {
                cache.put(d.getType(), new Stack<RecyclerView.ViewHolder>());
            }

            if (mCacheSize == -1 || cache.get(d.getType()).size() <= mCacheSize) {
                cache.get(d.getType()).push(d.getViewHolder(recyclerView));
            }

            RecyclerView.RecycledViewPool recyclerViewPool = new RecyclerView.RecycledViewPool();

            //we fill the pool
            for (Map.Entry<Integer, Stack<RecyclerView.ViewHolder>> entry : cache.entrySet()) {
                recyclerViewPool.setMaxRecycledViews(entry.getKey(), mCacheSize);

                for (RecyclerView.ViewHolder holder : entry.getValue()) {
                    recyclerViewPool.putRecycledView(holder);
                }

                //make sure to clear the stack
                entry.getValue().clear();
            }

            //make sure to clear the cache
            cache.clear();

            recyclerView.setRecycledViewPool(recyclerViewPool);
        }
    }
}
 
Example 5
Project: incubator-netbeans   File: DriverListUtilTest.java   View Source Code Vote up 5 votes
public void testMSSQL2005() throws Exception {
    /*
            add(getMessage("DRIVERNAME_MSSQL2005"),
    "com.microsoft.sqlserver.jdbc.SQLServerDriver",
    "jdbc:sqlserver://[<HOST>[\\<INSTANCE>][:<PORT>]][;databaseName=<DB>][;<ADDITIONAL>]", true);
    */
    ArrayList<String> supportedProps = new ArrayList<String>();
    supportedProps.addAll(STD_SUPPORTED_PROPS);
    supportedProps.add(JdbcUrl.TOKEN_INSTANCE);
    
    ArrayList<String> requiredProps = new ArrayList<String>();
    JdbcUrl url = checkUrl(getDriverName("DRIVERNAME_MSSQL2005"), null, 
            "com.microsoft.sqlserver.jdbc.SQLServerDriver", 
            "jdbc:sqlserver://[<HOST>[\\<INSTANCE>][:<PORT>]][;databaseName=<DB>][;<ADDITIONAL>]", 
            supportedProps, requiredProps);
    
    HashMap<String, String> propValues = buildPropValues(supportedProps);        
    testUrlString(url, propValues, "jdbc:sqlserver://" + HOST + "\\" + INSTANCE + ":" + PORT + ";databaseName=" + DB + ";" + ADDITIONAL);

    propValues.remove(JdbcUrl.TOKEN_ADDITIONAL);
    testUrlString(url, propValues, "jdbc:sqlserver://" + HOST + "\\" + INSTANCE + ":" + PORT + ";databaseName=" + DB);
    
    propValues.remove(JdbcUrl.TOKEN_PORT);
    testUrlString(url, propValues, "jdbc:sqlserver://" + HOST + "\\" + INSTANCE + ";databaseName=" + DB);
    
    propValues.remove(JdbcUrl.TOKEN_INSTANCE);
    testUrlString(url, propValues, "jdbc:sqlserver://" + HOST + ";databaseName=" + DB);
    
    propValues.remove(JdbcUrl.TOKEN_DB);
    testUrlString(url, propValues, "jdbc:sqlserver://" + HOST);
    
    propValues.remove(JdbcUrl.TOKEN_HOST);
    propValues.put(JdbcUrl.TOKEN_DB, DB);
    testUrlString(url, propValues, "jdbc:sqlserver://;databaseName=" + DB);
    
    propValues.clear();
    testUrlString(url, propValues, "jdbc:sqlserver://");
    
}
 
Example 6
Project: JAddOn   File: JFileListener.java   View Source Code Vote up 5 votes
private void updateFile(HashMap<File, ArrayList<String>> file_data_temp, boolean reload) {
    file_data_temp.clear();
    if(file != null) {
        if(!file.exists()) {
            file_data_temp.put(file, null);
        } else {
            if(file.isFile()) {
                ArrayList<String> data = new ArrayList<>();/*
                if(file.exists()) {
                    try (Scanner scanner = new Scanner(file)) {
                        while(scanner.hasNextLine()) {
                            String line = scanner.nextLine();
                            data.add(line);
                        }
                        scanner.close();
                    } catch (Exception ex) {
                        StaticStandard.logErr("Error while scanning file: " + ex);
                    }
                }*/
                file_data_temp.put(file, data);
            } else if(file.isDirectory()) {
                addFolder(file, file_data_temp);
            }
        }
    }
    if(reload) {
        reloadFile();
    }
}
 
Example 7
Project: OSchina_resources_android   File: SimpleMonthAdapter.java   View Source Code Vote up 5 votes
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    SimpleMonthView v;
    HashMap<String, Integer> drawingParams = null;
    if (convertView != null) {
        v = (SimpleMonthView) convertView;
        drawingParams = (HashMap<String, Integer>) v.getTag();
    } else {
        v = new SimpleMonthView(mContext);
        v.setLayoutParams(new AbsListView.LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        v.setClickable(true);
        v.setOnDayClickListener(this);
    }
    if (drawingParams == null) {
        drawingParams = new HashMap<String, Integer>();
    }
    drawingParams.clear();

    final int month = position % MONTHS_IN_YEAR;
    final int year = position / MONTHS_IN_YEAR + mController.getMinYear();

    int selectedDay = -1;
    if (isSelectedDayInMonth(year, month)) {
        selectedDay = mSelectedDay.day;
    }

    v.reuse();

    drawingParams
            .put(SimpleMonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay);
    drawingParams.put(SimpleMonthView.VIEW_PARAMS_YEAR, year);
    drawingParams.put(SimpleMonthView.VIEW_PARAMS_MONTH, month);
    drawingParams.put(SimpleMonthView.VIEW_PARAMS_WEEK_START,
            mController.getFirstDayOfWeek());
    v.setMonthParams(drawingParams);
    v.invalidate();

    return v;
}
 
Example 8
Project: atbash-octopus   File: SessionUtil.java   View Source Code Vote up 5 votes
public void invalidateCurrentSession(HttpServletRequest request) {
        /*
        FIXME
        if (!octopusConfig.getIsSessionInvalidatedAtLogin()) {
            // Defined with config that developer don't was logout/session invalidation.
            return;
        }
*/

        /*
        if (SecurityUtils.getSubject() instanceof TwoStepSubject) {
            // Otherwise the principals are cleared from the current subject which isn't something we want :)
            return;
        }
        */
        HttpSession session = request.getSession();

        HashMap<String, Object> content = new HashMap<>();
        Enumeration keys = session.getAttributeNames();

        while (keys.hasMoreElements()) {
            String key = (String) keys.nextElement();
            content.put(key, session.getAttribute(key));
            session.removeAttribute(key);
        }

        SecurityUtils.getSubject().logout();

        session = request.getSession(true);
        for (Map.Entry m : content.entrySet()) {
            session.setAttribute((String) m.getKey(), m.getValue());
        }
        content.clear();
    }
 
Example 9
Project: bubichain-sdk-java   File: TransactionContent.java   View Source Code Vote up 5 votes
private void put(K key, V value){

            if (queue.get(queue.size() - 1).size() >= bufferSize) {
                if (queue.size() < queueLen) {
                    queue.add(new HashMap<>());
                } else {
                    HashMap<K, V> remove = queue.remove(0);
                    remove.clear();
                    queue.add(remove);
                }
            }

            queue.get(queue.size() - 1).put(key, value);
        }
 
Example 10
Project: m6ASNP   File: Node.java   View Source Code Vote up 5 votes
public Node(ArrayList<double[]> data)
{
    this.dataList = data;
    leftNode = null;
    rightNode = null;
    isLeaf = true;
    //Calculate Gini-impurity
    HashMap<Double, Integer>classType = new HashMap();
    for(double[] dataValue : dataList)
    {
        if(!classType.containsKey(dataValue[dataValue.length - 1]))
            classType.put(dataValue[dataValue.length - 1], 1);
        else
        {
            int count = classType.get(dataValue[dataValue.length - 1]) + 1;
            classType.put(dataValue[dataValue.length - 1], count);
        }
    }
    impurity = 1;
    double count, dataSize = dataList.size();
    double maxCount = -1;
    for(double classIndex : classType.keySet())
    {
        count = classType.get(classIndex);
        impurity = impurity - Math.pow(count/dataSize, 2);
        if(count > maxCount)
        {
            majorityType = classIndex;
            maxCount = count;
        }
    }
    classType.clear();
}
 
Example 11
Project: odoo-work   File: OdooWrapper.java   View Source Code Vote up 5 votes
public HashMap<String, Object> updateContext(HashMap<String, Object> newContext) {
    if (odooSession != null && odooSession.userContext() != null)
        newContext.putAll(odooSession.userContext());
    if (user != null) {
        newContext.clear();
        newContext.put("uid", user.getUserId());
        newContext.put("tz", user.getTimezone());
    }
    return newContext;
}
 
Example 12
Project: monarch   File: PartitionedRegion.java   View Source Code Vote up 4 votes
/**
 * Fetches entries from local and remote nodes and appends these to register-interest response.
 */
public void fetchEntries(HashMap<Integer, HashSet> bucketKeys, VersionedObjectList values,
    ServerConnection servConn) throws IOException {
  int retryAttempts = calcRetry();
  RetryTimeKeeper retryTime = null;
  HashMap<Integer, HashSet> failures = new HashMap<Integer, HashSet>(bucketKeys);
  HashMap<InternalDistributedMember, HashMap<Integer, HashSet>> nodeToBuckets =
      new HashMap<InternalDistributedMember, HashMap<Integer, HashSet>>();

  while (--retryAttempts >= 0 && !failures.isEmpty()) {
    nodeToBuckets.clear();
    updateNodeToBucketMap(nodeToBuckets, failures);
    failures.clear();

    HashMap<Integer, HashSet> localBuckets = nodeToBuckets.remove(getMyId());
    if (localBuckets != null && !localBuckets.isEmpty()) {
      Set keys = new HashSet();
      for (Integer id : localBuckets.keySet()) {
        keys.addAll(localBuckets.get(id));
      }
      if (!keys.isEmpty()) {
        BaseCommand.appendNewRegisterInterestResponseChunkFromLocal(this, values, "keyList", keys,
            servConn);
      }
    }

    // Handle old nodes for Rolling Upgrade support
    Set<Integer> failedSet = handleOldNodes(nodeToBuckets, values, servConn);
    // Add failed buckets to nodeToBuckets map so that these will be tried on
    // remote nodes.
    if (!failedSet.isEmpty()) {
      for (Integer bId : failedSet) {
        failures.put(bId, bucketKeys.get(bId));
      }
      updateNodeToBucketMap(nodeToBuckets, failures);
      failures.clear();
    }

    fetchRemoteEntries(nodeToBuckets, failures, values, servConn);
    if (!failures.isEmpty()) {
      if (retryTime == null) {
        retryTime = new RetryTimeKeeper(this.retryTimeout);
      }
      if (!waitForFetchRemoteEntriesRetry(retryTime)) {
        break;
      }
    }
  }
  if (!failures.isEmpty()) {
    throw new InternalGemFireException("Failed to fetch entries from " + failures.size()
        + " buckets of region " + getName() + " for register interest.");
  }
}
 
Example 13
Project: ctsms   File: TrialServiceImpl.java   View Source Code Vote up 4 votes
private ECRFFieldValuesOutVO getEcrfFieldValues(ECRF ecrf, String section, ProbandListEntryOutVO listEntryVO, boolean addSeries, boolean jsValues, boolean loadAllJsValues,
		PSFVO psf) throws Exception {
	ECRFFieldValuesOutVO result = new ECRFFieldValuesOutVO();
	if (listEntryVO != null && ecrf != null) {
		ECRFFieldDao ecrfFieldDao = this.getECRFFieldDao();
		ECRFFieldValueDao ecrfFieldValueDao = this.getECRFFieldValueDao();
		Collection<Map> ecrfFieldValues = ecrfFieldValueDao.findByListEntryEcrfSectionJs(listEntryVO.getId(), ecrf.getId(), section, true, null, psf);
		HashMap<String, Long> maxSeriesIndexMap = null;
		HashMap<String, Long> fieldMaxPositionMap = null;
		HashMap<String, Long> fieldMinPositionMap = null;
		HashMap<String, Set<ECRFField>> seriesEcrfFieldMap = null;
		// HashMap<String, Set<ECRFField>> seriesEcrfFieldJsMap = null;
		if (addSeries) {
			maxSeriesIndexMap = new HashMap<String, Long>();
			fieldMaxPositionMap = new HashMap<String, Long>();
			fieldMinPositionMap = new HashMap<String, Long>();
			seriesEcrfFieldMap = new HashMap<String, Set<ECRFField>>();
			// seriesEcrfFieldJsMap = new HashMap<String, Set<ECRFField>>();
			ServiceUtil.initSeriesEcrfFieldMaps(
					ecrfFieldDao.findByTrialEcrfSectionSeriesJs(null, ecrf.getId(), section, true, true, null, null),
					listEntryVO.getId(),
					ecrf.getId(),
					maxSeriesIndexMap,
					fieldMaxPositionMap,
					fieldMinPositionMap,
					seriesEcrfFieldMap,
					// seriesEcrfFieldJsMap,
					ecrfFieldValueDao
					);
		}
		result.setPageValues(ServiceUtil.getEcrfFieldValues(listEntryVO, ecrfFieldValues, maxSeriesIndexMap, fieldMaxPositionMap, fieldMinPositionMap, seriesEcrfFieldMap,
				null,
				ecrfFieldDao,
				ecrfFieldValueDao,
				this.getECRFFieldStatusEntryDao(),
				this.getECRFFieldStatusTypeDao())); // this.getInputFieldSelectionSetValueDao()
		if (jsValues) {
			if (addSeries) {
				maxSeriesIndexMap.clear();
				fieldMaxPositionMap.clear();
				fieldMinPositionMap.clear();
				seriesEcrfFieldMap.clear();
				// seriesEcrfFieldJsMap.clear();
				ServiceUtil.initSeriesEcrfFieldMaps(
						(loadAllJsValues ? ecrfFieldDao.findByTrialEcrfSeriesJs(null, ecrf.getId(), true, true, true, null) :
							ecrfFieldDao.findByTrialEcrfSectionSeriesJs(null, ecrf.getId(), section, true, true, true, null)),
							listEntryVO.getId(),
							ecrf.getId(),
							maxSeriesIndexMap,
							fieldMaxPositionMap,
							fieldMinPositionMap,
							seriesEcrfFieldMap,
							// seriesEcrfFieldJsMap,
							ecrfFieldValueDao
						);
			}
			if (loadAllJsValues) {
				result.setJsValues(ServiceUtil.getEcrfFieldJsonValues(
						// ecrfFieldValueDao.findByListEntryEcrfSectionJs(listEntryVO.getId(), ecrf.getId(), section, true, true, null),
						ecrfFieldValueDao.findByListEntryEcrfJs(listEntryVO.getId(), ecrf.getId(), true, true, null),
						maxSeriesIndexMap, fieldMaxPositionMap,
						fieldMinPositionMap, seriesEcrfFieldMap,
						false, ecrfFieldValueDao,
						this.getInputFieldSelectionSetValueDao()));
			} else {
				result.setJsValues(ServiceUtil.getEcrfFieldJsonValues(ecrfFieldValues,
						maxSeriesIndexMap, fieldMaxPositionMap,
						fieldMinPositionMap, seriesEcrfFieldMap,
						true, ecrfFieldValueDao,
						this.getInputFieldSelectionSetValueDao()));
			}
		}
	}
	return result;
}
 
Example 14
Project: incubator-netbeans   File: MultiPartHandler.java   View Source Code Vote up 4 votes
public void parseMultipartUpload()
              throws IOException {
  // setup the initial buffered input stream, boundary string that separates
  // various parts in the stream.
  startMultipartParse();

  HashMap partHeaders = parsePartHeaders();
  while (partHeaders != null) {

      String fieldName = (String)partHeaders.get("fieldName");
      String fileName = (String)partHeaders.get("fileName");

      if (fileName != null) {
          // This is a file upload part
          if (fileName.equals("")) {
              fileName = null; // empty filename, probably an "empty" file param
          }

          if (fileName != null) {
              // a filename was actually specified
              String content = (String)partHeaders.get("content-type");
              fileName = saveUploadFile(fileName, content);

              uploadFiles.put(fieldName, 
                  new OneUpload( 
                     uploadDir.toString(), 
                     fileName, 
                     content
                 )
              );
          }
          else {
              uploadFiles.put(fieldName, new OneUpload(null, null, null));
          }
      }
      else {
          // this is a parameters list part
          byte[] valueBytes = parseFormFieldBytes();
          String value = new String(valueBytes, fieldEncoding);

          Vector<String> existingValues = formFields.get(fieldName);
          if (existingValues == null) {
              existingValues = new Vector<String>();
              formFields.put(fieldName, existingValues);
          }
          existingValues.addElement(value);
      }

      partHeaders.clear();
      partHeaders = parsePartHeaders();
  }
}
 
Example 15
Project: AssistantBySDK   File: MonthAdapter.java   View Source Code Vote up 4 votes
@SuppressLint("NewApi")
@SuppressWarnings("unchecked")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    MonthView v;
    HashMap<String, Integer> drawingParams = null;
    if (convertView != null) {
        v = (MonthView) convertView;
        // We store the drawing parameters in the view so it can be recycled
        drawingParams = (HashMap<String, Integer>) v.getTag();
    } else {
        v = createMonthView(mContext);
        // Set up the new view
        LayoutParams params = new LayoutParams(
                LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
        v.setLayoutParams(params);
        v.setClickable(true);
        v.setOnDayClickListener(this);
    }
    if (drawingParams == null) {
        drawingParams = new HashMap<>();
    }
    drawingParams.clear();

    final int month = (position + mController.getStartDate().get(Calendar.MONTH)) % MONTHS_IN_YEAR;
    final int year = (position + mController.getStartDate().get(Calendar.MONTH)) / MONTHS_IN_YEAR + mController.getMinYear();

    int selectedDay = -1;
    if (isSelectedDayInMonth(year, month)) {
        selectedDay = mSelectedDay.day;
    }

    // Invokes requestLayout() to ensure that the recycled view is set with the appropriate
    // height/number of weeks before being displayed.
    v.reuse();

    drawingParams.put(MonthView.VIEW_PARAMS_SELECTED_DAY, selectedDay);
    drawingParams.put(MonthView.VIEW_PARAMS_YEAR, year);
    drawingParams.put(MonthView.VIEW_PARAMS_MONTH, month);
    drawingParams.put(MonthView.VIEW_PARAMS_WEEK_START, mController.getFirstDayOfWeek());
    v.setMonthParams(drawingParams);
    v.invalidate();
    return v;
}
 
Example 16
Project: emr-nlp-server   File: test.java   View Source Code Vote up 4 votes
protected static void testSaveFeatureWeight() throws Exception {
    String folder = Util.getOSPath(new String[] {Util.getExecutingPath(),
            "data", "emr-vis-nlp_colonoscopy2", "modelsWeights"});
    String fn_featureWeight;
    String fn_featureWeightDist;
    String[][] featureWeightTable;
    HashMap<Double, Integer> valueCountMap = new HashMap<>();
    double value;
    int count;
    StringBuilder sb;
    Iterator iter;
    
    for(String varName : varNameList) {
        for(int iFold : foldList) {
            fn_featureWeight = getFeatureWeightFileName(folder, varName, iFold);
            fn_featureWeightDist = getFeatureWeightDistributionFileName(folder, varName, iFold);
            
            featureWeightTable = Util.loadTable(fn_featureWeight);
            valueCountMap.clear();
            
            for(int i = 0; i < featureWeightTable.length; i++) {
                value = Math.abs(Double.parseDouble(featureWeightTable[i][1]));
                try {
                    valueCountMap.put(value, valueCountMap.get(value) + 1);
                }
                catch (NullPointerException e) {
                    valueCountMap.put(value, 1);
                }
            }
            
            sb = new StringBuilder();
            // sort the list by value
            List<Double> sortedKeys = new ArrayList(valueCountMap.keySet());
            Collections.sort(sortedKeys);
            // descending
            Collections.reverse(sortedKeys);
            for(double key : sortedKeys) {
                count = valueCountMap.get(key);
                sb.append(key);
                sb.append(",");
                sb.append(count);
                sb.append("\n");
            }
            
            Util.saveTextFile(fn_featureWeightDist, sb.toString());
        }
    }
}
 
Example 17
Project: alfresco-repository   File: ChainingAuthenticationServiceTest.java   View Source Code Vote up 4 votes
@Override
protected void setUp() throws Exception
{
    if (AlfrescoTransactionSupport.getTransactionReadState() != TxnReadState.TXN_NONE)
    {
        throw new AlfrescoRuntimeException(
                "A previous tests did not clean up transaction: " +
                AlfrescoTransactionSupport.getTransactionId());
    }
    
    AuthenticationUtil authUtil = new AuthenticationUtil();
    authUtil.setDefaultAdminUserName("admin");
    authUtil.setDefaultGuestUserName("guest");
    authUtil.afterPropertiesSet();
    
    service1 = new TestAuthenticationServiceImpl(ALFRESCO, true, true, true, false);
    service1.createAuthentication("andy", "andy".toCharArray());

    HashMap<String, String> up = new HashMap<String, String>();
    HashSet<String> disabled = new HashSet<String>();
    up.put("lone", "lone");
    service2 = new TestAuthenticationServiceImpl(LONELY_ENABLED, false, false, false, true, up, disabled);

    up.clear();
    disabled.clear();

    up.put("ranger", "ranger");
    disabled.add("ranger");

    service3 = new TestAuthenticationServiceImpl(LONELY_DISABLE, false, false, false, false, up, disabled);

    service4 = new TestAuthenticationServiceImpl(EMPTY, true, true, true, false);

    up.clear();
    disabled.clear();

    up.put("A", "A");
    up.put("B", "B");
    up.put("C", "C");
    up.put("D", "D");
    up.put("E", "E");
    service5 = new TestAuthenticationServiceImpl(FIVE, false, false, false, false, up, disabled);

    up.clear();
    disabled.clear();

    up.put("A", "a");
    up.put("B", "b");
    up.put("C", "c");
    up.put("D", "d");
    up.put("E", "e");
    up.put("F", "f");
    up.put("G", "g");
    up.put("H", "h");
    up.put("I", "i");
    up.put("J", "j");
    up.put("K", "k");
    service6 = new TestAuthenticationServiceImpl(FIVE_AND_MORE, false, false, false, false, up, disabled);
}
 
Example 18
Project: ctsms   File: TrialServiceImpl.java   View Source Code Vote up 4 votes
private ECRFFieldValuesOutVO getEcrfFieldValues(ECRF ecrf, ProbandListEntryOutVO listEntryVO, boolean addSeries, boolean jsValues, boolean loadAllJsValues, PSFVO psf)
		throws Exception {
	ECRFFieldValuesOutVO result = new ECRFFieldValuesOutVO();
	if (listEntryVO != null && ecrf != null) {
		ECRFFieldDao ecrfFieldDao = this.getECRFFieldDao();
		ECRFFieldValueDao ecrfFieldValueDao = this.getECRFFieldValueDao();
		Collection<Map> ecrfFieldValues = ecrfFieldValueDao.findByListEntryEcrfJs(listEntryVO.getId(), ecrf.getId(), true, null, psf);
		HashMap<String, Long> maxSeriesIndexMap = null;
		HashMap<String, Long> fieldMaxPositionMap = null;
		HashMap<String, Long> fieldMinPositionMap = null;
		HashMap<String, Set<ECRFField>> seriesEcrfFieldMap = null;
		// HashMap<String, Set<ECRFField>> seriesEcrfFieldJsMap = null;
		if (addSeries) {
			maxSeriesIndexMap = new HashMap<String, Long>();
			fieldMaxPositionMap = new HashMap<String, Long>();
			fieldMinPositionMap = new HashMap<String, Long>();
			seriesEcrfFieldMap = new HashMap<String, Set<ECRFField>>();
			// seriesEcrfFieldJsMap = new HashMap<String, Set<ECRFField>>();
			ServiceUtil.initSeriesEcrfFieldMaps(
					ecrfFieldDao.findByTrialEcrfSeriesJs(null, ecrf.getId(), true, true, null, null),
					listEntryVO.getId(),
					ecrf.getId(),
					maxSeriesIndexMap,
					fieldMaxPositionMap,
					fieldMinPositionMap,
					seriesEcrfFieldMap,
					// seriesEcrfFieldJsMap,
					ecrfFieldValueDao
					);
		}
		result.setPageValues(ServiceUtil.getEcrfFieldValues(listEntryVO, ecrfFieldValues, maxSeriesIndexMap, fieldMaxPositionMap, fieldMinPositionMap, seriesEcrfFieldMap,
				null,
				ecrfFieldDao,
				ecrfFieldValueDao,
				this.getECRFFieldStatusEntryDao(),
				this.getECRFFieldStatusTypeDao())); // this.getInputFieldSelectionSetValueDao()
		if (jsValues) {
			if (addSeries) {
				maxSeriesIndexMap.clear();
				fieldMaxPositionMap.clear();
				fieldMinPositionMap.clear();
				seriesEcrfFieldMap.clear();
				// seriesEcrfFieldJsMap.clear();
				ServiceUtil.initSeriesEcrfFieldMaps(
						ecrfFieldDao.findByTrialEcrfSeriesJs(null, ecrf.getId(), true, true, true, null),
						listEntryVO.getId(),
						ecrf.getId(),
						maxSeriesIndexMap,
						fieldMaxPositionMap,
						fieldMinPositionMap,
						seriesEcrfFieldMap,
						// seriesEcrfFieldJsMap,
						ecrfFieldValueDao
						);
			}
			if (loadAllJsValues) {
				result.setJsValues(ServiceUtil.getEcrfFieldJsonValues(ecrfFieldValueDao.findByListEntryEcrfJs(listEntryVO.getId(), ecrf.getId(), true, true, null),
						maxSeriesIndexMap, fieldMaxPositionMap, fieldMinPositionMap, seriesEcrfFieldMap,
						false, ecrfFieldValueDao,
						this.getInputFieldSelectionSetValueDao()));
			} else {
				result.setJsValues(ServiceUtil.getEcrfFieldJsonValues(ecrfFieldValues, maxSeriesIndexMap, fieldMaxPositionMap, fieldMinPositionMap, seriesEcrfFieldMap,
						true, ecrfFieldValueDao,
						this.getInputFieldSelectionSetValueDao()));
			}
		}
	}
	return result;
}
 
Example 19
Project: FreeCol   File: DebugUtils.java   View Source Code Vote up 4 votes
/**
 * Debug action to display Europe.
 *
 * Called from the debug popup menu.
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public static void displayEurope(final FreeColClient freeColClient) {
    final FreeColServer server = freeColClient.getFreeColServer();
    final Game sGame = server.getGame();
    final AIMain aiMain = server.getAIMain();

    LogBuilder lb = new LogBuilder(256);
    List<Unit> inEurope = new ArrayList<>();
    List<Unit> toEurope = new ArrayList<>();
    List<Unit> toAmerica = new ArrayList<>();
    HashMap<String,List<Unit>> units = new HashMap<>();
    for (Player tp : sGame.getLiveEuropeanPlayerList()) {
        Player p = sGame.getFreeColGameObject(tp.getId(), Player.class);
        if (p.getEurope() == null) continue;
        inEurope.clear();
        toEurope.clear();
        toAmerica.clear();
        units.clear();
        units.put(Messages.message("sailingToEurope"), toEurope);
        units.put(Messages.getName(p.getEurope()), inEurope);
        units.put(Messages.message("sailingToAmerica"), toAmerica);
        lb.add("\n==", Messages.message(p.getCountryLabel()), "==\n");

        for (Unit u : p.getEurope().getUnitList()) {
            if (u.getDestination() instanceof Map) {
                toAmerica.add(u);
            } else if (u.getDestination() instanceof Europe) {
                toEurope.add(u);
            } else {
                inEurope.add(u);
            }
        }
        forEachMapEntry(units,
            e -> logEurope(aiMain, lb, e.getKey(), e.getValue()));
        lb.add("\n->", Messages.message("immigrants"), "\n\n");
        for (AbstractUnit au : p.getEurope().getExpandedRecruitables(false)) {
            lb.add(Messages.message(au.getSingleLabel()), "\n");
        }
        lb.add("\n");
    }
    freeColClient.getGUI().showInformationMessage(lb.toString());
}
 
Example 20
Project: DynamicAC   File: BackendChecks.java   View Source Code Vote up 4 votes
public void wipe() {
    for(HashMap hashMap : maps) {
        hashMap.clear();
    }
}