id
stringlengths
7
14
text
stringlengths
1
106k
1072630_1
;
1072630_2
public <T> Iterable<T> mapPaths(final Iterable<Path> paths, final PathMapper<T> pathMapper) { assert paths != null; assert pathMapper != null; IterationController.IterationMode mode = getIterationControl(pathMapper); switch (mode) { case EAGER: case EAGER_STOP_ON_NULL: List<T> result = new ArrayList<T>(); try { for (Path path : paths) { T mapped = pathMapper.mapPath(path); if (mapped == null && mode == IterationController.IterationMode.EAGER_STOP_ON_NULL) break; result.add(mapped); } } finally { close(paths); } return result; case EAGER_IGNORE_RESULTS: try { for (Path path : paths) { pathMapper.mapPath(path); } } finally { close(paths); } return null; case LAZY: return new IterableWrapper<T, Path>(paths) { @Override protected T underlyingObjectToObject(Path path) { return pathMapper.mapPath(path); } }; default: throw new IllegalStateException("Unknown IterationControl " + mode); } }
1072630_3
public <T> Iterable<T> mapPaths(final Iterable<Path> paths, final PathMapper<T> pathMapper) { assert paths != null; assert pathMapper != null; IterationController.IterationMode mode = getIterationControl(pathMapper); switch (mode) { case EAGER: case EAGER_STOP_ON_NULL: List<T> result = new ArrayList<T>(); try { for (Path path : paths) { T mapped = pathMapper.mapPath(path); if (mapped == null && mode == IterationController.IterationMode.EAGER_STOP_ON_NULL) break; result.add(mapped); } } finally { close(paths); } return result; case EAGER_IGNORE_RESULTS: try { for (Path path : paths) { pathMapper.mapPath(path); } } finally { close(paths); } return null; case LAZY: return new IterableWrapper<T, Path>(paths) { @Override protected T underlyingObjectToObject(Path path) { return pathMapper.mapPath(path); } }; default: throw new IllegalStateException("Unknown IterationControl " + mode); } }
1076094_0
public IncomingMessageFormDefinition getByCode(String formCode) { logger.debug("variable passed to getByCode: " + formCode); try { Criterion code = Restrictions.eq("formCode", formCode); IncomingMessageFormDefinition definition = (IncomingMessageFormDefinition)this.getSessionFactory().getCurrentSession().createCriteria(this.getPersistentClass()) .add(code) .setMaxResults(1) .uniqueResult(); logger.debug(definition); return definition; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in getByCode", he); return null; } catch (Exception ex) { logger.error("Exception in getByCode", ex); return null; } }
1076094_1
public static Long generateID(int length) { logger.info("Calling generateID with specify length"); Long result = null; if (length > 0) { StringBuilder id = new StringBuilder(length); for (int i = 0; i < length; i++) { id.append(NUMS[(int) Math.floor(Math.random() * 20)]); } result = Long.parseLong(id.toString()); } return result; }
1076094_2
public GatewayResponse getMostRecentResponseByMessageId(Long messageId) { logger.debug("variable passed to getMostRecentResponseByRequestId: " + messageId); try { GatewayResponse response = null; String query = "from GatewayResponseImpl g where g.gatewayRequest.messageRequest.id = :reqId and g.gatewayRequest.messageStatus != 'PENDING' and g.gatewayRequest.messageStatus != 'PROCESSING' "; List responses = this.getSessionFactory().getCurrentSession().createQuery(query).setParameter("reqId", messageId).list(); logger.debug(responses); return responses != null && responses.size() > 0 ? (GatewayResponse) responses.get(0) : null; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in getMostRecentResponseByRequestId", he); return null; } catch (Exception ex) { logger.error("Exception in getMostRecentResponseByRequestId", ex); return new GatewayResponseImpl(); } }
1076094_3
public List<GatewayRequest> getByStatusAndSchedule(MStatus status, Date schedule) { logger.debug("variables passed to getByStatusAndSchedule. status: " + status + "And schedule: " + schedule); try { List<GatewayRequest> allbystatandSdule; Criteria criteria = this.getSessionFactory().getCurrentSession().createCriteria(getPersistentClass()); if (schedule == null) { criteria = criteria.add(Restrictions.isNull("dateTo")).add(Restrictions.isNull("dateFrom")).add(Restrictions.eq("messageStatus", status)); } else { criteria = criteria.add(Restrictions.eq("messageStatus", status)).add(Restrictions.or(Restrictions.isNull("dateFrom"),Restrictions.lt("dateFrom", schedule))).add(Restrictions.or(Restrictions.isNull("dateTo"),Restrictions.gt("dateTo", schedule))); } allbystatandSdule = (List<GatewayRequest>) criteria.add(Restrictions.isNotNull("gatewayRequestDetails")).list(); logger.debug(allbystatandSdule); return allbystatandSdule; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in Method getByStatusAndSchedule", he); return null; } catch (Exception ex) { logger.error("Exception in Method getByStatusAndSchedule", ex); return null; } }
1076094_4
public Language getByCode(String code) { logger.debug("variable passed to getByCode: " + code); try { Language lang = (Language) this.getSessionFactory().getCurrentSession().createCriteria(LanguageImpl.class).add(Restrictions.eq("code", code)).uniqueResult(); logger.debug(lang); return lang; } catch (NonUniqueResultException ne) { logger.error("getByCode returned more than one object", ne); return null; } catch (HibernateException he) { logger.error("Persistence or jdbc Exception in Method getByCode", he); return null; } catch (Exception e) { logger.error("Exception in getByCode", e); return null; } }
1076094_5
public Language getByCode(String code) { logger.debug("variable passed to getByCode: " + code); try { Language lang = (Language) this.getSessionFactory().getCurrentSession().createCriteria(LanguageImpl.class).add(Restrictions.eq("code", code)).uniqueResult(); logger.debug(lang); return lang; } catch (NonUniqueResultException ne) { logger.error("getByCode returned more than one object", ne); return null; } catch (HibernateException he) { logger.error("Persistence or jdbc Exception in Method getByCode", he); return null; } catch (Exception e) { logger.error("Exception in getByCode", e); return null; } }
1076094_6
public MessageTemplate getTemplateByLangNotifMType(Language lang, NotificationType notif, MessageType type) { logger.debug("variables passed to getTemplateByLangNotifMType. language: " + lang + "And NotificationType: " + notif + "And MessageType: " + type); try { MessageTemplate template = (MessageTemplate) this.getSessionFactory().getCurrentSession().createCriteria(MessageTemplateImpl.class).add(Restrictions.eq("language", lang)).add(Restrictions.eq("notificationType", notif)).add(Restrictions.eq("messageType", type)).uniqueResult(); logger.debug(template); return template; } catch (NonUniqueResultException ne) { logger.error("Method getTemplateByLangNotifMType returned more than one MessageTemplate object", ne); return null; } catch (HibernateException he) { logger.error(" Persistence or JDBC Exception in Method getTemplateByLangNotifMType", he); return null; } catch (Exception ex) { logger.error("Exception in Method getTemplateByLangNotifMType", ex); return null; } }
1076094_7
public IMPService createIMPService(){ return (IMPService)context.getBean("impService"); }
1076094_8
public IncomingMessageParser createIncomingMessageParser(){ return (IncomingMessageParser)context.getBean("imParser"); }
1076094_9
public IncomingMessageFormValidator createIncomingMessageFormValidator(){ return (IncomingMessageFormValidator)context.getBean("imFormValidator"); }
1076159_0
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_1
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_2
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_3
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_4
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_5
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_6
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_7
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_8
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076159_9
public static <T> Instantiator<T> createInstantiator( Class<T> klass, InstantiatorModule... modules) { Errors errors = new Errors(); for (Instantiator<T> instantiator : createInstantiator(errors, klass, modules)) { return instantiator; } errors.throwIfHasErrors(); // The following program should not be reachable since the factory should // produce errors if it is unable to create an instantiator. throw new IllegalStateException(); }
1076632_0
public User newUser(WebStaff webStaff) { User user = new User(); user.setSystemId(identifierGenerator.generateStaffId()); user.setGender(MotechConstants.GENDER_UNKNOWN_OPENMRS); PersonName name = new PersonName(webStaff.getFirstName(), null, webStaff.getLastName()); user.addName(name); String phoneValue = webStaff.getPhone() == null ? "" : webStaff.getPhone(); String typeValue = webStaff.getType() == null ? "" : webStaff.getType(); createPhoneNumber(user, phoneValue); createType(user, typeValue); Role role = userService.getRole(OpenmrsConstants.PROVIDER_ROLE); user.addRole(role); return user; }
1076632_1
public MotechUserTypes userTypes() { return motechUsers.types(); }
1076632_2
@Override public void execute() { long start = System.currentTimeMillis(); log.info("Message Program Task - Update Enrolled Programs for all Patients"); Integer batchSize = null; String batchSizeProperty = taskDefinition.getProperty(MotechConstants.TASK_PROPERTY_BATCH_SIZE); if (batchSizeProperty != null) { try { batchSize = Integer.valueOf(batchSizeProperty); } catch (NumberFormatException e) { log.error("Invalid Integer batch size value", e); } } Long batchPreviousId = null; String batchPreviousProperty = taskDefinition.getProperty(MotechConstants.TASK_PROPERTY_BATCH_PREVIOUS_ID); if (batchPreviousProperty != null) { try { batchPreviousId = Long.valueOf(batchPreviousProperty); } catch (NumberFormatException e) { log.error("Invalid Long batch previous id value", e); } } // Session required for Task to get RegistrarBean through Context try { contextService.openSession(); TaskDefinition updatedTask = contextService.getRegistrarBean() .updateAllMessageProgramsState(batchSize, batchPreviousId); if (updatedTask != null) { // Updates this running task to use newly stored properties this.initialize(updatedTask); } } finally { contextService.closeSession(); } long end = System.currentTimeMillis(); long runtime = (end - start) / 1000; log.info("executed for " + runtime + " seconds"); }
1076632_3
@Override public void execute() { long start = System.currentTimeMillis(); log.info("executing task"); String timeOffsetString = this.taskDefinition .getProperty(MotechConstants.TASK_PROPERTY_TIME_OFFSET); Boolean sendImmediate = Boolean.valueOf(taskDefinition .getProperty(MotechConstants.TASK_PROPERTY_SEND_IMMEDIATE)); Long timeOffset = 0L; if (timeOffsetString != null) { timeOffset = Long.valueOf(timeOffsetString); } Date startDate = new Date(System.currentTimeMillis() + (timeOffset * 1000)); Date endDate = new Date(System.currentTimeMillis() + (this.taskDefinition.getRepeatInterval() * 1000) + (timeOffset * 1000)); // Session required for Task to get RegistrarBean through Context try { contextService.openSession(); contextService.getRegistrarBean().sendMessages(startDate, endDate, sendImmediate); } finally { contextService.closeSession(); } long end = System.currentTimeMillis(); long runtime = (end - start) / 1000; log.info("executed for " + runtime + " seconds"); }
1076632_4
public Patient build() { if (registrantType == RegistrantType.CHILD_UNDER_FIVE) { return buildChild(); } else { return buildPatient(); } }
1076632_5
public List<Patient> getAllDuplicatePatients() { return motechDAO.getAllDuplicatePatients(); }
1076632_6
public Facility facilityFor(Patient patient) { return motechDAO.facilityFor(patient); }
1076632_7
public MotechConfiguration getConfigurationFor(String name) { return motechDAO.getConfiguration(name); }
1076632_8
public DefaultedExpectedEncounterAlert getDefaultedEncounterAlertFor(ExpectedEncounter expectedEncounter) { return motechDAO.getDefaultedEncounterAlertFor(expectedEncounter); }
1076632_9
public DefaultedExpectedObsAlert getDefaultedObsAlertFor(ExpectedObs expectedObs) { return motechDAO.getDefaultedObsAlertFor(expectedObs); }
1077753_0
public static List<String> statementsFrom(Reader reader) throws IOException { SQLFile file = new SQLFile(); file.parse(reader); return file.getStatements(); }
1077753_1
public static List<String> statementsFrom(Reader reader) throws IOException { SQLFile file = new SQLFile(); file.parse(reader); return file.getStatements(); }
1079636_0
public static boolean isClassAccessChange(final int oldAccess, final int newAccess) { if ( not(oldAccess, Opcodes.ACC_ABSTRACT) && has(newAccess, Opcodes.ACC_ABSTRACT) ) { return true; // 13.4.1 #1 } else if ( not(oldAccess, Opcodes.ACC_FINAL) && has(newAccess, Opcodes.ACC_FINAL) ) { return true; // 13.4.2 #1 } else { final int compatibleChanges = Opcodes.ACC_ABSTRACT | // 13.4.1 #2 Opcodes.ACC_FINAL ; // 13.4.2 #2 // FIXME Opcodes.ACC_VOLATILE ? final int oldAccess2 = oldAccess & ~compatibleChanges; final int newAccess2 = newAccess & ~compatibleChanges; return oldAccess2 != newAccess2; } }
1079636_1
public static boolean isFieldAccessChange(final int oldAccess, final int newAccess) { if (isAccessIncompatible(oldAccess, newAccess)) { return true; // 13.4.7 } if ( not(oldAccess, Opcodes.ACC_FINAL) && has(newAccess, Opcodes.ACC_FINAL) ) { return true; // 13.4.9 #1 } else { final int compatibleChanges = Opcodes.ACC_FINAL | // 13.4.9 #2 Opcodes.ACC_TRANSIENT; // 13.4.11 #1 final int accessPermissions = Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE; final int oldAccess2 = oldAccess & ~compatibleChanges & ~accessPermissions; final int newAccess2 = newAccess & ~compatibleChanges & ~accessPermissions; return oldAccess2 != newAccess2; } }
1079636_2
public static boolean isMethodAccessChange(final int oldAccess, final int newAccess) { if (isAccessIncompatible(oldAccess, newAccess)) { return true; // 13.4.7 } if ( not(oldAccess, Opcodes.ACC_ABSTRACT) && has(newAccess, Opcodes.ACC_ABSTRACT) ) { return true; // 13.4.16 #2 } else if ( not(oldAccess, Opcodes.ACC_FINAL) && not(oldAccess, Opcodes.ACC_STATIC) && has(newAccess, Opcodes.ACC_FINAL) ) { return true; // 13.4.17 #2 excluding and #3 } else { final int compatibleChanges = Opcodes.ACC_ABSTRACT | // 13.4.16 #1 Opcodes.ACC_FINAL | // 13.4.17 #1 Opcodes.ACC_NATIVE | // 13.4.18 #1 Opcodes.ACC_SYNCHRONIZED; // 13.4.20 #1 final int accessPermissions = Opcodes.ACC_PUBLIC | Opcodes.ACC_PROTECTED | Opcodes.ACC_PRIVATE; final int oldAccess2 = oldAccess & ~compatibleChanges & ~accessPermissions; final int newAccess2 = newAccess & ~compatibleChanges & ~accessPermissions; return oldAccess2 != newAccess2; } }
1079636_3
protected boolean isClassConsidered( final String className ) { // Fix case where class names are reported with '.' final String fixedClassName = className.replace('.', '/'); for ( String exclude : this.excludes ) { final Pattern excludePattern; if( !excludesAreRegExp ) { if ( exclude.contains( "/**/" ) ) { exclude = exclude.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( exclude.contains( "/*/" ) ) { exclude = exclude.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } excludePattern = simplifyRegularExpression( exclude, false ); } else { excludePattern = Pattern.compile( exclude ); } final Matcher excludeMatcher = excludePattern.matcher( fixedClassName ); while ( excludeMatcher.find() ) { return false; } } if ( !this.includes.isEmpty() ) { for ( String include : this.includes ) { final Pattern includePattern; if( !includesAreRegExp ) { if ( include.contains( "/**/" ) ) { include = include.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( include.contains( "/*/" ) ) { include = include.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } includePattern = simplifyRegularExpression( include, false ); } else { includePattern = Pattern.compile( include ); } final Matcher includeMatcher = includePattern.matcher( fixedClassName ); while ( includeMatcher.find() ) { return true; } } return false; } return true; }
1079636_4
protected boolean isClassConsidered( final String className ) { // Fix case where class names are reported with '.' final String fixedClassName = className.replace('.', '/'); for ( String exclude : this.excludes ) { final Pattern excludePattern; if( !excludesAreRegExp ) { if ( exclude.contains( "/**/" ) ) { exclude = exclude.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( exclude.contains( "/*/" ) ) { exclude = exclude.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } excludePattern = simplifyRegularExpression( exclude, false ); } else { excludePattern = Pattern.compile( exclude ); } final Matcher excludeMatcher = excludePattern.matcher( fixedClassName ); while ( excludeMatcher.find() ) { return false; } } if ( !this.includes.isEmpty() ) { for ( String include : this.includes ) { final Pattern includePattern; if( !includesAreRegExp ) { if ( include.contains( "/**/" ) ) { include = include.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( include.contains( "/*/" ) ) { include = include.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } includePattern = simplifyRegularExpression( include, false ); } else { includePattern = Pattern.compile( include ); } final Matcher includeMatcher = includePattern.matcher( fixedClassName ); while ( includeMatcher.find() ) { return true; } } return false; } return true; }
1079636_5
protected boolean isClassConsidered( final String className ) { // Fix case where class names are reported with '.' final String fixedClassName = className.replace('.', '/'); for ( String exclude : this.excludes ) { final Pattern excludePattern; if( !excludesAreRegExp ) { if ( exclude.contains( "/**/" ) ) { exclude = exclude.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( exclude.contains( "/*/" ) ) { exclude = exclude.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } excludePattern = simplifyRegularExpression( exclude, false ); } else { excludePattern = Pattern.compile( exclude ); } final Matcher excludeMatcher = excludePattern.matcher( fixedClassName ); while ( excludeMatcher.find() ) { return false; } } if ( !this.includes.isEmpty() ) { for ( String include : this.includes ) { final Pattern includePattern; if( !includesAreRegExp ) { if ( include.contains( "/**/" ) ) { include = include.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( include.contains( "/*/" ) ) { include = include.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } includePattern = simplifyRegularExpression( include, false ); } else { includePattern = Pattern.compile( include ); } final Matcher includeMatcher = includePattern.matcher( fixedClassName ); while ( includeMatcher.find() ) { return true; } } return false; } return true; }
1079636_6
protected boolean isClassConsidered( final String className ) { // Fix case where class names are reported with '.' final String fixedClassName = className.replace('.', '/'); for ( String exclude : this.excludes ) { final Pattern excludePattern; if( !excludesAreRegExp ) { if ( exclude.contains( "/**/" ) ) { exclude = exclude.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( exclude.contains( "/*/" ) ) { exclude = exclude.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } excludePattern = simplifyRegularExpression( exclude, false ); } else { excludePattern = Pattern.compile( exclude ); } final Matcher excludeMatcher = excludePattern.matcher( fixedClassName ); while ( excludeMatcher.find() ) { return false; } } if ( !this.includes.isEmpty() ) { for ( String include : this.includes ) { final Pattern includePattern; if( !includesAreRegExp ) { if ( include.contains( "/**/" ) ) { include = include.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( include.contains( "/*/" ) ) { include = include.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } includePattern = simplifyRegularExpression( include, false ); } else { includePattern = Pattern.compile( include ); } final Matcher includeMatcher = includePattern.matcher( fixedClassName ); while ( includeMatcher.find() ) { return true; } } return false; } return true; }
1079636_7
protected boolean isClassConsidered( final String className ) { // Fix case where class names are reported with '.' final String fixedClassName = className.replace('.', '/'); for ( String exclude : this.excludes ) { final Pattern excludePattern; if( !excludesAreRegExp ) { if ( exclude.contains( "/**/" ) ) { exclude = exclude.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( exclude.contains( "/*/" ) ) { exclude = exclude.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } excludePattern = simplifyRegularExpression( exclude, false ); } else { excludePattern = Pattern.compile( exclude ); } final Matcher excludeMatcher = excludePattern.matcher( fixedClassName ); while ( excludeMatcher.find() ) { return false; } } if ( !this.includes.isEmpty() ) { for ( String include : this.includes ) { final Pattern includePattern; if( !includesAreRegExp ) { if ( include.contains( "/**/" ) ) { include = include.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( include.contains( "/*/" ) ) { include = include.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } includePattern = simplifyRegularExpression( include, false ); } else { includePattern = Pattern.compile( include ); } final Matcher includeMatcher = includePattern.matcher( fixedClassName ); while ( includeMatcher.find() ) { return true; } } return false; } return true; }
1079636_8
protected boolean isClassConsidered( final String className ) { // Fix case where class names are reported with '.' final String fixedClassName = className.replace('.', '/'); for ( String exclude : this.excludes ) { final Pattern excludePattern; if( !excludesAreRegExp ) { if ( exclude.contains( "/**/" ) ) { exclude = exclude.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( exclude.contains( "/*/" ) ) { exclude = exclude.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } excludePattern = simplifyRegularExpression( exclude, false ); } else { excludePattern = Pattern.compile( exclude ); } final Matcher excludeMatcher = excludePattern.matcher( fixedClassName ); while ( excludeMatcher.find() ) { return false; } } if ( !this.includes.isEmpty() ) { for ( String include : this.includes ) { final Pattern includePattern; if( !includesAreRegExp ) { if ( include.contains( "/**/" ) ) { include = include.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( include.contains( "/*/" ) ) { include = include.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } includePattern = simplifyRegularExpression( include, false ); } else { includePattern = Pattern.compile( include ); } final Matcher includeMatcher = includePattern.matcher( fixedClassName ); while ( includeMatcher.find() ) { return true; } } return false; } return true; }
1079636_9
protected boolean isClassConsidered( final String className ) { // Fix case where class names are reported with '.' final String fixedClassName = className.replace('.', '/'); for ( String exclude : this.excludes ) { final Pattern excludePattern; if( !excludesAreRegExp ) { if ( exclude.contains( "/**/" ) ) { exclude = exclude.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( exclude.contains( "/*/" ) ) { exclude = exclude.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } excludePattern = simplifyRegularExpression( exclude, false ); } else { excludePattern = Pattern.compile( exclude ); } final Matcher excludeMatcher = excludePattern.matcher( fixedClassName ); while ( excludeMatcher.find() ) { return false; } } if ( !this.includes.isEmpty() ) { for ( String include : this.includes ) { final Pattern includePattern; if( !includesAreRegExp ) { if ( include.contains( "/**/" ) ) { include = include.replaceAll( "/\\*\\*/", "{0,1}**/" ); } if ( include.contains( "/*/" ) ) { include = include.replaceAll( "/\\*/", "{0,1}*/{0,1}" ); } includePattern = simplifyRegularExpression( include, false ); } else { includePattern = Pattern.compile( include ); } final Matcher includeMatcher = includePattern.matcher( fixedClassName ); while ( includeMatcher.find() ) { return true; } } return false; } return true; }
1081751_0
@Nonnull public final T get() { return value; }
1081751_1
@Nonnull public static XProperties from(@Nonnull @NonNull final String absolutePath) throws IOException { final Resource resource = new PathMatchingResourcePatternResolver() .getResource(absolutePath); try (final InputStream in = resource.getInputStream()) { final XProperties xprops = new XProperties(); xprops.included.add(resource.getURI()); xprops.load(in); return xprops; } }
1081751_2
@Override public synchronized void load(@Nonnull final Reader reader) throws IOException { final ResourcePatternResolver loader = new PathMatchingResourcePatternResolver(); try (final CharArrayWriter writer = new CharArrayWriter()) { try (final BufferedReader lines = new BufferedReader(reader)) { for (String line = lines.readLine(); null != line; line = lines.readLine()) { writer.append(line).append('\n'); final Matcher matcher = include.matcher(line); if (matcher.matches()) for (final String x : comma .split(substitutor.replace(matcher.group(1)))) for (final Resource resource : loader .getResources(x)) { final URI uri = resource.getURI(); if (!included.add(uri)) throw new RecursiveIncludeException(uri, included); try (final InputStream in = resource .getInputStream()) { load(in); } } } } super.load(new CharArrayReader(writer.toCharArray())); } included.clear(); }
1081751_3
@Nullable @Override public String getProperty(final String key) { final String value = super.getProperty(key); if (null == value) return null; return substitutor.replace(value); }
1081751_4
@Nullable @Override public String getProperty(final String key) { final String value = super.getProperty(key); if (null == value) return null; return substitutor.replace(value); }
1081751_5
@Nullable @Override public String getProperty(final String key) { final String value = super.getProperty(key); if (null == value) return null; return substitutor.replace(value); }
1081751_6
@Nullable @Override public String getProperty(final String key) { final String value = super.getProperty(key); if (null == value) return null; return substitutor.replace(value); }
1081751_7
@Nullable @Override public String getProperty(final String key) { final String value = super.getProperty(key); if (null == value) return null; return substitutor.replace(value); }
1081751_8
@Nullable @Override public synchronized Object get(final Object key) { final Object value = super.get(key); if (null == value || !(value instanceof String)) return value; return substitutor.replace((String) value); }
1081751_9
@Nullable @Override public String getProperty(final String key) { final String value = super.getProperty(key); if (null == value) return null; return substitutor.replace(value); }
1081991_1
public static File findFile(File rootDir, final String fileName) { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.equals(fileName); } }; return findFile(rootDir, filter); }
1081991_2
public static File findFile(File rootDir, final String fileName) { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.equals(fileName); } }; return findFile(rootDir, filter); }
1081991_3
public static File findFile(File rootDir, final String fileName) { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.equals(fileName); } }; return findFile(rootDir, filter); }
1081991_4
public static File findFile(File rootDir, final String fileName) { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.equals(fileName); } }; return findFile(rootDir, filter); }
1081991_5
public static File findFile(File rootDir, final String fileName) { FilenameFilter filter = new FilenameFilter() { @Override public boolean accept(File dir, String name) { return name.equals(fileName); } }; return findFile(rootDir, filter); }
1081991_6
public URI buildWar() { if (option.getName() == null) { option.name(UUID.randomUUID().toString()); } processClassPath(); try { File webResourceDir = getWebResourceDir(); File probeWar = new File(tempDir, option.getName() + ".war"); ZipBuilder builder = new ZipBuilder(probeWar); for (String library : option.getLibraries()) { File file = toLocalFile(library); /* * ScatteredArchive copies all directory class path items to WEB-INF/classes, * so that separate CDI bean deployment archives get merged into one. To avoid * that, we convert each directory class path to a JAR file. */ if (file.isDirectory()) { file = toJar(file); } LOG.debug("including library {} = {}", library, file); builder.addFile(file, "WEB-INF/lib/" + file.getName()); } builder.addDirectory(webResourceDir, ""); builder.close(); URI warUri = probeWar.toURI(); LOG.info("WAR probe = {}", warUri); return warUri; } catch (IOException exc) { throw new TestContainerException(exc); } }
1081991_7
public URI buildWar() { if (option.getName() == null) { option.name(UUID.randomUUID().toString()); } processClassPath(); try { File webResourceDir = getWebResourceDir(); File probeWar = new File(tempDir, option.getName() + ".war"); ZipBuilder builder = new ZipBuilder(probeWar); for (String library : option.getLibraries()) { File file = toLocalFile(library); /* * ScatteredArchive copies all directory class path items to WEB-INF/classes, * so that separate CDI bean deployment archives get merged into one. To avoid * that, we convert each directory class path to a JAR file. */ if (file.isDirectory()) { file = toJar(file); } LOG.debug("including library {} = {}", library, file); builder.addFile(file, "WEB-INF/lib/" + file.getName()); } builder.addDirectory(webResourceDir, ""); builder.close(); URI warUri = probeWar.toURI(); LOG.info("WAR probe = {}", warUri); return warUri; } catch (IOException exc) { throw new TestContainerException(exc); } }
1081991_8
@Override public Object remoteCall(final Class<?> serviceType, final String methodName, final Class<?>[] methodParams, String filter, final RelativeTimeout timeout, final Object... actualParams) throws NoSuchServiceException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { LOG.trace("Remote call of [" + serviceType.getName() + "." + methodName + "]"); Object service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); Object obj = null; try { obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } catch (InvocationTargetException t) { if (t.getTargetException().getCause() instanceof RerunTestException) { LOG.debug("rerun the test"); service = ServiceLookup.getService(bundleContext, serviceType, timeout.getValue(), filter); obj = serviceType.getMethod(methodName, methodParams).invoke(service, actualParams); } else { throw t; } } return obj; }
1081991_9
public void loadSystemProperties(String configurationKey) { String propertyRef = getProperty(configurationKey); if (propertyRef == null) { return; } if (propertyRef.startsWith("env:")) { propertyRef = propertyRef.substring(4); propertyRef = System.getenv(propertyRef); } if (!propertyRef.startsWith("/")) { propertyRef = "/" + propertyRef; } try { URL url = getClass().getResource(propertyRef); if (url == null) { url = new URL(propertyRef); } Properties props = System.getProperties(); props.load(url.openStream()); System.setProperties(props); } catch (IOException exc) { throw new TestContainerException(exc); } }
1089023_0
@Override public void subscribe(Completable.Observer subscriber) { completionSignal.subscribe(subscriber); }
1090553_0
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_1
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_2
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_3
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_4
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_5
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_6
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_7
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_8
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1090553_9
public Result getMembership(RegionAssociable subject) { checkNotNull(subject); int minimumPriority = Integer.MIN_VALUE; Result result = Result.NO_REGIONS; Set<ProtectedRegion> ignoredRegions = Sets.newHashSet(); for (ProtectedRegion region : getApplicable()) { // Don't consider lower priorities below minimumPriority // (which starts at Integer.MIN_VALUE). A region that "counts" // (has the flag set OR has members) will raise minimumPriority // to its own priority. if (getPriority(region) < minimumPriority) { break; } // If PASSTHROUGH is set, ignore this region if (getEffectiveFlag(region, Flags.PASSTHROUGH, subject) == State.ALLOW) { continue; } if (ignoredRegions.contains(region)) { continue; } minimumPriority = getPriority(region); boolean member = RegionGroup.MEMBERS.contains(subject.getAssociation(Collections.singletonList(region))); if (member) { result = Result.SUCCESS; addParents(ignoredRegions, region); } else { return Result.FAIL; } } return result; }
1091655_0
public String getMBeanName() { return mBeanName; }
1091655_1
public String getMBeanName() { return mBeanName; }
1091655_2
public String getMBeanName() { return mBeanName; }
1091655_3
public String getMBeanName() { return mBeanName; }
1091655_4
public String getMBeanName() { return mBeanName; }
1091655_5
public String getMBeanName() { return mBeanName; }
1091655_6
public String getMBeanName() { return mBeanName; }
1091655_7
public String getMBeanName() { return mBeanName; }
1091966_0
public Request read(InputStream in) throws IOException { String header = null; String body = null; byte[] headerBytes = new byte[headerLength]; int n = in.read(headerBytes); if (n > 0) { header = new String(headerBytes, encoding); log.debug("header: #{}# ", header); int length = Integer.parseInt(header.substring(headerBodyLengthBeginIndex, headerBodyLengthEndIndex)); log.debug("length: {}", length); byte[] bodyBytes = new byte[length]; in.read(bodyBytes); body = new String(bodyBytes, encoding); log.debug("body: #{}#", body); } log.info("request: #{}#", header + body); return new Request(header, body); }
1091966_1
public Object service(String declaringClassCanonicalName, String methodName, Object[] arguments, String rootPath, boolean useRootRelativePath) throws Exception { log.debug("declaringClassCanonicalName: {}, methodName: {}, arguments: {}, rootPath: {}, useRootRelativePath: {}", new Object[]{declaringClassCanonicalName, methodName, arguments, rootPath, useRootRelativePath}); String rootRelativePath = useRootRelativePath ? getRootRelativePath(declaringClassCanonicalName, methodName) : ""; String simulatorRequest = createRequest(arguments); Optional<SimulatorResponse> simulatorResponseOptional = simulator.service(rootPath, rootRelativePath, simulatorRequest, CONTENT_TYPE); SimulatorResponse simulatorResponse = simulatorResponseOptional.get(); Object response = createResponse(simulatorResponse.getResponse()); if (response instanceof Throwable) { throw (Exception) response; } return response; }
1091966_2
private void escape(StringBuilder sb, JsonNode node, String name) { if (node.isArray()) { sb.append("\\["); Iterator<JsonNode> iterator = node.iterator(); int n = 0; while (iterator.hasNext()) { if (n > 0) { sb.append(","); } n++; escape(sb, iterator.next(), null); } sb.append("\\]"); } else if (node.isObject()) { sb.append("\\{"); Iterator<Entry<String, JsonNode>> fields = node.getFields(); int n = 0; while (fields.hasNext()) { if (n > 0) { sb.append(","); } n++; Entry<String, JsonNode> field = fields.next(); sb.append("\"").append(field.getKey()).append("\":"); escape(sb, field.getValue(), field.getKey()); } sb.append("\\}"); } else { sb.append(node.toString()); } }
1091966_3
public String map(String uri) { for (Mapping mapping : mappings) { Matcher matcher = mapping.from.matcher(uri); if (matcher.matches()) { String result = mapping.to; log.debug("uri: {}, mapping to: {}", uri, result); for (int i = 1; i <= matcher.groupCount(); i++) { log.debug("group {}: {}", i, matcher.group(i)); result = result.replaceAll("\\$\\{" + i + "\\}", matcher.group(i)); } log.debug("result: {}", result); return result; } } return null; }
1091966_4
public String map(String uri) { for (Mapping mapping : mappings) { Matcher matcher = mapping.from.matcher(uri); if (matcher.matches()) { String result = mapping.to; log.debug("uri: {}, mapping to: {}", uri, result); for (int i = 1; i <= matcher.groupCount(); i++) { log.debug("group {}: {}", i, matcher.group(i)); result = result.replaceAll("\\$\\{" + i + "\\}", matcher.group(i)); } log.debug("result: {}", result); return result; } } return null; }
1095208_0
@Override public void recycle () { data.clear(); classMap.clear(); }
1095208_1
public void readBootRecord (URL bootUrl) { Document document = getDocument(bootUrl); XPathFactory factory = XPathFactory.newInstance(); XPath xPath = factory.newXPath(); try { // first grab the Competition XPathExpression exp = xPath.compile("/powertac-bootstrap-data/config/competition"); NodeList nodes = (NodeList) exp.evaluate(document, XPathConstants.NODESET); String xml = nodeToString(nodes.item(0)); bootstrapCompetition = (Competition) messageConverter.fromXML(xml); add(bootstrapCompetition); for (CustomerInfo cust: bootstrapCompetition.getCustomers()) add(cust); // next, grab the bootstrap-state and add it to the config exp = xPath.compile("/powertac-bootstrap-data/bootstrap-state/properties"); nodes = (NodeList) exp.evaluate(document, XPathConstants.NODESET); if (null != nodes && nodes.getLength() > 0) { // handle the case where there is no bootstrap-state clause xml = nodeToString(nodes.item(0)); bootState = (Properties) messageConverter.fromXML(xml); } } catch (XPathExpressionException xee) { log.error("Error reading boot record from {}: {}", bootUrl, xee.toString()); System.out.println("Error reading boot dataset: " + xee.toString()); } processBootDataset(document); }
1095208_2
public void evaluateTariffs () { allocations.clear(); HashSet<Tariff> newTariffs = new LinkedHashSet<>(getTariffRepo() .findRecentActiveTariffs(tariffEvalDepth, customerInfo.getPowerType())); // make sure all superseding tariffs are in the set addSupersedingTariffs(newTariffs); // adjust inertia for BOG, accounting for the extra // evaluation cycle at ts 0 double actualInertia = Math.max(0.0, (1.0 - Math.pow(2, 1 - evaluationCounter)) * inertia); evaluationCounter += 1; // Get the cost eval for the appropriate default tariff EvalData defaultEval = getDefaultTariffEval(); log.info("customer {}: defaultEval={}", getName(), defaultEval.costEstimate); // ensure we have the cost eval for each of the new tariffs for (Tariff tariff : newTariffs) { EvalData eval = evaluatedTariffs.get(tariff); if (evaluateAllTariffs || null == eval) { // compute the projected cost for this tariff double cost = forecastCost(tariff); double hassle = computeInconvenience(tariff); log.info("Evaluated tariff " + tariff.getId() + ": cost=" + cost + ", inconvenience=" + hassle); eval = new EvalData(cost, hassle); evaluatedTariffs.put(tariff, eval); } } // Iterate through the current active subscriptions for (TariffSubscription subscription : getTariffSubscriptionRepo(). findActiveSubscriptionsForCustomer(customerInfo)) { Tariff subTariff = subscription.getTariff(); // find out how many of these customers can withdraw without penalty double withdrawCost = subTariff.getEarlyWithdrawPayment(); int committedCount = subscription.getCustomersCommitted(); int expiredCount = subscription.getExpiredCustomerCount(); if (withdrawCost == 0.0 || (expiredCount > 0 && expiredCount == committedCount)) { // no need to worry about expiration evaluateAlternativeTariffs(subscription, actualInertia, 0.0, committedCount, getDefaultTariff(), defaultEval, newTariffs); } else { // Evaluate expired and unexpired subsets separately evaluateAlternativeTariffs(subscription, actualInertia, 0.0, expiredCount, getDefaultTariff(), defaultEval, newTariffs); evaluateAlternativeTariffs(subscription, actualInertia, withdrawCost, committedCount - expiredCount, getDefaultTariff(), defaultEval, newTariffs); } } updateSubscriptions(); }
1095208_3
public void evaluateTariffs () { allocations.clear(); HashSet<Tariff> newTariffs = new LinkedHashSet<>(getTariffRepo() .findRecentActiveTariffs(tariffEvalDepth, customerInfo.getPowerType())); // make sure all superseding tariffs are in the set addSupersedingTariffs(newTariffs); // adjust inertia for BOG, accounting for the extra // evaluation cycle at ts 0 double actualInertia = Math.max(0.0, (1.0 - Math.pow(2, 1 - evaluationCounter)) * inertia); evaluationCounter += 1; // Get the cost eval for the appropriate default tariff EvalData defaultEval = getDefaultTariffEval(); log.info("customer {}: defaultEval={}", getName(), defaultEval.costEstimate); // ensure we have the cost eval for each of the new tariffs for (Tariff tariff : newTariffs) { EvalData eval = evaluatedTariffs.get(tariff); if (evaluateAllTariffs || null == eval) { // compute the projected cost for this tariff double cost = forecastCost(tariff); double hassle = computeInconvenience(tariff); log.info("Evaluated tariff " + tariff.getId() + ": cost=" + cost + ", inconvenience=" + hassle); eval = new EvalData(cost, hassle); evaluatedTariffs.put(tariff, eval); } } // Iterate through the current active subscriptions for (TariffSubscription subscription : getTariffSubscriptionRepo(). findActiveSubscriptionsForCustomer(customerInfo)) { Tariff subTariff = subscription.getTariff(); // find out how many of these customers can withdraw without penalty double withdrawCost = subTariff.getEarlyWithdrawPayment(); int committedCount = subscription.getCustomersCommitted(); int expiredCount = subscription.getExpiredCustomerCount(); if (withdrawCost == 0.0 || (expiredCount > 0 && expiredCount == committedCount)) { // no need to worry about expiration evaluateAlternativeTariffs(subscription, actualInertia, 0.0, committedCount, getDefaultTariff(), defaultEval, newTariffs); } else { // Evaluate expired and unexpired subsets separately evaluateAlternativeTariffs(subscription, actualInertia, 0.0, expiredCount, getDefaultTariff(), defaultEval, newTariffs); evaluateAlternativeTariffs(subscription, actualInertia, withdrawCost, committedCount - expiredCount, getDefaultTariff(), defaultEval, newTariffs); } } updateSubscriptions(); }
1095208_4
public void evaluateTariffs () { allocations.clear(); HashSet<Tariff> newTariffs = new LinkedHashSet<>(getTariffRepo() .findRecentActiveTariffs(tariffEvalDepth, customerInfo.getPowerType())); // make sure all superseding tariffs are in the set addSupersedingTariffs(newTariffs); // adjust inertia for BOG, accounting for the extra // evaluation cycle at ts 0 double actualInertia = Math.max(0.0, (1.0 - Math.pow(2, 1 - evaluationCounter)) * inertia); evaluationCounter += 1; // Get the cost eval for the appropriate default tariff EvalData defaultEval = getDefaultTariffEval(); log.info("customer {}: defaultEval={}", getName(), defaultEval.costEstimate); // ensure we have the cost eval for each of the new tariffs for (Tariff tariff : newTariffs) { EvalData eval = evaluatedTariffs.get(tariff); if (evaluateAllTariffs || null == eval) { // compute the projected cost for this tariff double cost = forecastCost(tariff); double hassle = computeInconvenience(tariff); log.info("Evaluated tariff " + tariff.getId() + ": cost=" + cost + ", inconvenience=" + hassle); eval = new EvalData(cost, hassle); evaluatedTariffs.put(tariff, eval); } } // Iterate through the current active subscriptions for (TariffSubscription subscription : getTariffSubscriptionRepo(). findActiveSubscriptionsForCustomer(customerInfo)) { Tariff subTariff = subscription.getTariff(); // find out how many of these customers can withdraw without penalty double withdrawCost = subTariff.getEarlyWithdrawPayment(); int committedCount = subscription.getCustomersCommitted(); int expiredCount = subscription.getExpiredCustomerCount(); if (withdrawCost == 0.0 || (expiredCount > 0 && expiredCount == committedCount)) { // no need to worry about expiration evaluateAlternativeTariffs(subscription, actualInertia, 0.0, committedCount, getDefaultTariff(), defaultEval, newTariffs); } else { // Evaluate expired and unexpired subsets separately evaluateAlternativeTariffs(subscription, actualInertia, 0.0, expiredCount, getDefaultTariff(), defaultEval, newTariffs); evaluateAlternativeTariffs(subscription, actualInertia, withdrawCost, committedCount - expiredCount, getDefaultTariff(), defaultEval, newTariffs); } } updateSubscriptions(); }
1095208_5
public RegulationCapacity (TariffSubscription subscription, double upRegulationCapacity, double downRegulationCapacity) { super(); this.subscription = subscription; if (upRegulationCapacity < 0.0) { if (upRegulationCapacity < -epsilon) log.warn("upRegulationCapacity " + upRegulationCapacity + " < 0.0"); upRegulationCapacity = 0.0; } if (downRegulationCapacity > 0.0) { if (downRegulationCapacity > epsilon) log.warn("downRegulationCapacity " + downRegulationCapacity + " > 0.0"); downRegulationCapacity = 0.0; } this.upRegulationCapacity = upRegulationCapacity; this.downRegulationCapacity = downRegulationCapacity; }
1095208_6
public double getUpRegulationCapacity () { return upRegulationCapacity; }
1095208_7
public double getDownRegulationCapacity () { return downRegulationCapacity; }
1095208_8
@Override public void postEconomicControl (EconomicControlEvent event) { int tsIndex = event.getTimeslotIndex(); int current = timeslotRepo.currentTimeslot().getSerialNumber(); if (tsIndex < current) { log.warn("attempt to save old economic control for ts " + tsIndex + " during timeslot " + current); return; } List<EconomicControlEvent> tsList = pendingEconomicControls.get(tsIndex); if (null == tsList) { tsList = new ArrayList<EconomicControlEvent>(); pendingEconomicControls.put(tsIndex, tsList); } tsList.add(event); }
1095208_9
@Override public RegulationAccumulator getRegulationCapacity (BalancingOrder order) { Tariff tariff = tariffRepo.findTariffById(order.getTariffId()); if (null == tariff) { // broker error, most likely log.warn("Null tariff " + order.getTariffId() + " for balancing order"); return new RegulationAccumulator(0.0, 0.0); } RegulationAccumulator result = new RegulationAccumulator(0.0, 0.0); List<TariffSubscription> subs = tariffSubscriptionRepo.findSubscriptionsForTariff(tariff); for (TariffSubscription sub : subs) { result.add(sub.getRemainingRegulationCapacity()); } log.info("BalancingOrder " + order.getId() + " capacity = (" + result.getUpRegulationCapacity() + "," + result.getDownRegulationCapacity() + ")"); return result; }
1097987_0
@Override public float lengthNorm(String fieldName, int numTerms) { if (numTerms < 20) { // this shouldn't be possible, but be safe. if (numTerms <= 0) return 0; return ARR[numTerms]; return -0.00606f * numTerms + 0.35f; } //else return (float) (1.0 / Math.sqrt(numTerms)); }
1107344_0
static void printHelp(PrintWriter out) { out.println("Usage:"); out.println(" vark [-f FILE] [options] [targets...]"); out.println(); out.println("Options:"); IArgKeyList keys = Launch.factory().createArgKeyList(); for (IArgKey key : AardvarkOptions.getArgKeys()) { keys.register(key); } keys.printHelp(out); }