Java Code Examples for java.util.HashMap

The following examples show how to use java.util.HashMap. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: cxf   Source File: MessageContextFirstHandler.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public boolean handleMessage(SOAPMessageContext context) {
    boolean isOutbound = (boolean)context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
    if (isOutbound) {
        @SuppressWarnings("unchecked")
        Map<String, List<String>> headerMap = (Map<String, List<String>>)context
            .get(MessageContext.HTTP_REQUEST_HEADERS);
        if (headerMap == null) {
            headerMap = new HashMap<>();
        }
        // Add custom header.
        headerMap.put("MY_HEADER", Arrays.asList("FIRST_VALUE"));
        context.put(MessageContext.HTTP_REQUEST_HEADERS, headerMap);
    }
    return true;
}
 
Example 2
Source Project: cxf   Source File: JWTTokenValidatorRealmTest.java    License: Apache License 2.0 5 votes vote down vote up
private Map<String, RealmProperties> getRealms() {
    // Create Realms
    Map<String, RealmProperties> realms = new HashMap<>();
    RealmProperties realm = new RealmProperties();
    realm.setIssuer("A-Issuer");
    realms.put("A", realm);
    realm = new RealmProperties();
    realm.setIssuer("B-Issuer");
    realms.put("B", realm);
    return realms;
}
 
Example 3
Source Project: mangopay2-java-sdk   Source File: PayInPaymentDetailsBankWire.java    License: MIT License 5 votes vote down vote up
/**
 * Gets map which property is an object and what type of object.
 *
 * @return Collection of field name-field type pairs.
 */
@Override
public Map<String, Type> getSubObjects() {

    HashMap<String, Type> result = new HashMap<>();

    result.put("DeclaredDebitedFunds", Money.class);
    result.put("DeclaredFees", Money.class);
    result.put("BankAccount", BankAccount.class);

    return result;
}
 
Example 4
Source Project: nifi-api-client-java   Source File: FlowApi.java    License: Apache License 2.0 5 votes vote down vote up
private com.squareup.okhttp.Call getPrioritizersCall(final ProgressResponseBody.ProgressListener progressListener, final ProgressRequestBody.ProgressRequestListener progressRequestListener) throws ApiException {
    Object localVarPostBody = null;
    

    // create path and map variables
    String localVarPath = "/flow/prioritizers".replaceAll("\\{format\\}","json");

    List<Pair> localVarQueryParams = new ArrayList<Pair>();

    Map<String, String> localVarHeaderParams = new HashMap<String, String>();

    Map<String, Object> localVarFormParams = new HashMap<String, Object>();

    final String[] localVarAccepts = {
        "application/json"
    };
    final String localVarAccept = apiClient.selectHeaderAccept(localVarAccepts);
    if (localVarAccept != null) localVarHeaderParams.put("Accept", localVarAccept);

    final String[] localVarContentTypes = {
        "*_/_*"
    };
    final String localVarContentType = apiClient.selectHeaderContentType(localVarContentTypes);
    localVarHeaderParams.put("Content-Type", localVarContentType);

    if(progressListener != null) {
        apiClient.getHttpClient().networkInterceptors().add(new com.squareup.okhttp.Interceptor() {
            @Override
            public com.squareup.okhttp.Response intercept(com.squareup.okhttp.Interceptor.Chain chain) throws IOException {
                com.squareup.okhttp.Response originalResponse = chain.proceed(chain.request());
                return originalResponse.newBuilder()
                .body(new ProgressResponseBody(originalResponse.body(), progressListener))
                .build();
            }
        });
    }

    String[] localVarAuthNames = new String[] {  };
    return apiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarAuthNames, progressRequestListener);
}
 
Example 5
Source Project: dubbox   Source File: ParseUtilsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testIsMatchGlobPatternsNeedInterpolate() throws Exception {
    Collection<String> patternsNeedInterpolate = new HashSet<String>();
    Map<String, String> interpolateParams = new HashMap<String, String>();
    
    boolean match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abc");
    assertFalse(match);
    
    patternsNeedInterpolate.add("abc*$var1");
    patternsNeedInterpolate.add("123${var2}*");
    
    interpolateParams.put("var1", "CAT");
    interpolateParams.put("var2", "DOG");
    
    match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abc");
    assertFalse(match);
    
    match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "abcXXXCAT");
    assertTrue(match);
    match = ParseUtils.isMatchGlobPatternsNeedInterpolate(patternsNeedInterpolate, interpolateParams, "123DOGYYY");
    assertTrue(match);
}
 
Example 6
Source Project: rocketmq-read   Source File: InnerLoggerFactory.java    License: Apache License 2.0 5 votes vote down vote up
private static void objectArrayAppend(StringBuilder sbuf, Object[] a, Map<Object[], Object> seenMap) {
    if (seenMap == null) {
        seenMap = new HashMap<Object[], Object>();
    }
    sbuf.append('[');
    if (!seenMap.containsKey(a)) {
        seenMap.put(a, null);
        int len = a.length;

        for (int i = 0; i < len; ++i) {
            deeplyAppendParameter(sbuf, a[i], seenMap);
            if (i != len - 1) {
                sbuf.append(", ");
            }
        }

        seenMap.remove(a);
    } else {
        sbuf.append("...");
    }

    sbuf.append(']');
}
 
Example 7
Source Project: sc-generator   Source File: VelocityUtil.java    License: Apache License 2.0 5 votes vote down vote up
public static String writerGeneratorConfig(String url, String username, String password, String driverClass,
		String packagePath, String targetPath, List<String> tables) throws IOException, SQLException {
	VelocityContext ctx = new VelocityContext();
	Template template = getTempate("templates/generatorConfig.vm");
	ctx.put("url", url);
	ctx.put("username", username);
	ctx.put("password", password);
	ctx.put("driverClass", driverClass);
	ctx.put("tables", tables);

	Map<String, String> primaryKeys = new HashMap<>();

	Connection connection = DriverManager.getConnection(url, username, password);
	for (String tableName : tables) {
		String primaryKey = TblUtil.getPrimaryKey(connection, tableName);
		String key = toHump(primaryKey);
		primaryKeys.put(tableName, key);
	}
	ctx.put("primaryKeys", primaryKeys);
	List<String> models = new ArrayList<String>();
	for (String table : tables) {
		String modelName = tableNameConvertModelName(table);
		models.add(modelName);
	}
	ctx.put("models", models);
	ctx.put("packagePath", packagePath);
	ctx.put("targetPath", targetPath);
	StringWriter writer = new StringWriter();
	template.merge(ctx, writer);
	writer.flush();
	writer.close();
	return writer.toString();
}
 
Example 8
/**
 * @throws java.lang.Exception
 */
@Before
public void setUp() throws Exception {
    bom = new BusinessObjectModel();
    final BusinessObject bo = new BusinessObject();
    bo.setQualifiedName("org.bonita.test.Employee");
    final SimpleField firstName = new SimpleField();
    firstName.setName("firstName");
    firstName.setType(FieldType.STRING);
    bo.getFields().add(firstName);
    bom.getBusinessObjects().add(bo);
    operationUnderTest = spy(new DeployBDMOperation(bdmFileStore));
    doReturn(bom).when(bdmFileStore).getContent();
    final Map<String, byte[]> result = new HashMap<>();
    result.put("bdm-client", new byte[512]);
    doReturn(false).when(operationUnderTest).dropDBOnInstall();
    when(manager.getTenantAdministrationAPI((APISession) anyObject())).thenReturn(tenantAdminAPI);
    doReturn(manager).when(operationUnderTest).getEngineManager();
    doNothing().when(operationUnderTest).uninstallBDMAccessControl(any(IProgressMonitor.class));
    doNothing().when(operationUnderTest).forceH2Drop();
    parentFolder = new File("test");
    parentFolder.mkdirs();
    doReturn(parentFolder).when(operationUnderTest).getTargetFolder();
}
 
Example 9
Source Project: medusa   Source File: MyGraph.java    License: GNU General Public License v3.0 5 votes vote down vote up
private boolean goodDegree(HashMap<MyNode, Integer> degrees) {
	boolean b = true;
	for (Entry<MyNode, Integer> entry : degrees.entrySet()) {
		if (entry.getValue() > 2) {
			b = false;
		}
	}
	return b;
}
 
Example 10
Source Project: dubbo-samples   Source File: UserServiceIT.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test() throws Exception {
    Map<String, String> map = new HashMap<>();
    map.put("id", "1");
    map.put("name", "Charles");
    Params params = new Params(map);
    User user = userService.get(params);
    Assert.assertEquals(1, user.getId());
    Assert.assertEquals("Charles", user.getName());
}
 
Example 11
Source Project: bce-sdk-java   Source File: QueryRequest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Return a string representation of the object.
 *
 * @return A string representation of the object.
 */
public String toString() {
    HashMap<String, Object> jsonObj = new HashMap<String, Object>();
    jsonObj.put(MolaDbConstants.JSON_TABLENAME, this.tableName);

    if (!this.attributesToGet.isEmpty()) {
        jsonObj.put(MolaDbConstants.JSON_ATTRIBUTES_TO_GET,
                this.attributesToGet);
    }
    if (null != this.exclusiveStartKey) {
        jsonObj.put(MolaDbConstants.JSON_EXCLUSIVE_START_KEY, this.exclusiveStartKey.toJsonObj());
    }
    if (this.consistentRead) {
        jsonObj.put(MolaDbConstants.JSON_CONSISTENT_READ, MolaDbConstants.JSON_TRUE);
    }

    if (this.limit > 0) {
        jsonObj.put(MolaDbConstants.JSON_LIMIT, Integer.toString(this.limit));
    }

    jsonObj.put(MolaDbConstants.JSON_KEY_CONDITION_EXPRESSION, this.keyConditionExpression);
    jsonObj.put(MolaDbConstants.JSON_EXPRESSION_ATTRIBUTEVALUES,
            this.attributeValueToJson(this.expressionAttributeValues));
    jsonObj.put(MolaDbConstants.JSON_ORDER, this.order);
    return JsonUtils.toJsonString(jsonObj);
}
 
Example 12
Source Project: Box   Source File: ResourceStorage.java    License: Apache License 2.0 5 votes vote down vote up
public Map<Integer, String> getResourcesNames() {
	Map<Integer, String> map = new HashMap<>();
	for (ResourceEntry entry : list) {
		map.put(entry.getId(), entry.getTypeName() + '/' + entry.getKeyName());
	}
	return map;
}
 
Example 13
Source Project: crate   Source File: UserPrivileges.java    License: Apache License 2.0 5 votes vote down vote up
UserPrivileges(Collection<Privilege> privileges) {
    privilegeByIdent = new HashMap<>(privileges.size());
    boolean anyClusterPrivilege = false;
    for (Privilege privilege : privileges) {
        PrivilegeIdent privilegeIdent = privilege.ident();
        privilegeByIdent.put(privilegeIdent, privilege);
        if (privilege.state() != Privilege.State.DENY) {
            switch (privilegeIdent.clazz()) {
                case CLUSTER:
                    anyClusterPrivilege = true;
                    break;
                case SCHEMA:
                    anySchemaPrivilege.add(privilegeIdent.ident());
                    break;
                case TABLE:
                    anyTablePrivilege.add(privilegeIdent.ident());
                    break;
                case VIEW:
                    anyViewPrivilege.add(privilegeIdent.ident());
                    break;
                default:
                    throw new IllegalStateException("Unsupported privilege class=" + privilegeIdent.clazz());
            }
        }
    }
    this.anyClusterPrivilege = anyClusterPrivilege;
}
 
Example 14
@Override
public Map<String, JPanel> getTabs() {
    try {
        return plugin.getTabs();
    } catch (RuntimeException e) {
        handleException(e);
    }
    return new HashMap<>();
}
 
Example 15
Source Project: xenon   Source File: ScriptingParserTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test03b_parseKeyValueLines_InputWithExtraSpaces_ResultMap() throws Exception {
    Map<String, String> expected = new HashMap<>();
    expected.put("key1", "value1");
    expected.put("key2", "value2");
    expected.put("key3", "value3");
    expected.put("key4", "value4");

    String input = "key1  =  value1\nkey2\t\t\t =   value2\n   key3 = value3  \n   key4   =value4    \n";

    Map<String, String> result = ScriptingParser.parseKeyValueLines(input, ScriptingParser.EQUALS_REGEX, "fake", "ignore this line");

    assertEquals("parser does not handle spaces in key/value input lines correctly", expected, result);
}
 
Example 16
Source Project: jwala   Source File: JvmStateReceiverAdapterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
@SuppressWarnings("unchecked")
public void testReceiveWithRuntimeException() throws Exception {
    final Identifier<Jvm> jvmId = new Identifier<>("1");
    Jvm jvm = new Jvm(jvmId, "jvm-name");

    final Map<Object, Object> serverInfoMap = new HashMap();
    serverInfoMap.put(JvmStateReceiverAdapter.NAME_KEY, jvm.getJvmName());
    serverInfoMap.put(JvmStateReceiverAdapter.STATE_KEY, LifecycleState.STOPPING);

    msg = new Message();
    msg.setObject(serverInfoMap);

    when (mockJvmPersistenceService.findJvmByExactName(jvm.getJvmName())).thenThrow(new NoResultException(""));

    jvmStateReceiverAdapter.receive(msg);
    verify(mockJvmStateService, never()).updateState(eq(jvm), eq(JvmState.JVM_STOPPING), eq(StringUtils.EMPTY));
}
 
Example 17
Source Project: AndroidWallet   Source File: CocosBcxApi.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * decrypt keyStore
 *
 * @param strPassword
 * @return privateKeys
 */
private Map<String, String> decrypt_keystore_callback_private_key(String strPassword) throws KeyInvalideException, AddressFormatException {

    assert (strPassword.length() > 0);
    sha512_object passwordHash = sha512_object.create_from_string(strPassword);
    byte[] byteKey = new byte[32];
    System.arraycopy(passwordHash.hash, 0, byteKey, 0, byteKey.length);
    byte[] ivBytes = new byte[16];
    System.arraycopy(passwordHash.hash, 32, ivBytes, 0, ivBytes.length);

    ByteBuffer byteDecrypt = aes.decrypt(byteKey, ivBytes, this.mWalletObject.cipher_keys.array());
    if (byteDecrypt == null || byteDecrypt.array().length == 0) {
        return new HashMap<>();
    }
    mCheckSum = passwordHash;
    plain_keys dataResult = plain_keys.from_input_stream(new ByteArrayInputStream(byteDecrypt.array()));
    Map<String, String> private_key = new HashMap();

    for (Map.Entry<types.public_key_type, String> entry : dataResult.keys.entrySet()) {
        types.private_key_type privateKeyType = new types.private_key_type(entry.getValue());
        mHashMapPub2Private.put(entry.getKey(), privateKeyType);
        private_key.put(entry.getKey().toString(), entry.getValue());
    }
    if (passwordHash.equals(dataResult.checksum)) {
        return private_key;
    } else {
        return new HashMap<>();
    }
}
 
Example 18
Source Project: sdn-rx   Source File: DefaultNeo4jConverter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void write(Object source, Map<String, Object> parameters) {
	Map<String, Object> properties = new HashMap<>();

	Neo4jPersistentEntity<?> nodeDescription =
		(Neo4jPersistentEntity<?>) nodeDescriptionStore.getNodeDescription(source.getClass());

	PersistentPropertyAccessor propertyAccessor = nodeDescription.getPropertyAccessor(source);
	nodeDescription.doWithProperties((Neo4jPersistentProperty p) -> {

		// Skip the internal properties, we don't want them to end up stored as properties
		if (p.isInternalIdProperty() || p.isDynamicLabels()) {
			return;
		}

		final Object value = writeValueFromProperty(propertyAccessor.getProperty(p), p.getTypeInformation());
		properties.put(p.getPropertyName(), value);
	});

	parameters.put(NAME_OF_PROPERTIES_PARAM, properties);

	// in case of relationship properties ignore internal id property
	if (nodeDescription.hasIdProperty()) {
		Neo4jPersistentProperty idProperty = nodeDescription.getRequiredIdProperty();
		parameters.put(NAME_OF_ID,
			writeValueFromProperty(propertyAccessor.getProperty(idProperty), idProperty.getTypeInformation()));
	}
	// in case of relationship properties ignore internal id property
	if (nodeDescription.hasVersionProperty()) {
		Long versionProperty = (Long) propertyAccessor.getProperty(nodeDescription.getRequiredVersionProperty());

		// we incremented this upfront the persist operation so the matching version would be one "before"
		parameters.put(NAME_OF_VERSION_PARAM, versionProperty - 1);
	}
}
 
Example 19
Source Project: fastods   Source File: StylesContainerImpl.java    License: GNU General Public License v3.0 5 votes vote down vote up
/**
 * Create a styles container
 *
 * @param logger the logger
 */
StylesContainerImpl(final Logger logger) {
    this.objectStylesContainer =
            new MultiContainer<String, Dest, ObjectStyle>(logger, Dest.class);
    this.dataStylesContainer = new MultiContainer<String, Dest, DataStyle>(logger, Dest.class);
    this.masterPageStylesContainer = new Container<String, MasterPageStyle>(logger);
    this.pageLayoutStylesContainer = new Container<String, PageLayoutStyle>(logger);
    this.anonymousStyleByChildCellStyle = new HashMap<ChildCellStyle, TableCellStyle>();
    this.fontFaces = new HashSet<FontFace>();
    this.fontFaces.add(DEFAULT_FONT_FACE);
}
 
Example 20
Source Project: iaf   Source File: ApiListenerServletTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void customExitCode() throws ServletException, IOException, ListenerException, ConfigurationException {
	addListener("exitcode", Methods.GET);

	Map<String, String> headers = new HashMap<String, String>();
	headers.put("Accept", "application/json");
	headers.put("content-type", "application/json");
	session = new HashMap<String, Object>();
	session.put("exitcode", "234");
	Response result = service(createRequest("exitcode", Methods.GET, null, headers));

	assertEquals(234, result.getStatus());
	assertEquals("OPTIONS, GET", result.getHeader("Allow"));
	assertNull(result.getErrorMessage());
}
 
Example 21
Source Project: dremio-oss   Source File: ParquetRecordReaderTest.java    License: Apache License 2.0 5 votes vote down vote up
private static void generateFile(String fileName, int numberRowGroups) throws Exception {
  final File f = new File(fileName);
  final ParquetTestProperties props =
      new ParquetTestProperties(numberRowGroups, recordsPerRowGroup, DEFAULT_BYTES_PER_PAGE, new HashMap<>());
  populateFieldInfoMap(props);
  if (!f.exists()) {
    TestFileGenerator.generateParquetFile(fileName, props);
  }
}
 
Example 22
/**
 * 将查出的数字与目标文本进行相关的比较
 * @param findNumber
 * @param targetText
 * @return
 */
public Map<String, List<String>> compareNumber(List<String> sourceNumbers, List<String> targetNumbers){
	Map<String, List<String>> resultMap  = new HashMap<String, List<String>>();
	List<String> resultList = new LinkedList<String>();
	//下面查看其目标数字集合中是否有源文本中的数字,如果有,则将这个数字从目标数字集合中删除
	int tarIndex;
	if (targetNumbers.size() == 0) {
		resultMap.put("source", sourceNumbers);
		return resultMap;
	}
	for (int index = 0; index < sourceNumbers.size(); index++) {
		String sourceNumber = sourceNumbers.get(index);
		
		if ((tarIndex = targetNumbers.indexOf(sourceNumber)) >= 0) {
			targetNumbers.remove(tarIndex);
		}else {
			resultList.add(sourceNumber);
		}
	}
	resultMap.put("source", resultList);
	if (targetNumbers.size() > 0) {
		resultMap.put("target", targetNumbers);
	}
	return resultMap;
}
 
Example 23
Source Project: nexus-public   Source File: MavenIndexPublisher.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns the records to publish of a hosted repository, the SELECT result count will be in parity with published
 * records count!
 */
private static Iterable<Record> getHostedRecords(final StorageTx tx, final Repository repository) throws IOException {
  Map<String, Object> sqlParams = new HashMap<>();
  sqlParams.put(P_BUCKET, AttachedEntityHelper.id(tx.findBucket(repository)));
  sqlParams.put(P_ASSET_KIND, AssetKind.ARTIFACT.name());
  return transform(
      tx.browse(SELECT_HOSTED_ARTIFACTS, sqlParams),
      (ODocument document) -> toRecord(repository.facet(MavenFacet.class), document)
  );
}
 
Example 24
Source Project: dal   Source File: DalConfigure.java    License: Apache License 2.0 5 votes vote down vote up
public void validate() throws Exception {
    Set<String> sqlServerSet = new HashSet<>();
    Map<String, Set<String>> connStrMap = new HashMap<>();
    for (DatabaseSet dbSet : databaseSets.values()) {
        IIdGeneratorConfig idGenConfig = dbSet.getIdGenConfig();
        if (null == idGenConfig) {
            continue;
        }
        String dbSetName = dbSet.getName();
        if (dbSet.getDatabaseCategory() == DatabaseCategory.SqlServer) {
            sqlServerSet.add(dbSetName);
            continue;
        }
        String sequenceDbName = idGenConfig.getSequenceDbName();
        Map<String, DataBase> dbs = dbSet.getDatabases();
        if (dbs != null) {
            for (DataBase db : dbs.values()) {
                String connStr = db.getConnectionString();
                Set<String> dbSetsForConnStr = connStrMap.get(connStr);
                if (dbSetsForConnStr != null) {
                    dbSetsForConnStr.add(sequenceDbName);
                } else {
                    dbSetsForConnStr = new HashSet<>();
                    dbSetsForConnStr.add(sequenceDbName);
                    connStrMap.put(connStr, dbSetsForConnStr);
                }
            }
        }
    }
    internalCheck(sqlServerSet, connStrMap);
}
 
Example 25
Source Project: zap-extensions   Source File: SOAPMsgConfigTestCase.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void changeParamTest() {
    /* Configuration. */
    HashMap<String, String> map = new HashMap<String, String>();
    map.put(KEY_PREFIX + KEY_NAME, KEY_VALUE);
    soapConfig.setParams(map);

    /* Checks that configuration has been processed correctly. */
    map = soapConfig.getParams();
    String value = map.get(KEY_PREFIX + KEY_NAME);
    assertTrue(value.equals(KEY_VALUE));

    /* Positive case. */
    soapConfig.changeParam(KEY_NAME, KEY_VALUE2);
    map = soapConfig.getParams();
    value = map.get(KEY_PREFIX + KEY_NAME);
    assertTrue(value.equals(KEY_VALUE2)); // Parameter value has been changed.

    /* Negative cases. */
    soapConfig.changeParam(KEY_NAME, null); // Null value.
    map = soapConfig.getParams();
    value = map.get(KEY_PREFIX + KEY_NAME);
    assertTrue(value.equals(KEY_VALUE2)); // Parameter value has NOT been changed.

    soapConfig.changeParam(null, KEY_VALUE); // Null key.
    map = soapConfig.getParams();
    value = map.get(KEY_PREFIX + KEY_NAME);
    assertTrue(value.equals(KEY_VALUE2)); // Parameter value has NOT been changed.
}
 
Example 26
public void saveOrUpdateLetterGradePercentMapping(final Map<String, Double> gradeMap, final Gradebook gradebook) {
	if(gradeMap == null) {
        throw new IllegalArgumentException("gradeMap is null in BaseHibernateManager.saveOrUpdateLetterGradePercentMapping");
    }

	final LetterGradePercentMapping lgpm = getLetterGradePercentMappingForGradebook(gradebook);

	if(lgpm == null) {
		final Set<String> keySet = gradeMap.keySet();

		if(keySet.size() != GradebookService.validLetterGrade.length) { //we only consider letter grade with -/+ now.
            throw new IllegalArgumentException("gradeMap doesn't have right size in BaseHibernateManager.saveOrUpdateLetterGradePercentMapping");
        }
		if(!validateLetterGradeMapping(gradeMap)) {
            throw new IllegalArgumentException("gradeMap contains invalid letter in BaseHibernateManager.saveOrUpdateLetterGradePercentMapping");
        }

		final HibernateCallback<Void> hcb = session -> {
            final LetterGradePercentMapping lgpm1 = new LetterGradePercentMapping();
            final Map<String, Double> saveMap = new HashMap<>(gradeMap);
            lgpm1.setGradeMap(saveMap);
            lgpm1.setGradebookId(gradebook.getId());
            lgpm1.setMappingType(2);
            session.save(lgpm1);
            return null;
        };
		getHibernateTemplate().execute(hcb);
	}
	else
	{
		udpateLetterGradePercentMapping(gradeMap, gradebook);
	}
}
 
Example 27
Source Project: Erdos   Source File: BFS.java    License: MIT License 5 votes vote down vote up
public BFS(IGraph graph_input, IVertex sourceIVertex)
{
    super(graph_input, "Breadth First Search");

    _sourceIVertex = sourceIVertex;
    _D            = new HashMap<>();
    _COLOR        = new HashMap<>();
    _PIE          = new LinkedHashMap<>();
    _Q            = new LinkedList<>();
}
 
Example 28
@Override
public ChangeActivityStateBuilder processVariable(String processVariableName, Object processVariableValue) {
    if (this.processVariables == null) {
        this.processVariables = new HashMap<>();
    }

    this.processVariables.put(processVariableName, processVariableValue);
    return this;
}
 
Example 29
Source Project: datawave   Source File: TLDEventDataFilterTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void keep_anyFieldTest() throws ParseException {
    Map<String,Integer> fieldLimits = new HashMap<>(1);
    fieldLimits.put(Constants.ANY_FIELD, 1);
    
    Set<String> blacklist = new HashSet<>();
    blacklist.add("field3");
    
    ASTJexlScript query = JexlASTHelper.parseJexlQuery("field2 == 'bar'");
    
    replayAll();
    
    // expected key structure
    Key key = new Key("row", "dataType" + Constants.NULL + "123.345.456", "field1" + Constants.NULL_BYTE_STRING + "value");
    filter = new TLDEventDataFilter(query, mockAttributeFactory, null, blacklist, 1, -1, fieldLimits, "LIMIT_FIELD", Collections.EMPTY_SET);
    
    assertTrue(filter.keep(key));
    // increments counts = 1
    assertTrue(filter.apply(new AbstractMap.SimpleEntry<>(key, null)));
    assertNull(filter.getSeekRange(key, key.followingKey(PartialKey.ROW), false));
    // does not increment counts so will still return true
    assertTrue(filter.keep(key));
    // increments counts = 2 so rejects based on field filter
    assertFalse(filter.apply(new AbstractMap.SimpleEntry<>(key, null)));
    Range seekRange = filter.getSeekRange(key, key.followingKey(PartialKey.ROW), false);
    assertNotNull(seekRange);
    assertEquals(seekRange.getStartKey().getRow(), key.getRow());
    assertEquals(seekRange.getStartKey().getColumnFamily(), key.getColumnFamily());
    assertEquals(seekRange.getStartKey().getColumnQualifier().toString(), "field1" + "\u0001");
    assertEquals(true, seekRange.isStartKeyInclusive());
    
    // now fails
    assertFalse(filter.keep(key));
    
    verifyAll();
}
 
Example 30
Source Project: mobemu   Source File: UPB.java    License: MIT License 5 votes vote down vote up
/**
 * Gets only the valid UPB 2012 trace users (i.e. those who actively
 * participated in the trace and had at least one interest). This function can
 * be modified depending on what is required.
 *
 * @return a map that correlates between the valid user's real ID from the trace
 *         and the newly-assigned one (since the IDs should be consecutive)
 */
private static Map<Integer, Integer> Upb2012GetValidUsers() {
	Map<Integer, Integer> users = new HashMap<>(); // real id / new id

	users.put(0, 0);
	users.put(12, 1);
	users.put(22, 2);
	users.put(14, 3);
	users.put(5, 4);
	users.put(32, 5);
	users.put(7, 6);
	users.put(30, 7);
	users.put(34, 8);
	users.put(31, 9);
	users.put(55, 10);
	users.put(52, 11);
	users.put(33, 12);
	users.put(43, 13);
	users.put(4, 14);
	users.put(15, 15);
	users.put(26, 16);
	users.put(20, 17);
	users.put(29, 18);
	users.put(40, 19);
	users.put(6, 20);
	users.put(45, 21);
	users.put(48, 22);
	users.put(61, 23);

	return users;
}