List of usage examples for java.lang Long longValue
@HotSpotIntrinsicCandidate public long longValue()
From source file:eu.optimis.ecoefficiencytool.core.ProactiveService.java
public ProactiveService(EcoEffAssessorSP assessor, String serviceId, /*List<Integer> historic,*/ Long timeout) { PropertiesConfiguration configEco = ConfigManager.getPropertiesConfiguration(ConfigManager.ECO_CONFIG_FILE); this.assessorSP = assessor; this.serviceId = serviceId; //this.historic = historic; if (timeout != null) { this.timeout = timeout.longValue(); } else {// w w w. j a v a 2 s. co m this.timeout = configEco.getLong("samplingPeriod"); } }
From source file:com.couchbase.trombi.controllers.CoworkerController.java
@RequestMapping(value = "/", method = RequestMethod.POST) public ResponseEntity<?> createCoworker(@RequestBody Map<String, Object> body) { String name;/* w w w . j a v a2s.c o m*/ String description; String team; Set<String> skills = new HashSet<>(); Map<String, String> imHandles; Location mainLocation; try { if (body.containsKey("skills")) { skills.addAll((Collection<String>) body.get("skills")); } imHandles = (Map<String, String>) body.get("imHandles"); Map<String, Object> mainLocationMap = (Map<String, Object>) body.get("mainLocation"); Map<String, Object> mainLocationCoord = (Map<String, Object>) mainLocationMap.get("coordinates"); double x = ((Number) mainLocationCoord.get("x")).doubleValue(); double y = ((Number) mainLocationCoord.get("y")).doubleValue(); mainLocation = new Location((String) mainLocationMap.get("name"), (String) mainLocationMap.get("description"), (int) mainLocationMap.get("timeZoneOffset"), new Point(x, y)); name = (String) body.get("name"); description = (String) body.get("description"); team = (String) body.get("team"); } catch (Exception e) { return ResponseEntity.badRequest().body("Malformed Coworker creation data, error: " + e.toString()); } //generate an ID Long sequence = bucket.counter("coworkerSequence", 1, TrombinoscopeApplication.RESERVED_IDS + 1).content(); String id = CoworkerRepository.PREFIX + sequence.longValue(); Coworker coworker = new Coworker(id, name, description, team, skills, imHandles, mainLocation, null); repository.save(coworker); final URI location = ServletUriComponentsBuilder.fromCurrentServletMapping().path("/{id}").build() .expand(id).toUri(); return ResponseEntity.created(location).body(coworker); }
From source file:it.grid.storm.namespace.util.userinfo.UserInfoCommand.java
/** * Extracts from the received string (with at least 3 fields separated by ":" * ) the GID value as a long/* ww w . j a va 2 s. co m*/ * * @param line * @return */ private int getGroupId(String line) throws UserInfoException { int gidInt = -1; String[] fields = getElements(line); if ((fields != null) && (fields.length > 2) && (fields[2] != null)) { log.trace("field[2], GID ='" + fields[2] + "'"); try { Long groupLong = new Long(Long.parseLong(fields[2])); if (groupLong.intValue() == groupLong.longValue()) { // The number in the output string fits in an integer (is at most 16 // bits) gidInt = groupLong.intValue(); } else { // The number in the output string does not fits in an integer (is // between 17 and 32 bits) log.warn("Group named '" + fields[2] + "' has a 32 bit GID " + groupLong.longValue() + " . Long GID are not managed by LCMAPS. Ignoring the group"); } } catch (NumberFormatException nfe) { log.error("Group named '" + fields[2] + "' return a result different from a long. NumberFormatException : " + nfe); throw new UserInfoException("Group named '" + fields[2] + "' return a result different from a long. NumberFormatException : " + nfe); } } return gidInt; }
From source file:de.hybris.platform.order.impl.DefaultCartService.java
@Override public void updateQuantities(final CartModel cart, final Map<Integer, Long> quantities) { if (cart == null) { throw new IllegalArgumentException("cart cannot be null"); }/*from w w w .j a va2 s. c om*/ if (!MapUtils.isEmpty(quantities)) { final Collection<CartEntryModel> toRemove = new LinkedList<CartEntryModel>(); final Collection<CartEntryModel> toSave = new LinkedList<CartEntryModel>(); for (final Map.Entry<CartEntryModel, Long> e : getEntryQuantityMap(cart, quantities).entrySet()) { final CartEntryModel cartEntry = e.getKey(); final Long quantity = e.getValue(); if (quantity == null || quantity.longValue() < 1) { toRemove.add(cartEntry); } else { cartEntry.setQuantity(quantity); toSave.add(cartEntry); } } getModelService().removeAll(toRemove); getModelService().saveAll(toSave); getModelService().refresh(cart); } }
From source file:de.hybris.platform.order.impl.DefaultCartService.java
@SuppressWarnings("deprecation") @Deprecated// ww w .j a v a2s .c o m @Override public void updateQuantities(final CartModel cart, final List<Long> quantities) { if (cart == null) { throw new IllegalArgumentException("cart was null"); } final List<AbstractOrderEntryModel> entries = cart.getEntries(); if (entries.size() < quantities.size()) { throw new IllegalArgumentException( "got less entries than quantities (" + entries.size() + " < " + quantities.size() + ")"); } int pos = 0; for (final AbstractOrderEntryModel entry : entries) { final Long value = quantities.get(pos++); if (value == null || value.longValue() < 1) { getModelService().remove(entry); } else { entry.setQuantity(value); getModelService().save(entry); } } }
From source file:it.grid.storm.namespace.util.userinfo.UserInfoCommand.java
/** * /*from ww w. j a v a2 s . co m*/ * @param parameters * @return * @throws UserInfoException */ public int retrieveGroupID(UserInfoParameters parameters) throws UserInfoException { int groupId = -1; String[] command = buildCommandString(parameters); StringBuffer commandOutput = new StringBuffer(); for (String element : command) { commandOutput.append(element).append(" "); log.debug("UserInfo Command INPUT String : " + commandOutput.toString()); } String output = getOutput(command); if ((output != null) && (output.length() > 0)) { try { Long groupLong = new Long(Long.parseLong(output)); if (groupLong.intValue() == groupLong.longValue()) { // The number in the output string fits in an integer (is at most 16 // bits) groupId = groupLong.intValue(); } else { // The number in the output string does not fits in an integer (is // between 17 and 32 bits) log.warn("Group named '" + parameters + "' has a 32 bit GID " + groupLong.longValue() + " . Long GID are not managed by LCMAPS. Ignoring the group"); } } catch (NumberFormatException nfe) { log.error("Group named '" + parameters + "' return a result different from a long. NumberFormatException : " + nfe); throw new UserInfoException("Group named '" + parameters + "' return a result different from a long. NumberFormatException : " + nfe); } } else { throw new UserInfoException( "Group named '" + parameters + "' return a result different from a integer"); } return groupId; }
From source file:com.eviware.soapui.impl.wsdl.loadtest.assertions.AbstractLoadTestAssertion.java
protected String returnErrorOrFail(String message, int maxErrors, LoadTestRunner testRunner, LoadTestRunContext context) {// ww w. j ava 2 s . c o m String propertyKey = getClass().getName() + hashCode(); Long errorCount = (Long) context.getProperty(propertyKey); if (errorCount == null) { errorCount = 1L; } else { errorCount = new Long(errorCount.longValue() + 1); } if (maxErrors >= 0 && errorCount >= maxErrors) { testRunner.fail( "Maximum number of errors [" + maxErrors + "] for assertion [" + getName() + "] exceeded"); } context.setProperty(propertyKey, errorCount); return message; }
From source file:ch.usi.da.paxos.ring.LearnerRole.java
@Override public void setSafeInstance(Integer ring, Long instance) { if (instance <= delivered_instance) { safe_instance = instance.longValue(); } else {//from w ww . j a v a 2s . c o m logger.error("Learner setSafeInstance() for not delivered instance number?!"); } }
From source file:com.redhat.rhn.domain.kickstart.test.KickstartableTreeTest.java
/** * Helper method to lookup KickstartableTree by id * @param id Id to lookup/* www.j a va 2 s.co m*/ * @return Returns the KickstartableTree * @throws Exception */ private KickstartableTree lookupById(Long id) throws Exception { Session session = HibernateFactory.getSession(); return (KickstartableTree) session.getNamedQuery("KickstartableTree.findById").setLong("id", id.longValue()) .uniqueResult(); }
From source file:org.horizontaldb.integration.InterceptorMockEnvironmentTest.java
@Test public void shouldValidateOneLevelShardedCall() throws SQLException { ConversationRegistry mockRegistry = EasyMock.createMock(ConversationRegistry.class); TenantContext mockTenantContext = EasyMock.createMock(TenantContext.class); org.apache.tomcat.jdbc.pool.DataSource mockDataSource = EasyMock .createMock(org.apache.tomcat.jdbc.pool.DataSource.class); DataSourceResource mockDataSourceResource = new DataSourceResource(mockDataSource); ShardBeanResolver mockShardBeanResolver = EasyMock.createMock(ShardBeanResolver.class); ShardBeanEnricher mockShardBeanEnricher = EasyMock.createMock(ShardBeanEnricher.class); Connection mockConnection = EasyMock.createMock(Connection.class); PreparedStatement mockStatement = EasyMock.createMock(PreparedStatement.class); ResultSet mockResultset = EasyMock.createMock(ResultSet.class); conversationRegistryMockProxy.setMockRegistry(mockRegistry); tenantContextMockProxy.setMockTenantContext(mockTenantContext); dataSourceFactoryMockProxy.setMockDataSourceResource(mockDataSourceResource); shardBeanResolverMockProxy.setMockResolver(mockShardBeanResolver); shardBeanEnricherMockProxy.setMockEnricher(mockShardBeanEnricher); // This is the protocol that the interceptors should follow during a sharded call mockRegistry.startConversation(testUserHelper.getJoeToken()); expect(mockRegistry.hasConversation(TestUser.JOE.name())).andReturn(true); expect(mockTenantContext.resolveCurrentTenantIdentifier()).andReturn(TestUser.JOE.name()); mockRegistry.addResource(TestUser.JOE.name(), mockDataSourceResource); mockRegistry.addResource(same(TestUser.JOE.name()), anyObject(DepartmentDaoImpl.class)); expect(mockShardBeanResolver.getBean(same(DepartmentDao.class), anyObject(ShardContext.class))) .andReturn(null);/* www . java2s .c om*/ mockShardBeanEnricher.setup(anyObject(DepartmentDaoImpl.class), anyObject(ShardContext.class)); mockShardBeanEnricher.tearDown(anyObject(DepartmentDaoImpl.class), anyObject(ShardContext.class)); mockDataSource.close(true); mockRegistry.teardownConversation(testUserHelper.getJoeToken()); // end protocol // This is the flow of a Hibernate transaction which is irrelevant, but had to be defined because of the // mocked dataSource. expect(mockDataSource.getConnection()).andReturn(mockConnection); mockConnection.setReadOnly(true); expect(mockConnection.getAutoCommit()).andReturn(false); expect(mockConnection.prepareStatement(anyObject(String.class))).andReturn(mockStatement); expect(mockStatement.executeQuery()).andReturn(mockResultset); expect(mockStatement.getWarnings()).andReturn(null); mockStatement.clearWarnings(); expect(mockStatement.getMaxRows()).andReturn(0); expect(mockStatement.getQueryTimeout()).andReturn(0); expect(mockResultset.next()).andReturn(true); expect(mockResultset.next()).andReturn(false); expect(mockResultset.getLong(anyObject(String.class))).andReturn(0l); expect(mockResultset.wasNull()).andReturn(false); mockResultset.close(); mockStatement.close(); mockConnection.commit(); // end Hibernate transaction replay(mockRegistry, mockTenantContext, mockShardBeanResolver, mockShardBeanEnricher, mockDataSource, mockConnection, mockStatement, mockResultset); try { ShardContext context = new ShardContext(TestUser.JOE.name()); testService.authenticate(testUserHelper.getJoeToken()); Long actualCount = testService.getCountOfDepartments(context); assertEquals(0, actualCount.longValue()); } finally { testService.logoff(testUserHelper.getJoeToken()); } verify(mockRegistry, mockTenantContext, mockShardBeanResolver, mockShardBeanEnricher, mockDataSource, mockConnection, mockStatement, mockResultset); }