id
int64 22
34.9k
| comment_id
int64 0
328
| comment
stringlengths 2
2.55k
| code
stringlengths 31
107k
| classification
stringclasses 6
values | isFinished
bool 1
class | code_context_2
stringlengths 21
27.3k
| code_context_10
stringlengths 29
27.3k
| code_context_20
stringlengths 29
27.3k
|
---|---|---|---|---|---|---|---|---|
24,576 | 0 | // If a manifest doesn't have a version, the other attributes won't get written out. Lame. | private void addEntriesToMainManifest(Manifest manifest) {
Attributes attrs = manifest.getMainAttributes();
// If a manifest doesn't have a version, the other attributes won't get written out. Lame.
attrs.put(Attributes.Name.MANIFEST_VERSION, new Date().toString());
for (Map.Entry<Attributes.Name, String> entry : this.manifestEntries.entrySet()) {
attrs.put(entry.getKey(), entry.getValue());
}
} | DEFECT | true | private void addEntriesToMainManifest(Manifest manifest) {
Attributes attrs = manifest.getMainAttributes();
// If a manifest doesn't have a version, the other attributes won't get written out. Lame.
attrs.put(Attributes.Name.MANIFEST_VERSION, new Date().toString());
for (Map.Entry<Attributes.Name, String> entry : this.manifestEntries.entrySet()) { | private void addEntriesToMainManifest(Manifest manifest) {
Attributes attrs = manifest.getMainAttributes();
// If a manifest doesn't have a version, the other attributes won't get written out. Lame.
attrs.put(Attributes.Name.MANIFEST_VERSION, new Date().toString());
for (Map.Entry<Attributes.Name, String> entry : this.manifestEntries.entrySet()) {
attrs.put(entry.getKey(), entry.getValue());
}
} | private void addEntriesToMainManifest(Manifest manifest) {
Attributes attrs = manifest.getMainAttributes();
// If a manifest doesn't have a version, the other attributes won't get written out. Lame.
attrs.put(Attributes.Name.MANIFEST_VERSION, new Date().toString());
for (Map.Entry<Attributes.Name, String> entry : this.manifestEntries.entrySet()) {
attrs.put(entry.getKey(), entry.getValue());
}
} |
22 | 0 | // FIXME: this is almost certainly boned. a Reg could appear in the
// address expressions. | public boolean usesRegs() {
// FIXME: this is almost certainly boned. a Reg could appear in the
// address expressions.
for (int i=0;i<rhs().length;++i) {
if (usesDirectly(i) && rhs()[i] instanceof Reg) {
return true;
}
}
if (opcode.form().implicitUses(head().code()).length!=0) {
return true;
}
return false;
} | DEFECT | true | public boolean usesRegs() {
// FIXME: this is almost certainly boned. a Reg could appear in the
// address expressions.
for (int i=0;i<rhs().length;++i) {
if (usesDirectly(i) && rhs()[i] instanceof Reg) { | public boolean usesRegs() {
// FIXME: this is almost certainly boned. a Reg could appear in the
// address expressions.
for (int i=0;i<rhs().length;++i) {
if (usesDirectly(i) && rhs()[i] instanceof Reg) {
return true;
}
}
if (opcode.form().implicitUses(head().code()).length!=0) {
return true;
}
return false;
} | public boolean usesRegs() {
// FIXME: this is almost certainly boned. a Reg could appear in the
// address expressions.
for (int i=0;i<rhs().length;++i) {
if (usesDirectly(i) && rhs()[i] instanceof Reg) {
return true;
}
}
if (opcode.form().implicitUses(head().code()).length!=0) {
return true;
}
return false;
} |
28 | 0 | //TODO: For each model create separate implementation. | @Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
long startTime = System.currentTimeMillis();
FeatureExtractor fe = new NYTEntitySalienceFeatureExtractor();
List<EntityInstance> entityInstances;
try {
entityInstances = fe.getEntityInstances(jCas, TrainingSettings.FeatureExtractor.ENTITY_SALIENCE);
final int featureVectorSize = FeatureSetFactory.createFeatureSet(TrainingSettings.FeatureExtractor.ENTITY_SALIENCE).getFeatureVectorSize();
//TODO: For each model create separate implementation.
RandomForestClassificationModel rfm = (RandomForestClassificationModel)trainingModel.stages()[2];
for(EntityInstance ei : entityInstances) {
Vector vei = FeatureValueInstanceUtils.convertToSparkMLVector(ei, featureVectorSize);
double label = rfm.predict(vei);
Vector probabilities = rfm.predictProbability(vei);
double salience = probabilities.toArray()[1];
SalientEntity salientEntity = new SalientEntity(jCas, 0, 0);
salientEntity.setLabel(label);
salientEntity.setID(ei.getEntityId());
salientEntity.setSalience(salience);
salientEntity.addToIndexes();
}
long endTime = System.currentTimeMillis() - startTime;
logger.debug("Annotating salient entities finished in {}ms.", endTime);
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
} | IMPLEMENTATION | true | entityInstances = fe.getEntityInstances(jCas, TrainingSettings.FeatureExtractor.ENTITY_SALIENCE);
final int featureVectorSize = FeatureSetFactory.createFeatureSet(TrainingSettings.FeatureExtractor.ENTITY_SALIENCE).getFeatureVectorSize();
//TODO: For each model create separate implementation.
RandomForestClassificationModel rfm = (RandomForestClassificationModel)trainingModel.stages()[2];
for(EntityInstance ei : entityInstances) { | @Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
long startTime = System.currentTimeMillis();
FeatureExtractor fe = new NYTEntitySalienceFeatureExtractor();
List<EntityInstance> entityInstances;
try {
entityInstances = fe.getEntityInstances(jCas, TrainingSettings.FeatureExtractor.ENTITY_SALIENCE);
final int featureVectorSize = FeatureSetFactory.createFeatureSet(TrainingSettings.FeatureExtractor.ENTITY_SALIENCE).getFeatureVectorSize();
//TODO: For each model create separate implementation.
RandomForestClassificationModel rfm = (RandomForestClassificationModel)trainingModel.stages()[2];
for(EntityInstance ei : entityInstances) {
Vector vei = FeatureValueInstanceUtils.convertToSparkMLVector(ei, featureVectorSize);
double label = rfm.predict(vei);
Vector probabilities = rfm.predictProbability(vei);
double salience = probabilities.toArray()[1];
SalientEntity salientEntity = new SalientEntity(jCas, 0, 0);
salientEntity.setLabel(label);
salientEntity.setID(ei.getEntityId());
salientEntity.setSalience(salience); | @Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
long startTime = System.currentTimeMillis();
FeatureExtractor fe = new NYTEntitySalienceFeatureExtractor();
List<EntityInstance> entityInstances;
try {
entityInstances = fe.getEntityInstances(jCas, TrainingSettings.FeatureExtractor.ENTITY_SALIENCE);
final int featureVectorSize = FeatureSetFactory.createFeatureSet(TrainingSettings.FeatureExtractor.ENTITY_SALIENCE).getFeatureVectorSize();
//TODO: For each model create separate implementation.
RandomForestClassificationModel rfm = (RandomForestClassificationModel)trainingModel.stages()[2];
for(EntityInstance ei : entityInstances) {
Vector vei = FeatureValueInstanceUtils.convertToSparkMLVector(ei, featureVectorSize);
double label = rfm.predict(vei);
Vector probabilities = rfm.predictProbability(vei);
double salience = probabilities.toArray()[1];
SalientEntity salientEntity = new SalientEntity(jCas, 0, 0);
salientEntity.setLabel(label);
salientEntity.setID(ei.getEntityId());
salientEntity.setSalience(salience);
salientEntity.addToIndexes();
}
long endTime = System.currentTimeMillis() - startTime;
logger.debug("Annotating salient entities finished in {}ms.", endTime);
} catch (Exception e) {
throw new AnalysisEngineProcessException(e);
}
} |
32 | 0 | // TODO: check here, may be necessary to remove the last space. | private void generateArttribute() {
String temp = "";
for (String s : connectedElements)
temp = temp + s + " ";
// TODO: check here, may be necessary to remove the last space.
linkingResourceElement.setAttribute(
"connectedResourceContainers_LinkingResource", temp);
} | DESIGN | true | for (String s : connectedElements)
temp = temp + s + " ";
// TODO: check here, may be necessary to remove the last space.
linkingResourceElement.setAttribute(
"connectedResourceContainers_LinkingResource", temp); | private void generateArttribute() {
String temp = "";
for (String s : connectedElements)
temp = temp + s + " ";
// TODO: check here, may be necessary to remove the last space.
linkingResourceElement.setAttribute(
"connectedResourceContainers_LinkingResource", temp);
} | private void generateArttribute() {
String temp = "";
for (String s : connectedElements)
temp = temp + s + " ";
// TODO: check here, may be necessary to remove the last space.
linkingResourceElement.setAttribute(
"connectedResourceContainers_LinkingResource", temp);
} |
32,849 | 0 | //验证手机号是否11位 | private boolean isTelLenthLegal(String tel) {
//TODO: Replace this with your own logic
return tel.length() == 11;
} | NONSATD | true | private boolean isTelLenthLegal(String tel) {
//TODO: Replace this with your own logic
return tel.length() == 11;
} | private boolean isTelLenthLegal(String tel) {
//TODO: Replace this with your own logic
return tel.length() == 11;
} | private boolean isTelLenthLegal(String tel) {
//TODO: Replace this with your own logic
return tel.length() == 11;
} |
32,849 | 1 | //TODO: Replace this with your own logic | private boolean isTelLenthLegal(String tel) {
//TODO: Replace this with your own logic
return tel.length() == 11;
} | IMPLEMENTATION | true | private boolean isTelLenthLegal(String tel) {
//TODO: Replace this with your own logic
return tel.length() == 11;
} | private boolean isTelLenthLegal(String tel) {
//TODO: Replace this with your own logic
return tel.length() == 11;
} | private boolean isTelLenthLegal(String tel) {
//TODO: Replace this with your own logic
return tel.length() == 11;
} |
32,850 | 0 | //是否是邮箱 | private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@")&&email.contains(".");
} | NONSATD | true | private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@")&&email.contains(".");
} | private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@")&&email.contains(".");
} | private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@")&&email.contains(".");
} |
32,850 | 1 | //TODO: Replace this with your own logic | private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@")&&email.contains(".");
} | IMPLEMENTATION | true | private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@")&&email.contains(".");
} | private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@")&&email.contains(".");
} | private boolean isEmailValid(String email) {
//TODO: Replace this with your own logic
return email.contains("@")&&email.contains(".");
} |
83 | 0 | // Operator op = ((OperatorItem) item0)._operator; // TODO check this value if we can, somehow | @Test
public void parseNegativeIntegerLiteral(
) throws ExpressionException {
LineSpecifier ls = new LineSpecifier(0, 10);
Locale locale = new Locale(ls, 10);
ExpressionParser parser = new ExpressionParser("-14458", locale);
Expression exp = parser.parse(new Assembler.Builder().build());
assertEquals(2, exp._items.size());
ExpressionItem item0 = exp._items.get(0);
assertTrue(item0 instanceof OperatorItem);
// Operator op = ((OperatorItem) item0)._operator; // TODO check this value if we can, somehow
ExpressionItem item1 = exp._items.get(1);
assertTrue(item1 instanceof ValueItem);
Value v1 = ((ValueItem)item1)._value;
assertTrue(v1 instanceof IntegerValue);
assertEquals(14458L, ((IntegerValue)v1)._value.get().longValue());
} | DESIGN | true | ExpressionItem item0 = exp._items.get(0);
assertTrue(item0 instanceof OperatorItem);
// Operator op = ((OperatorItem) item0)._operator; // TODO check this value if we can, somehow
ExpressionItem item1 = exp._items.get(1);
assertTrue(item1 instanceof ValueItem); | @Test
public void parseNegativeIntegerLiteral(
) throws ExpressionException {
LineSpecifier ls = new LineSpecifier(0, 10);
Locale locale = new Locale(ls, 10);
ExpressionParser parser = new ExpressionParser("-14458", locale);
Expression exp = parser.parse(new Assembler.Builder().build());
assertEquals(2, exp._items.size());
ExpressionItem item0 = exp._items.get(0);
assertTrue(item0 instanceof OperatorItem);
// Operator op = ((OperatorItem) item0)._operator; // TODO check this value if we can, somehow
ExpressionItem item1 = exp._items.get(1);
assertTrue(item1 instanceof ValueItem);
Value v1 = ((ValueItem)item1)._value;
assertTrue(v1 instanceof IntegerValue);
assertEquals(14458L, ((IntegerValue)v1)._value.get().longValue());
} | @Test
public void parseNegativeIntegerLiteral(
) throws ExpressionException {
LineSpecifier ls = new LineSpecifier(0, 10);
Locale locale = new Locale(ls, 10);
ExpressionParser parser = new ExpressionParser("-14458", locale);
Expression exp = parser.parse(new Assembler.Builder().build());
assertEquals(2, exp._items.size());
ExpressionItem item0 = exp._items.get(0);
assertTrue(item0 instanceof OperatorItem);
// Operator op = ((OperatorItem) item0)._operator; // TODO check this value if we can, somehow
ExpressionItem item1 = exp._items.get(1);
assertTrue(item1 instanceof ValueItem);
Value v1 = ((ValueItem)item1)._value;
assertTrue(v1 instanceof IntegerValue);
assertEquals(14458L, ((IntegerValue)v1)._value.get().longValue());
} |
85 | 0 | /**
* Adds a module for placing a voice call.
*
* <p>The method is a no-op if the number is blocked.
*/ | public HistoryItemActionModulesBuilder addModuleForVoiceCall() {
if (moduleInfo.getIsBlocked()) {
return this;
}
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls.
CallIntentBuilder callIntentBuilder =
new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType())
.setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing());
modules.add(IntentModule.newCallModule(context, callIntentBuilder));
return this;
} | NONSATD | true | public HistoryItemActionModulesBuilder addModuleForVoiceCall() {
if (moduleInfo.getIsBlocked()) {
return this;
}
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls.
CallIntentBuilder callIntentBuilder =
new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType())
.setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing());
modules.add(IntentModule.newCallModule(context, callIntentBuilder));
return this;
} | public HistoryItemActionModulesBuilder addModuleForVoiceCall() {
if (moduleInfo.getIsBlocked()) {
return this;
}
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls.
CallIntentBuilder callIntentBuilder =
new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType())
.setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing());
modules.add(IntentModule.newCallModule(context, callIntentBuilder));
return this;
} | public HistoryItemActionModulesBuilder addModuleForVoiceCall() {
if (moduleInfo.getIsBlocked()) {
return this;
}
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls.
CallIntentBuilder callIntentBuilder =
new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType())
.setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing());
modules.add(IntentModule.newCallModule(context, callIntentBuilder));
return this;
} |
85 | 1 | // TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls. | public HistoryItemActionModulesBuilder addModuleForVoiceCall() {
if (moduleInfo.getIsBlocked()) {
return this;
}
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls.
CallIntentBuilder callIntentBuilder =
new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType())
.setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing());
modules.add(IntentModule.newCallModule(context, callIntentBuilder));
return this;
} | IMPLEMENTATION | true | return this;
}
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls.
CallIntentBuilder callIntentBuilder =
new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType()) | public HistoryItemActionModulesBuilder addModuleForVoiceCall() {
if (moduleInfo.getIsBlocked()) {
return this;
}
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls.
CallIntentBuilder callIntentBuilder =
new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType())
.setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing());
modules.add(IntentModule.newCallModule(context, callIntentBuilder));
return this;
} | public HistoryItemActionModulesBuilder addModuleForVoiceCall() {
if (moduleInfo.getIsBlocked()) {
return this;
}
// TODO(zachh): Support post-dial digits; consider using DialerPhoneNumber.
// Do not set PhoneAccountHandle so that regular PreCall logic will be used. The account used to
// place or receive the call should be ignored for voice calls.
CallIntentBuilder callIntentBuilder =
new CallIntentBuilder(moduleInfo.getNormalizedNumber(), getCallInitiationType())
.setAllowAssistedDial(moduleInfo.getCanSupportAssistedDialing());
modules.add(IntentModule.newCallModule(context, callIntentBuilder));
return this;
} |
32,858 | 0 | // TODO(felly): Support directory traversal. | @Override
protected Collection<String> getDirectoryEntries(Path path) throws IOException {
// TODO(felly): Support directory traversal.
return ImmutableList.of();
} | DESIGN | true | @Override
protected Collection<String> getDirectoryEntries(Path path) throws IOException {
// TODO(felly): Support directory traversal.
return ImmutableList.of();
} | @Override
protected Collection<String> getDirectoryEntries(Path path) throws IOException {
// TODO(felly): Support directory traversal.
return ImmutableList.of();
} | @Override
protected Collection<String> getDirectoryEntries(Path path) throws IOException {
// TODO(felly): Support directory traversal.
return ImmutableList.of();
} |
24,672 | 0 | //TODO Capitalize first char?? | public String getJavaName() {
return service.getName(); //TODO Capitalize first char??
} | IMPLEMENTATION | true | public String getJavaName() {
return service.getName(); //TODO Capitalize first char??
} | public String getJavaName() {
return service.getName(); //TODO Capitalize first char??
} | public String getJavaName() {
return service.getName(); //TODO Capitalize first char??
} |
24,673 | 0 | /**
* Checks if the provided zone is an option for the client to connect to.
* Any zone provided must have previously been created by ZoneManagement.
*
* @param tenantId The tenantId of the connecting envoy.
* @param zone The zone provided in the envoySummary.
* @throws IllegalArgumentException if the zone is not found.
*/ | private void validateZoneAvailable(String tenantId, String zone) throws IllegalArgumentException {
List<ZoneDTO> zones;
try {
zones = zoneApi.getAvailableZones(tenantId);
} catch (ResourceAccessException e) {
// need to do something here to handle things more gracefully.
throw new RuntimeException("Unable to validate zones.", e);
}
boolean found = zones.stream().anyMatch(z -> z.getName().equals(zone));
log.debug("Found {} zones for tenant", zoneApi.getAvailableZones(tenantId).size());
if (!found) throw new IllegalArgumentException("Provided zone does not exist: " + zone);
} | NONSATD | true | private void validateZoneAvailable(String tenantId, String zone) throws IllegalArgumentException {
List<ZoneDTO> zones;
try {
zones = zoneApi.getAvailableZones(tenantId);
} catch (ResourceAccessException e) {
// need to do something here to handle things more gracefully.
throw new RuntimeException("Unable to validate zones.", e);
}
boolean found = zones.stream().anyMatch(z -> z.getName().equals(zone));
log.debug("Found {} zones for tenant", zoneApi.getAvailableZones(tenantId).size());
if (!found) throw new IllegalArgumentException("Provided zone does not exist: " + zone);
} | private void validateZoneAvailable(String tenantId, String zone) throws IllegalArgumentException {
List<ZoneDTO> zones;
try {
zones = zoneApi.getAvailableZones(tenantId);
} catch (ResourceAccessException e) {
// need to do something here to handle things more gracefully.
throw new RuntimeException("Unable to validate zones.", e);
}
boolean found = zones.stream().anyMatch(z -> z.getName().equals(zone));
log.debug("Found {} zones for tenant", zoneApi.getAvailableZones(tenantId).size());
if (!found) throw new IllegalArgumentException("Provided zone does not exist: " + zone);
} | private void validateZoneAvailable(String tenantId, String zone) throws IllegalArgumentException {
List<ZoneDTO> zones;
try {
zones = zoneApi.getAvailableZones(tenantId);
} catch (ResourceAccessException e) {
// need to do something here to handle things more gracefully.
throw new RuntimeException("Unable to validate zones.", e);
}
boolean found = zones.stream().anyMatch(z -> z.getName().equals(zone));
log.debug("Found {} zones for tenant", zoneApi.getAvailableZones(tenantId).size());
if (!found) throw new IllegalArgumentException("Provided zone does not exist: " + zone);
} |
24,673 | 1 | // need to do something here to handle things more gracefully. | private void validateZoneAvailable(String tenantId, String zone) throws IllegalArgumentException {
List<ZoneDTO> zones;
try {
zones = zoneApi.getAvailableZones(tenantId);
} catch (ResourceAccessException e) {
// need to do something here to handle things more gracefully.
throw new RuntimeException("Unable to validate zones.", e);
}
boolean found = zones.stream().anyMatch(z -> z.getName().equals(zone));
log.debug("Found {} zones for tenant", zoneApi.getAvailableZones(tenantId).size());
if (!found) throw new IllegalArgumentException("Provided zone does not exist: " + zone);
} | DESIGN | true | zones = zoneApi.getAvailableZones(tenantId);
} catch (ResourceAccessException e) {
// need to do something here to handle things more gracefully.
throw new RuntimeException("Unable to validate zones.", e);
} | private void validateZoneAvailable(String tenantId, String zone) throws IllegalArgumentException {
List<ZoneDTO> zones;
try {
zones = zoneApi.getAvailableZones(tenantId);
} catch (ResourceAccessException e) {
// need to do something here to handle things more gracefully.
throw new RuntimeException("Unable to validate zones.", e);
}
boolean found = zones.stream().anyMatch(z -> z.getName().equals(zone));
log.debug("Found {} zones for tenant", zoneApi.getAvailableZones(tenantId).size());
if (!found) throw new IllegalArgumentException("Provided zone does not exist: " + zone);
} | private void validateZoneAvailable(String tenantId, String zone) throws IllegalArgumentException {
List<ZoneDTO> zones;
try {
zones = zoneApi.getAvailableZones(tenantId);
} catch (ResourceAccessException e) {
// need to do something here to handle things more gracefully.
throw new RuntimeException("Unable to validate zones.", e);
}
boolean found = zones.stream().anyMatch(z -> z.getName().equals(zone));
log.debug("Found {} zones for tenant", zoneApi.getAvailableZones(tenantId).size());
if (!found) throw new IllegalArgumentException("Provided zone does not exist: " + zone);
} |
32,867 | 0 | // TODO: Configuration is not used because we don't support any other mode for now. For that : ISPN-8413 | @Override
public boolean defineLock(String name, ClusteredLockConfiguration configuration) {
// TODO: Configuration is not used because we don't support any other mode for now. For that : ISPN-8413
CacheHolder cacheHolder = extractCacheHolder(cacheHolderFuture);
cache = cacheHolder.getClusteredLockCache();
ClusteredLockKey key = new ClusteredLockKey(ByteString.fromString(name));
ClusteredLockValue clusteredLockValue = cache.putIfAbsent(key, ClusteredLockValue.INITIAL_STATE);
locks.putIfAbsent(name, new ClusteredLockImpl(name, key, cache, this));
return clusteredLockValue == null;
} | DESIGN | true | @Override
public boolean defineLock(String name, ClusteredLockConfiguration configuration) {
// TODO: Configuration is not used because we don't support any other mode for now. For that : ISPN-8413
CacheHolder cacheHolder = extractCacheHolder(cacheHolderFuture);
cache = cacheHolder.getClusteredLockCache(); | @Override
public boolean defineLock(String name, ClusteredLockConfiguration configuration) {
// TODO: Configuration is not used because we don't support any other mode for now. For that : ISPN-8413
CacheHolder cacheHolder = extractCacheHolder(cacheHolderFuture);
cache = cacheHolder.getClusteredLockCache();
ClusteredLockKey key = new ClusteredLockKey(ByteString.fromString(name));
ClusteredLockValue clusteredLockValue = cache.putIfAbsent(key, ClusteredLockValue.INITIAL_STATE);
locks.putIfAbsent(name, new ClusteredLockImpl(name, key, cache, this));
return clusteredLockValue == null;
} | @Override
public boolean defineLock(String name, ClusteredLockConfiguration configuration) {
// TODO: Configuration is not used because we don't support any other mode for now. For that : ISPN-8413
CacheHolder cacheHolder = extractCacheHolder(cacheHolderFuture);
cache = cacheHolder.getClusteredLockCache();
ClusteredLockKey key = new ClusteredLockKey(ByteString.fromString(name));
ClusteredLockValue clusteredLockValue = cache.putIfAbsent(key, ClusteredLockValue.INITIAL_STATE);
locks.putIfAbsent(name, new ClusteredLockImpl(name, key, cache, this));
return clusteredLockValue == null;
} |
100 | 0 | // TODO Auto-generated method stub
// return super.hasRole(principal, roleIdentifier); | @Override
public boolean hasRole(final PrincipalCollection principal, final String roleIdentifier) {
// TODO Auto-generated method stub
// return super.hasRole(principal, roleIdentifier);
for (final Object p : principal.fromRealm(REALM_NAME)) {
if (p instanceof GenericPrincipal) {
final GenericPrincipal gp = (GenericPrincipal) p;
for (final String r : gp.getRoles()) {
if (r.equals(roleIdentifier)) {
return true;
}
}
}
}
return false;
} | DESIGN | true | @Override
public boolean hasRole(final PrincipalCollection principal, final String roleIdentifier) {
// TODO Auto-generated method stub
// return super.hasRole(principal, roleIdentifier);
for (final Object p : principal.fromRealm(REALM_NAME)) {
if (p instanceof GenericPrincipal) { | @Override
public boolean hasRole(final PrincipalCollection principal, final String roleIdentifier) {
// TODO Auto-generated method stub
// return super.hasRole(principal, roleIdentifier);
for (final Object p : principal.fromRealm(REALM_NAME)) {
if (p instanceof GenericPrincipal) {
final GenericPrincipal gp = (GenericPrincipal) p;
for (final String r : gp.getRoles()) {
if (r.equals(roleIdentifier)) {
return true;
}
}
}
} | @Override
public boolean hasRole(final PrincipalCollection principal, final String roleIdentifier) {
// TODO Auto-generated method stub
// return super.hasRole(principal, roleIdentifier);
for (final Object p : principal.fromRealm(REALM_NAME)) {
if (p instanceof GenericPrincipal) {
final GenericPrincipal gp = (GenericPrincipal) p;
for (final String r : gp.getRoles()) {
if (r.equals(roleIdentifier)) {
return true;
}
}
}
}
return false;
} |
16,486 | 0 | //TODO check rewrite in future | public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
if(args.length != 4) {
System.out.print("args should be 2 : <inputpath> <outpath> <number of centroids> <dimensions> .") ;
System.exit(-1);
}
int k = Integer.valueOf(args[2]) ;
int dim = Integer.valueOf(args[3]) ;
Job init_job = Job.getInstance() ;
Configuration init_conf = init_job.getConfiguration();
init_conf.set("kmeans.k", args[2]);
init_conf.set("kmeans.dim", args[3]);
init_job.setJarByClass(KMean.class);
init_job.setJobName("clustered kmeans");
init_job.setMapperClass(KMeanInitMapper.class);
init_job.setReducerClass(KMeanInitReducer.class);
init_job.setOutputKeyClass(IntWritable.class);
init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true);
double[][] old_centroids = new double[k][dim] ;
int fi = 1 ;
long t1 = System.currentTimeMillis() ;
while(true) {
System.out.print("start iteration") ;
Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]);
conf.set("kmeans.dim", args[3]);
kmean_cluster_jb.setJarByClass(KMean.class);
kmean_cluster_jb.setJobName("clustered kmeans");
kmean_cluster_jb.setMapperClass(KMeanIterationMapper.class);
kmean_cluster_jb.setReducerClass(KMeanIterationReducer.class);
kmean_cluster_jb.setOutputKeyClass(IntWritable.class);
kmean_cluster_jb.setOutputValueClass(Text.class);
// TODO check rewrite in future
String uri = args[1] + "_m_" + Integer.toString(fi-1) + "/part-r-00000";
Configuration temp_conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), temp_conf);
Path input_path = new Path(uri);
FSDataInputStream input_stream = fs.open(input_path);
BufferedReader input_buffer = new BufferedReader(new InputStreamReader(input_stream));
double total_dis = 0 ;
double[][] new_centroids = new double[k][dim] ;
for(int i = 0 ; i < k ; i++) {
String line = input_buffer.readLine() ;
if(line == null) {
for(int j = 0 ; j < dim ; j++) {
new_centroids[i][j] = Double.valueOf(old_centroids[i][j]) ;
}
continue ;
}
int key = Integer.valueOf(line.split("\t")[0]) ;
String[] new_centroid = line.split("\t")[1].split(",") ;
for(int j = 0 ; j < dim ; j++) {
new_centroids[key][j] = Double.valueOf(new_centroid[j]) ;
total_dis += Math.pow(new_centroids[key][j] - old_centroids[key][j], 2) ;
}
conf.set("kmeans.centroid" + key, line.split("\t")[1]);
}
double threshold = Math.pow(0.001 ,2) * k * dim ;
if(total_dis < threshold)
break ;
FileInputFormat.addInputPath(kmean_cluster_jb, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(kmean_cluster_jb, new Path(args[1] + "_m_" + Integer.toString(fi)));
kmean_cluster_jb.waitForCompletion(true);
old_centroids = new_centroids;
fi++ ;
}
long t2 = System.currentTimeMillis() ;
System.out.println("\n Time token by un-parallel is : " + (t2-t1) + "ms");
} | IMPLEMENTATION | true | init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true); | Configuration init_conf = init_job.getConfiguration();
init_conf.set("kmeans.k", args[2]);
init_conf.set("kmeans.dim", args[3]);
init_job.setJarByClass(KMean.class);
init_job.setJobName("clustered kmeans");
init_job.setMapperClass(KMeanInitMapper.class);
init_job.setReducerClass(KMeanInitReducer.class);
init_job.setOutputKeyClass(IntWritable.class);
init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true);
double[][] old_centroids = new double[k][dim] ;
int fi = 1 ;
long t1 = System.currentTimeMillis() ;
while(true) {
System.out.print("start iteration") ;
Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]); | public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
if(args.length != 4) {
System.out.print("args should be 2 : <inputpath> <outpath> <number of centroids> <dimensions> .") ;
System.exit(-1);
}
int k = Integer.valueOf(args[2]) ;
int dim = Integer.valueOf(args[3]) ;
Job init_job = Job.getInstance() ;
Configuration init_conf = init_job.getConfiguration();
init_conf.set("kmeans.k", args[2]);
init_conf.set("kmeans.dim", args[3]);
init_job.setJarByClass(KMean.class);
init_job.setJobName("clustered kmeans");
init_job.setMapperClass(KMeanInitMapper.class);
init_job.setReducerClass(KMeanInitReducer.class);
init_job.setOutputKeyClass(IntWritable.class);
init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true);
double[][] old_centroids = new double[k][dim] ;
int fi = 1 ;
long t1 = System.currentTimeMillis() ;
while(true) {
System.out.print("start iteration") ;
Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]);
conf.set("kmeans.dim", args[3]);
kmean_cluster_jb.setJarByClass(KMean.class);
kmean_cluster_jb.setJobName("clustered kmeans");
kmean_cluster_jb.setMapperClass(KMeanIterationMapper.class);
kmean_cluster_jb.setReducerClass(KMeanIterationReducer.class);
kmean_cluster_jb.setOutputKeyClass(IntWritable.class);
kmean_cluster_jb.setOutputValueClass(Text.class);
// TODO check rewrite in future
String uri = args[1] + "_m_" + Integer.toString(fi-1) + "/part-r-00000";
Configuration temp_conf = new Configuration(); |
16,486 | 1 | // TODO check rewrite in future | public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
if(args.length != 4) {
System.out.print("args should be 2 : <inputpath> <outpath> <number of centroids> <dimensions> .") ;
System.exit(-1);
}
int k = Integer.valueOf(args[2]) ;
int dim = Integer.valueOf(args[3]) ;
Job init_job = Job.getInstance() ;
Configuration init_conf = init_job.getConfiguration();
init_conf.set("kmeans.k", args[2]);
init_conf.set("kmeans.dim", args[3]);
init_job.setJarByClass(KMean.class);
init_job.setJobName("clustered kmeans");
init_job.setMapperClass(KMeanInitMapper.class);
init_job.setReducerClass(KMeanInitReducer.class);
init_job.setOutputKeyClass(IntWritable.class);
init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true);
double[][] old_centroids = new double[k][dim] ;
int fi = 1 ;
long t1 = System.currentTimeMillis() ;
while(true) {
System.out.print("start iteration") ;
Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]);
conf.set("kmeans.dim", args[3]);
kmean_cluster_jb.setJarByClass(KMean.class);
kmean_cluster_jb.setJobName("clustered kmeans");
kmean_cluster_jb.setMapperClass(KMeanIterationMapper.class);
kmean_cluster_jb.setReducerClass(KMeanIterationReducer.class);
kmean_cluster_jb.setOutputKeyClass(IntWritable.class);
kmean_cluster_jb.setOutputValueClass(Text.class);
// TODO check rewrite in future
String uri = args[1] + "_m_" + Integer.toString(fi-1) + "/part-r-00000";
Configuration temp_conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), temp_conf);
Path input_path = new Path(uri);
FSDataInputStream input_stream = fs.open(input_path);
BufferedReader input_buffer = new BufferedReader(new InputStreamReader(input_stream));
double total_dis = 0 ;
double[][] new_centroids = new double[k][dim] ;
for(int i = 0 ; i < k ; i++) {
String line = input_buffer.readLine() ;
if(line == null) {
for(int j = 0 ; j < dim ; j++) {
new_centroids[i][j] = Double.valueOf(old_centroids[i][j]) ;
}
continue ;
}
int key = Integer.valueOf(line.split("\t")[0]) ;
String[] new_centroid = line.split("\t")[1].split(",") ;
for(int j = 0 ; j < dim ; j++) {
new_centroids[key][j] = Double.valueOf(new_centroid[j]) ;
total_dis += Math.pow(new_centroids[key][j] - old_centroids[key][j], 2) ;
}
conf.set("kmeans.centroid" + key, line.split("\t")[1]);
}
double threshold = Math.pow(0.001 ,2) * k * dim ;
if(total_dis < threshold)
break ;
FileInputFormat.addInputPath(kmean_cluster_jb, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(kmean_cluster_jb, new Path(args[1] + "_m_" + Integer.toString(fi)));
kmean_cluster_jb.waitForCompletion(true);
old_centroids = new_centroids;
fi++ ;
}
long t2 = System.currentTimeMillis() ;
System.out.println("\n Time token by un-parallel is : " + (t2-t1) + "ms");
} | IMPLEMENTATION | true | kmean_cluster_jb.setOutputKeyClass(IntWritable.class);
kmean_cluster_jb.setOutputValueClass(Text.class);
// TODO check rewrite in future
String uri = args[1] + "_m_" + Integer.toString(fi-1) + "/part-r-00000";
Configuration temp_conf = new Configuration(); | Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]);
conf.set("kmeans.dim", args[3]);
kmean_cluster_jb.setJarByClass(KMean.class);
kmean_cluster_jb.setJobName("clustered kmeans");
kmean_cluster_jb.setMapperClass(KMeanIterationMapper.class);
kmean_cluster_jb.setReducerClass(KMeanIterationReducer.class);
kmean_cluster_jb.setOutputKeyClass(IntWritable.class);
kmean_cluster_jb.setOutputValueClass(Text.class);
// TODO check rewrite in future
String uri = args[1] + "_m_" + Integer.toString(fi-1) + "/part-r-00000";
Configuration temp_conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), temp_conf);
Path input_path = new Path(uri);
FSDataInputStream input_stream = fs.open(input_path);
BufferedReader input_buffer = new BufferedReader(new InputStreamReader(input_stream));
double total_dis = 0 ;
double[][] new_centroids = new double[k][dim] ;
for(int i = 0 ; i < k ; i++) {
String line = input_buffer.readLine() ; | init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true);
double[][] old_centroids = new double[k][dim] ;
int fi = 1 ;
long t1 = System.currentTimeMillis() ;
while(true) {
System.out.print("start iteration") ;
Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]);
conf.set("kmeans.dim", args[3]);
kmean_cluster_jb.setJarByClass(KMean.class);
kmean_cluster_jb.setJobName("clustered kmeans");
kmean_cluster_jb.setMapperClass(KMeanIterationMapper.class);
kmean_cluster_jb.setReducerClass(KMeanIterationReducer.class);
kmean_cluster_jb.setOutputKeyClass(IntWritable.class);
kmean_cluster_jb.setOutputValueClass(Text.class);
// TODO check rewrite in future
String uri = args[1] + "_m_" + Integer.toString(fi-1) + "/part-r-00000";
Configuration temp_conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), temp_conf);
Path input_path = new Path(uri);
FSDataInputStream input_stream = fs.open(input_path);
BufferedReader input_buffer = new BufferedReader(new InputStreamReader(input_stream));
double total_dis = 0 ;
double[][] new_centroids = new double[k][dim] ;
for(int i = 0 ; i < k ; i++) {
String line = input_buffer.readLine() ;
if(line == null) {
for(int j = 0 ; j < dim ; j++) {
new_centroids[i][j] = Double.valueOf(old_centroids[i][j]) ;
}
continue ;
}
int key = Integer.valueOf(line.split("\t")[0]) ;
String[] new_centroid = line.split("\t")[1].split(",") ;
for(int j = 0 ; j < dim ; j++) {
new_centroids[key][j] = Double.valueOf(new_centroid[j]) ; |
16,486 | 2 | //TODO check rewrite in future | public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
if(args.length != 4) {
System.out.print("args should be 2 : <inputpath> <outpath> <number of centroids> <dimensions> .") ;
System.exit(-1);
}
int k = Integer.valueOf(args[2]) ;
int dim = Integer.valueOf(args[3]) ;
Job init_job = Job.getInstance() ;
Configuration init_conf = init_job.getConfiguration();
init_conf.set("kmeans.k", args[2]);
init_conf.set("kmeans.dim", args[3]);
init_job.setJarByClass(KMean.class);
init_job.setJobName("clustered kmeans");
init_job.setMapperClass(KMeanInitMapper.class);
init_job.setReducerClass(KMeanInitReducer.class);
init_job.setOutputKeyClass(IntWritable.class);
init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true);
double[][] old_centroids = new double[k][dim] ;
int fi = 1 ;
long t1 = System.currentTimeMillis() ;
while(true) {
System.out.print("start iteration") ;
Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]);
conf.set("kmeans.dim", args[3]);
kmean_cluster_jb.setJarByClass(KMean.class);
kmean_cluster_jb.setJobName("clustered kmeans");
kmean_cluster_jb.setMapperClass(KMeanIterationMapper.class);
kmean_cluster_jb.setReducerClass(KMeanIterationReducer.class);
kmean_cluster_jb.setOutputKeyClass(IntWritable.class);
kmean_cluster_jb.setOutputValueClass(Text.class);
// TODO check rewrite in future
String uri = args[1] + "_m_" + Integer.toString(fi-1) + "/part-r-00000";
Configuration temp_conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), temp_conf);
Path input_path = new Path(uri);
FSDataInputStream input_stream = fs.open(input_path);
BufferedReader input_buffer = new BufferedReader(new InputStreamReader(input_stream));
double total_dis = 0 ;
double[][] new_centroids = new double[k][dim] ;
for(int i = 0 ; i < k ; i++) {
String line = input_buffer.readLine() ;
if(line == null) {
for(int j = 0 ; j < dim ; j++) {
new_centroids[i][j] = Double.valueOf(old_centroids[i][j]) ;
}
continue ;
}
int key = Integer.valueOf(line.split("\t")[0]) ;
String[] new_centroid = line.split("\t")[1].split(",") ;
for(int j = 0 ; j < dim ; j++) {
new_centroids[key][j] = Double.valueOf(new_centroid[j]) ;
total_dis += Math.pow(new_centroids[key][j] - old_centroids[key][j], 2) ;
}
conf.set("kmeans.centroid" + key, line.split("\t")[1]);
}
double threshold = Math.pow(0.001 ,2) * k * dim ;
if(total_dis < threshold)
break ;
FileInputFormat.addInputPath(kmean_cluster_jb, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(kmean_cluster_jb, new Path(args[1] + "_m_" + Integer.toString(fi)));
kmean_cluster_jb.waitForCompletion(true);
old_centroids = new_centroids;
fi++ ;
}
long t2 = System.currentTimeMillis() ;
System.out.println("\n Time token by un-parallel is : " + (t2-t1) + "ms");
} | IMPLEMENTATION | true | init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true); | Configuration init_conf = init_job.getConfiguration();
init_conf.set("kmeans.k", args[2]);
init_conf.set("kmeans.dim", args[3]);
init_job.setJarByClass(KMean.class);
init_job.setJobName("clustered kmeans");
init_job.setMapperClass(KMeanInitMapper.class);
init_job.setReducerClass(KMeanInitReducer.class);
init_job.setOutputKeyClass(IntWritable.class);
init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true);
double[][] old_centroids = new double[k][dim] ;
int fi = 1 ;
long t1 = System.currentTimeMillis() ;
while(true) {
System.out.print("start iteration") ;
Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]); | public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
if(args.length != 4) {
System.out.print("args should be 2 : <inputpath> <outpath> <number of centroids> <dimensions> .") ;
System.exit(-1);
}
int k = Integer.valueOf(args[2]) ;
int dim = Integer.valueOf(args[3]) ;
Job init_job = Job.getInstance() ;
Configuration init_conf = init_job.getConfiguration();
init_conf.set("kmeans.k", args[2]);
init_conf.set("kmeans.dim", args[3]);
init_job.setJarByClass(KMean.class);
init_job.setJobName("clustered kmeans");
init_job.setMapperClass(KMeanInitMapper.class);
init_job.setReducerClass(KMeanInitReducer.class);
init_job.setOutputKeyClass(IntWritable.class);
init_job.setOutputValueClass(Text.class);
FileInputFormat.addInputPath(init_job, new Path(args[0]));
//TODO check rewrite in future
FileOutputFormat.setOutputPath(init_job, new Path(args[1] + "_m_" + Integer.toString(0)));
init_job.waitForCompletion(true);
double[][] old_centroids = new double[k][dim] ;
int fi = 1 ;
long t1 = System.currentTimeMillis() ;
while(true) {
System.out.print("start iteration") ;
Job kmean_cluster_jb = Job.getInstance() ;
Configuration conf = kmean_cluster_jb.getConfiguration() ;
conf.set("kmeans.k", args[2]);
conf.set("kmeans.dim", args[3]);
kmean_cluster_jb.setJarByClass(KMean.class);
kmean_cluster_jb.setJobName("clustered kmeans");
kmean_cluster_jb.setMapperClass(KMeanIterationMapper.class);
kmean_cluster_jb.setReducerClass(KMeanIterationReducer.class);
kmean_cluster_jb.setOutputKeyClass(IntWritable.class);
kmean_cluster_jb.setOutputValueClass(Text.class);
// TODO check rewrite in future
String uri = args[1] + "_m_" + Integer.toString(fi-1) + "/part-r-00000";
Configuration temp_conf = new Configuration(); |
118 | 0 | // Bug report: cached GeoPoint is being returned as the first value.
// Wait for the 2nd value to be returned, which is hopefully not cached? | @Override
public void onLocationChanged(Location location) {
mLocation = location;
if (mLocation != null) {
// Bug report: cached GeoPoint is being returned as the first value.
// Wait for the 2nd value to be returned, which is hopefully not cached?
++mLocationCount;
InfoLogger.geolog("GeoPointActivity: " + System.currentTimeMillis() +
" onLocationChanged(" + mLocationCount + ") lat: " +
mLocation.getLatitude() + " long: " +
mLocation.getLongitude() + " acc: " +
mLocation.getAccuracy());
if (mLocationCount > 1) {
mLocationDialog.setMessage(getString(R.string.location_provider_accuracy,
mLocation.getProvider(), truncateDouble(mLocation.getAccuracy())));
if (mLocation.getAccuracy() <= mLocationAccuracy) {
returnLocation();
}
}
} else {
InfoLogger.geolog("GeoPointActivity: " + System.currentTimeMillis() +
" onLocationChanged(" + mLocationCount + ") null location");
}
} | DEFECT | true | mLocation = location;
if (mLocation != null) {
// Bug report: cached GeoPoint is being returned as the first value.
// Wait for the 2nd value to be returned, which is hopefully not cached?
++mLocationCount;
InfoLogger.geolog("GeoPointActivity: " + System.currentTimeMillis() + | @Override
public void onLocationChanged(Location location) {
mLocation = location;
if (mLocation != null) {
// Bug report: cached GeoPoint is being returned as the first value.
// Wait for the 2nd value to be returned, which is hopefully not cached?
++mLocationCount;
InfoLogger.geolog("GeoPointActivity: " + System.currentTimeMillis() +
" onLocationChanged(" + mLocationCount + ") lat: " +
mLocation.getLatitude() + " long: " +
mLocation.getLongitude() + " acc: " +
mLocation.getAccuracy());
if (mLocationCount > 1) {
mLocationDialog.setMessage(getString(R.string.location_provider_accuracy,
mLocation.getProvider(), truncateDouble(mLocation.getAccuracy())));
if (mLocation.getAccuracy() <= mLocationAccuracy) { | @Override
public void onLocationChanged(Location location) {
mLocation = location;
if (mLocation != null) {
// Bug report: cached GeoPoint is being returned as the first value.
// Wait for the 2nd value to be returned, which is hopefully not cached?
++mLocationCount;
InfoLogger.geolog("GeoPointActivity: " + System.currentTimeMillis() +
" onLocationChanged(" + mLocationCount + ") lat: " +
mLocation.getLatitude() + " long: " +
mLocation.getLongitude() + " acc: " +
mLocation.getAccuracy());
if (mLocationCount > 1) {
mLocationDialog.setMessage(getString(R.string.location_provider_accuracy,
mLocation.getProvider(), truncateDouble(mLocation.getAccuracy())));
if (mLocation.getAccuracy() <= mLocationAccuracy) {
returnLocation();
}
}
} else {
InfoLogger.geolog("GeoPointActivity: " + System.currentTimeMillis() +
" onLocationChanged(" + mLocationCount + ") null location");
}
} |
119 | 0 | /**
* Reduce la lista de vulnerabilidades de zap.
*
* @param site
* @param zapRelations
* @param groupVulnerabilities
* @throws MalformedURLException
*/ | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", ""));
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
}
}
} | NONSATD | true | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", ""));
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
}
}
} | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", ""));
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
}
}
} | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", ""));
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
}
}
} |
119 | 1 | /**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/ | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", ""));
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
}
}
} | NONSATD | true | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid()); | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid())); | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){ |
119 | 2 | //TODO: Convertir la serveridad | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", ""));
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
}
}
} | IMPLEMENTATION | true | vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid())); | * De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){ | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName()); |
119 | 3 | //TODO: Convertir la serveridad | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", ""));
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
}
}
} | IMPLEMENTATION | true | vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid())); | * De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){ | private void reduceList(Site site, Map<String, String> zapRelations,
Map<String, Vulnerability> groupVulnerabilities) throws MalformedURLException {
/**
* De las vulnerabilidades encontradas las mapeamos a objetos
* y las agrupamos por tipo de vulnerabilidad y url
*/
for (Alert alert: site.getAlerts()) {
String nameVuln = zapRelations.get(alert.getPluginid());
if(StringUtils.isBlank(nameVuln)){
Vulnerability vulnerability = new Vulnerability();
vulnerability.setName(Constantes.COMMON_MESSAGE_NOT_FOUND + alert.getName());
vulnerability.setShortName(alert.getName());
vulnerability.setLongName(alert.getName());
//TODO: Convertir la serveridad
vulnerability.setSeverity(alert.getRiskdesc().replaceAll("\\(.*\\)", "").trim());
vulnerability.setCwe(Integer.parseInt(alert.getCweid()));
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
groupVulnerabilities.put(vulnerability.getName(), vulnerability);
} else if(groupVulnerabilities.containsKey(nameVuln)){
Vulnerability vulnerability = groupVulnerabilities.get(nameVuln);
for(Endpoint endPointZap : alert.getInstances()){
if(!vulnerability.getEndpoint().stream().anyMatch(obj -> obj.getUrl().equals(getUrlWithoutParameters(endPointZap.getUrl()))
&& obj.getMethod().equals(endPointZap.getMethod()))){
vulnerability.getEndpoint().add(new Endpoint(endPointZap.getMethod(), getUrlWithoutParameters(endPointZap.getUrl())));
}
}
} else {
Vulnerability vulnerability = new Vulnerability();
vulnerability.setShortName(alert.getName()); |
24,703 | 0 | // TODO: andrus, 4/28/2006 - actually we need to analyze preloaded classes and
// see how they were annotated to choose the right access type... | @Override
public boolean onStartNode(ProjectPath path) {
JpaEntityMap entityMap = (JpaEntityMap) path.getObject();
// TODO: andrus, 4/28/2006 - actually we need to analyze preloaded classes and
// see how they were annotated to choose the right access type...
entityMap.setAccess(AccessType.FIELD);
return true;
} | DESIGN | true | public boolean onStartNode(ProjectPath path) {
JpaEntityMap entityMap = (JpaEntityMap) path.getObject();
// TODO: andrus, 4/28/2006 - actually we need to analyze preloaded classes and
// see how they were annotated to choose the right access type...
entityMap.setAccess(AccessType.FIELD);
return true; | @Override
public boolean onStartNode(ProjectPath path) {
JpaEntityMap entityMap = (JpaEntityMap) path.getObject();
// TODO: andrus, 4/28/2006 - actually we need to analyze preloaded classes and
// see how they were annotated to choose the right access type...
entityMap.setAccess(AccessType.FIELD);
return true;
} | @Override
public boolean onStartNode(ProjectPath path) {
JpaEntityMap entityMap = (JpaEntityMap) path.getObject();
// TODO: andrus, 4/28/2006 - actually we need to analyze preloaded classes and
// see how they were annotated to choose the right access type...
entityMap.setAccess(AccessType.FIELD);
return true;
} |
24,704 | 0 | // JPA Spec, 2.1.8.2 (same for all relationship owners):
// The following mapping defaults apply: [...]
// Table A contains a foreign key to table B. The foreign key column
// name is formed as the concatenation of the following: the name of
// the relationship property or field of entityA; "_" ; the name of
// the primary key column in table B. The foreign key column has the
// same type as the primary key of table B. | @Override
public boolean onStartNode(ProjectPath path) {
JpaRelationship relationship = (JpaRelationship) path.getObjectParent();
JpaJoinColumn column = (JpaJoinColumn) path.getObject();
if (column.getTable() == null) {
JpaEntity entity = path.firstInstanceOf(JpaEntity.class);
column.setTable(entity.getTable().getName());
}
// JPA Spec, 2.1.8.2 (same for all relationship owners):
// The following mapping defaults apply: [...]
// Table A contains a foreign key to table B. The foreign key column
// name is formed as the concatenation of the following: the name of
// the relationship property or field of entityA; "_" ; the name of
// the primary key column in table B. The foreign key column has the
// same type as the primary key of table B.
JpaEntityMap map = path.firstInstanceOf(JpaEntityMap.class);
JpaEntity target = map.entityForClass(relationship.getTargetEntityName());
if (target == null) {
context.recordConflict(new SimpleValidationFailure(
relationship,
"Invalid relationship target "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes() == null
|| target.getAttributes().getIds().isEmpty()) {
context.recordConflict(new SimpleValidationFailure(
target,
"Relationship target has no PK defined: "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes().getIds().size() > 1) {
// TODO: andrus, 4/30/2006 implement this; note that instead of
// checking for "attribute.getJoinColumns().isEmpty()" above,
// we'll have to match individual columns
context.recordConflict(new SimpleValidationFailure(
relationship,
"Defaults for compound FK are not implemented."));
}
else {
JpaId id = target.getAttributes().getIds().iterator().next();
String pkName = id.getColumn() != null ? id.getColumn().getName() : id
.getName();
column.setName(relationship.getName() + '_' + pkName);
column.setReferencedColumnName(id.getColumn() != null ? id
.getColumn()
.getName() : id.getName());
}
return true;
} | NONSATD | true | column.setTable(entity.getTable().getName());
}
// JPA Spec, 2.1.8.2 (same for all relationship owners):
// The following mapping defaults apply: [...]
// Table A contains a foreign key to table B. The foreign key column
// name is formed as the concatenation of the following: the name of
// the relationship property or field of entityA; "_" ; the name of
// the primary key column in table B. The foreign key column has the
// same type as the primary key of table B.
JpaEntityMap map = path.firstInstanceOf(JpaEntityMap.class);
JpaEntity target = map.entityForClass(relationship.getTargetEntityName()); | @Override
public boolean onStartNode(ProjectPath path) {
JpaRelationship relationship = (JpaRelationship) path.getObjectParent();
JpaJoinColumn column = (JpaJoinColumn) path.getObject();
if (column.getTable() == null) {
JpaEntity entity = path.firstInstanceOf(JpaEntity.class);
column.setTable(entity.getTable().getName());
}
// JPA Spec, 2.1.8.2 (same for all relationship owners):
// The following mapping defaults apply: [...]
// Table A contains a foreign key to table B. The foreign key column
// name is formed as the concatenation of the following: the name of
// the relationship property or field of entityA; "_" ; the name of
// the primary key column in table B. The foreign key column has the
// same type as the primary key of table B.
JpaEntityMap map = path.firstInstanceOf(JpaEntityMap.class);
JpaEntity target = map.entityForClass(relationship.getTargetEntityName());
if (target == null) {
context.recordConflict(new SimpleValidationFailure(
relationship,
"Invalid relationship target "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes() == null
|| target.getAttributes().getIds().isEmpty()) { | @Override
public boolean onStartNode(ProjectPath path) {
JpaRelationship relationship = (JpaRelationship) path.getObjectParent();
JpaJoinColumn column = (JpaJoinColumn) path.getObject();
if (column.getTable() == null) {
JpaEntity entity = path.firstInstanceOf(JpaEntity.class);
column.setTable(entity.getTable().getName());
}
// JPA Spec, 2.1.8.2 (same for all relationship owners):
// The following mapping defaults apply: [...]
// Table A contains a foreign key to table B. The foreign key column
// name is formed as the concatenation of the following: the name of
// the relationship property or field of entityA; "_" ; the name of
// the primary key column in table B. The foreign key column has the
// same type as the primary key of table B.
JpaEntityMap map = path.firstInstanceOf(JpaEntityMap.class);
JpaEntity target = map.entityForClass(relationship.getTargetEntityName());
if (target == null) {
context.recordConflict(new SimpleValidationFailure(
relationship,
"Invalid relationship target "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes() == null
|| target.getAttributes().getIds().isEmpty()) {
context.recordConflict(new SimpleValidationFailure(
target,
"Relationship target has no PK defined: "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes().getIds().size() > 1) {
// TODO: andrus, 4/30/2006 implement this; note that instead of
// checking for "attribute.getJoinColumns().isEmpty()" above,
// we'll have to match individual columns
context.recordConflict(new SimpleValidationFailure( |
24,704 | 1 | // TODO: andrus, 4/30/2006 implement this; note that instead of
// checking for "attribute.getJoinColumns().isEmpty()" above,
// we'll have to match individual columns | @Override
public boolean onStartNode(ProjectPath path) {
JpaRelationship relationship = (JpaRelationship) path.getObjectParent();
JpaJoinColumn column = (JpaJoinColumn) path.getObject();
if (column.getTable() == null) {
JpaEntity entity = path.firstInstanceOf(JpaEntity.class);
column.setTable(entity.getTable().getName());
}
// JPA Spec, 2.1.8.2 (same for all relationship owners):
// The following mapping defaults apply: [...]
// Table A contains a foreign key to table B. The foreign key column
// name is formed as the concatenation of the following: the name of
// the relationship property or field of entityA; "_" ; the name of
// the primary key column in table B. The foreign key column has the
// same type as the primary key of table B.
JpaEntityMap map = path.firstInstanceOf(JpaEntityMap.class);
JpaEntity target = map.entityForClass(relationship.getTargetEntityName());
if (target == null) {
context.recordConflict(new SimpleValidationFailure(
relationship,
"Invalid relationship target "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes() == null
|| target.getAttributes().getIds().isEmpty()) {
context.recordConflict(new SimpleValidationFailure(
target,
"Relationship target has no PK defined: "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes().getIds().size() > 1) {
// TODO: andrus, 4/30/2006 implement this; note that instead of
// checking for "attribute.getJoinColumns().isEmpty()" above,
// we'll have to match individual columns
context.recordConflict(new SimpleValidationFailure(
relationship,
"Defaults for compound FK are not implemented."));
}
else {
JpaId id = target.getAttributes().getIds().iterator().next();
String pkName = id.getColumn() != null ? id.getColumn().getName() : id
.getName();
column.setName(relationship.getName() + '_' + pkName);
column.setReferencedColumnName(id.getColumn() != null ? id
.getColumn()
.getName() : id.getName());
}
return true;
} | IMPLEMENTATION | true | }
else if (target.getAttributes().getIds().size() > 1) {
// TODO: andrus, 4/30/2006 implement this; note that instead of
// checking for "attribute.getJoinColumns().isEmpty()" above,
// we'll have to match individual columns
context.recordConflict(new SimpleValidationFailure(
relationship, | + relationship.getTargetEntityName()));
}
else if (target.getAttributes() == null
|| target.getAttributes().getIds().isEmpty()) {
context.recordConflict(new SimpleValidationFailure(
target,
"Relationship target has no PK defined: "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes().getIds().size() > 1) {
// TODO: andrus, 4/30/2006 implement this; note that instead of
// checking for "attribute.getJoinColumns().isEmpty()" above,
// we'll have to match individual columns
context.recordConflict(new SimpleValidationFailure(
relationship,
"Defaults for compound FK are not implemented."));
}
else {
JpaId id = target.getAttributes().getIds().iterator().next();
String pkName = id.getColumn() != null ? id.getColumn().getName() : id
.getName();
column.setName(relationship.getName() + '_' + pkName);
column.setReferencedColumnName(id.getColumn() != null ? id | // name is formed as the concatenation of the following: the name of
// the relationship property or field of entityA; "_" ; the name of
// the primary key column in table B. The foreign key column has the
// same type as the primary key of table B.
JpaEntityMap map = path.firstInstanceOf(JpaEntityMap.class);
JpaEntity target = map.entityForClass(relationship.getTargetEntityName());
if (target == null) {
context.recordConflict(new SimpleValidationFailure(
relationship,
"Invalid relationship target "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes() == null
|| target.getAttributes().getIds().isEmpty()) {
context.recordConflict(new SimpleValidationFailure(
target,
"Relationship target has no PK defined: "
+ relationship.getTargetEntityName()));
}
else if (target.getAttributes().getIds().size() > 1) {
// TODO: andrus, 4/30/2006 implement this; note that instead of
// checking for "attribute.getJoinColumns().isEmpty()" above,
// we'll have to match individual columns
context.recordConflict(new SimpleValidationFailure(
relationship,
"Defaults for compound FK are not implemented."));
}
else {
JpaId id = target.getAttributes().getIds().iterator().next();
String pkName = id.getColumn() != null ? id.getColumn().getName() : id
.getName();
column.setName(relationship.getName() + '_' + pkName);
column.setReferencedColumnName(id.getColumn() != null ? id
.getColumn()
.getName() : id.getName());
}
return true;
} |
24,712 | 0 | // TODO: optimize | public void deleteAll(User user, Conversation conversation) {
// TODO: optimize
messageRepository.getAllBySenderAndConversation(user, conversation)
.stream()
.parallel()
.forEach(this::delete);
} | DESIGN | true | public void deleteAll(User user, Conversation conversation) {
// TODO: optimize
messageRepository.getAllBySenderAndConversation(user, conversation)
.stream() | public void deleteAll(User user, Conversation conversation) {
// TODO: optimize
messageRepository.getAllBySenderAndConversation(user, conversation)
.stream()
.parallel()
.forEach(this::delete);
} | public void deleteAll(User user, Conversation conversation) {
// TODO: optimize
messageRepository.getAllBySenderAndConversation(user, conversation)
.stream()
.parallel()
.forEach(this::delete);
} |
24,717 | 0 | /**
*
* @see org.springframework.web.servlet.mvc.Controller#handleRequest(javax.servlet.http.HttpServletRequest,
* javax.servlet.http.HttpServletResponse)
*/ | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} |
24,717 | 1 | // copy study information | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) { | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis); |
24,717 | 2 | // study from TBI do not contain submission_id | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | // copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId()); | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController. | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
} |
24,717 | 3 | // FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController. | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | DEFECT | true | StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate(); | studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
} | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly(); |
24,717 | 4 | // save to db if the validated flag is updated: | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | }
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
} | StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand(); | StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo(); |
24,717 | 5 | //FIXME: display err message in GUI | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | IMPLEMENTATION | true | }
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$ | if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>(); | if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) { |
24,717 | 6 | //$NON-NLS-1$ | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | //FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
// | if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand(); | }
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) { |
24,717 | 7 | //
// Analysis | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) { | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
} |
24,717 | 8 | // Analysis Steps for Analysis and add algorithm type | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>(); | }
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) { | // FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) { |
24,717 | 9 | // analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo()); | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String(); | //
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian; | }
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step |
24,717 | 10 | // add algorithm type for analysisStepCommand | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step | algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput); | BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel()); |
24,717 | 11 | // analyzed data for each analysis step | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | // add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>(); | algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData; | // analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId()); |
24,717 | 12 | // Matrix or Tree? | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand(); | } else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId()); | if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for |
24,717 | 13 | // end for | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | }
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator()); | analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList); | // Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} |
24,717 | 14 | // add analyzedData for analysisStepCommand | public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response)
throws Exception {
Study study = ControllerUtil.findStudy(request, mStudyService);
Submission submission = (Submission) study.getSubmission();
StudyCommand studyCommand = new StudyCommand();
// copy study information
studyCommand.setStudy(study);
// study from TBI do not contain submission_id
if (submission != null) {
studyCommand.setSubmission_id(submission.getId());
}
List<Analysis> analysisList = study.getAnalyses();
List<AnalysisCommand> analysisCommandList = new ArrayList<AnalysisCommand>();
List<Analysis> changedAnalyses = new ArrayList<Analysis>();
StringBuilder errBuilder = new StringBuilder();
for (Analysis analysis : analysisList) {
// FIXME: next if block needs to me moved to the onSumbit method when
// we this controller will extend BaseFormController.
if (!analysis.getValidated()) {
ExecutionResult result = analysis.validate();
if (!result.isSuccessful()) {
errBuilder.append(result.getErrorMessage());
}
if (analysis.getValidated()) {
// save to db if the validated flag is updated:
changedAnalyses.add(analysis);
}
}
//FIXME: display err message in GUI
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(errBuilder.toString()); //$NON-NLS-1$
}
//
// Analysis
AnalysisCommand analysisCommand = new AnalysisCommand();
BeanUtils.copyProperties(analysisCommand, analysis);
// Analysis Steps for Analysis and add algorithm type
List<AnalysisStep> analysisStepList = analysis.getAnalysisStepsReadOnly();
List<AnalysisStepCommand> analysisStepCommandList = new ArrayList<AnalysisStepCommand>();
for (AnalysisStep analysisStep : analysisStepList) {
AnalysisStepCommand analysisStepCommand = new AnalysisStepCommand();
BeanUtils.copyProperties(analysisStepCommand, analysisStep);
// analysisStepCommand.setId(analysisStep.getId());
// analysisStepCommand.setSoftwareInfo(analysisStep.getSoftwareInfo());
Algorithm algorithm = analysisStep.getAlgorithmInfo();
String algorithmType = new String();
if (algorithm instanceof LikelihoodAlgorithm) {
algorithmType = Constants.ALGORITHM_LIKELIHOOD;
} else if (algorithm instanceof ParsimonyAlgorithm) {
algorithmType = Constants.ALGORITHM_PARSIMONY;
} else if (algorithm instanceof OtherAlgorithm) {
algorithmType = Constants.ALGORITHM_OTHER;
}else if (algorithm instanceof BayesianAlgorithm) {
algorithmType = Constants.ALGORITHM_Bayesian;
} else if (algorithm instanceof EvolutionAlgorithm) {
algorithmType = Constants.ALGORITHM_Evolution;
} else if (algorithm instanceof JoiningAlgorithm) {
algorithmType = Constants.ALGORITHM_Joining;
} else if (algorithm instanceof UPGMAAlgorithm) {
algorithmType = Constants.ALGORITHM_UPGMA;
}
// add algorithm type for analysisStepCommand
analysisStepCommand.setAlgorithmType(algorithmType);
// analyzed data for each analysis step
List<AnalyzedData> analyzedDataSet = analysisStep.getDataSetReadOnly();
List<AnalyzedDataCommand> analyzedDataCommandList = new ArrayList<AnalyzedDataCommand>();
// Matrix or Tree?
for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} | NONSATD | true | analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList); | analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand); | for (AnalyzedData analyzedData : analyzedDataSet) {
AnalyzedDataCommand analyzedDataCommand = new AnalyzedDataCommand();
BeanUtils.copyProperties(analyzedDataCommand, analyzedData);
String inputOutput = (analyzedData.isInputData()) ? ("Input") : ("Output");
analyzedDataCommand.setInputOutputType(inputOutput);
if (analyzedData instanceof AnalyzedMatrix) {
AnalyzedMatrix analyzedMatrix = (AnalyzedMatrix) analyzedData;
analyzedDataCommand.setDataType(Constants.MATRIX_KEY);
analyzedDataCommand.setDisplayName(analyzedMatrix.getMatrix().getTitle());
analyzedDataCommand.setId(analyzedMatrix.getId());
analyzedDataCommand.setDataId(analyzedMatrix.getMatrix().getId());
} else if (analyzedData instanceof AnalyzedTree) {
AnalyzedTree analyzedTree = (AnalyzedTree) analyzedData;
analyzedDataCommand.setDataType(Constants.TREE_KEY);
analyzedDataCommand.setDisplayName(analyzedTree.getTree().getLabel());
analyzedDataCommand.setId(analyzedTree.getId());
analyzedDataCommand.setDataId(analyzedTree.getTree().getId());
}
analyzedDataCommandList.add(analyzedDataCommand);
} // end for
// add analyzedData for analysisStepCommand
Collections.sort(analyzedDataCommandList, new AnalyzedDataComparator());
analysisStepCommand.setAnalyzedDataCommandList(analyzedDataCommandList);
analysisStepCommandList.add(analysisStepCommand);
}
analysisCommand.setAnalysisStepCommandList(analysisStepCommandList);
analysisCommandList.add(analysisCommand);
}
getStudyService().updateCollection(changedAnalyses);
studyCommand.setAnalysisCommandList(analysisCommandList);
return new ModelAndView("analysisSection", Constants.STUDY_COMMAND_KEY, studyCommand);
} |
16,532 | 0 | /**
* Return the id of the block that the spawn is happening on.
*/ | public String getBlockId() {
final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1?
return String.valueOf(Registry.BLOCK_ENTITY_TYPE.getId(be.getType()));
} | NONSATD | true | public String getBlockId() {
final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1?
return String.valueOf(Registry.BLOCK_ENTITY_TYPE.getId(be.getType()));
} | public String getBlockId() {
final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1?
return String.valueOf(Registry.BLOCK_ENTITY_TYPE.getId(be.getType()));
} | public String getBlockId() {
final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1?
return String.valueOf(Registry.BLOCK_ENTITY_TYPE.getId(be.getType()));
} |
16,532 | 1 | // FIXME do we need to check at y+1? | public String getBlockId() {
final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1?
return String.valueOf(Registry.BLOCK_ENTITY_TYPE.getId(be.getType()));
} | DEFECT | true | public String getBlockId() {
final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1?
return String.valueOf(Registry.BLOCK_ENTITY_TYPE.getId(be.getType()));
} | public String getBlockId() {
final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1?
return String.valueOf(Registry.BLOCK_ENTITY_TYPE.getId(be.getType()));
} | public String getBlockId() {
final BlockEntity be = serverWorld.getBlockEntity(this.blockPos); // FIXME do we need to check at y+1?
return String.valueOf(Registry.BLOCK_ENTITY_TYPE.getId(be.getType()));
} |
148 | 0 | /** TODO: Synchronize once per read, not once per varlet */ | private void addVar(Varlet v){
long key=key(v.chromosome, v.beginLoc);
ArrayList<Varlet> list=keymap.get(key);
assert(list!=null) : "\nCan't find "+key+" in "+keymap.keySet()+"\n";
synchronized(list){
list.add(v);
if(list.size()>=WRITE_BUFFER){
if(MERGE_EQUAL_VARLETS){
mergeEqualVarlets(list);
}else{
Collections.sort(list);
}
writeList(list);
list.clear();
}
}
} | DESIGN | true | private void addVar(Varlet v){
long key=key(v.chromosome, v.beginLoc);
ArrayList<Varlet> list=keymap.get(key);
assert(list!=null) : "\nCan't find "+key+" in "+keymap.keySet()+"\n";
synchronized(list){
list.add(v);
if(list.size()>=WRITE_BUFFER){
if(MERGE_EQUAL_VARLETS){
mergeEqualVarlets(list);
}else{
Collections.sort(list);
}
writeList(list);
list.clear();
}
}
} | private void addVar(Varlet v){
long key=key(v.chromosome, v.beginLoc);
ArrayList<Varlet> list=keymap.get(key);
assert(list!=null) : "\nCan't find "+key+" in "+keymap.keySet()+"\n";
synchronized(list){
list.add(v);
if(list.size()>=WRITE_BUFFER){
if(MERGE_EQUAL_VARLETS){
mergeEqualVarlets(list);
}else{
Collections.sort(list);
}
writeList(list);
list.clear();
}
}
} | private void addVar(Varlet v){
long key=key(v.chromosome, v.beginLoc);
ArrayList<Varlet> list=keymap.get(key);
assert(list!=null) : "\nCan't find "+key+" in "+keymap.keySet()+"\n";
synchronized(list){
list.add(v);
if(list.size()>=WRITE_BUFFER){
if(MERGE_EQUAL_VARLETS){
mergeEqualVarlets(list);
}else{
Collections.sort(list);
}
writeList(list);
list.clear();
}
}
} |
24,727 | 0 | // TODO: Not sure what to do about this now that we have base and absolute path. | @Override
public List<DeviceStorageRoot> getSecondaryDeviceStorageRoots() {
ArrayList<DeviceStorageRoot> secondaryStorageRoot = new ArrayList<>(1);
if (secondaryStoragePath != null) {
secondaryStorageRoot.add(new DeviceStorageRoot(secondaryStoragePath, secondaryStoragePath, DeviceStorageRoot.Type.SECONDARY));
}
return secondaryStorageRoot;
} | DESIGN | true | @Override
public List<DeviceStorageRoot> getSecondaryDeviceStorageRoots() {
ArrayList<DeviceStorageRoot> secondaryStorageRoot = new ArrayList<>(1);
if (secondaryStoragePath != null) {
secondaryStorageRoot.add(new DeviceStorageRoot(secondaryStoragePath, secondaryStoragePath, DeviceStorageRoot.Type.SECONDARY));
}
return secondaryStorageRoot;
} | @Override
public List<DeviceStorageRoot> getSecondaryDeviceStorageRoots() {
ArrayList<DeviceStorageRoot> secondaryStorageRoot = new ArrayList<>(1);
if (secondaryStoragePath != null) {
secondaryStorageRoot.add(new DeviceStorageRoot(secondaryStoragePath, secondaryStoragePath, DeviceStorageRoot.Type.SECONDARY));
}
return secondaryStorageRoot;
} | @Override
public List<DeviceStorageRoot> getSecondaryDeviceStorageRoots() {
ArrayList<DeviceStorageRoot> secondaryStorageRoot = new ArrayList<>(1);
if (secondaryStoragePath != null) {
secondaryStorageRoot.add(new DeviceStorageRoot(secondaryStoragePath, secondaryStoragePath, DeviceStorageRoot.Type.SECONDARY));
}
return secondaryStorageRoot;
} |
24,736 | 0 | // Prior to fix, this was throwing StringIndexOutOfBoundsException | @Test
public void testLANG1292() {
// Prior to fix, this was throwing StringIndexOutOfBoundsException
Wrap.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 70);
} | DEFECT | true | @Test
public void testLANG1292() {
// Prior to fix, this was throwing StringIndexOutOfBoundsException
Wrap.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " | @Test
public void testLANG1292() {
// Prior to fix, this was throwing StringIndexOutOfBoundsException
Wrap.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 70);
} | @Test
public void testLANG1292() {
// Prior to fix, this was throwing StringIndexOutOfBoundsException
Wrap.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 70);
} |
161 | 0 | /**
* Add several new sequences to <code>ambariSequencesTable</code>.
* @param seqNames list of sequences to be inserted
* @param seqDefaultValue initial value for the sequence
* @param ignoreFailure true to ignore insert sql errors
* @throws SQLException
*
*/ | protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException{
// ToDo: rewrite function to use one SQL call per select/insert for all items
for (String seqName: seqNames){
addSequence(seqName, seqDefaultValue, ignoreFailure);
}
} | NONSATD | true | protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException{
// ToDo: rewrite function to use one SQL call per select/insert for all items
for (String seqName: seqNames){
addSequence(seqName, seqDefaultValue, ignoreFailure);
}
} | protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException{
// ToDo: rewrite function to use one SQL call per select/insert for all items
for (String seqName: seqNames){
addSequence(seqName, seqDefaultValue, ignoreFailure);
}
} | protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException{
// ToDo: rewrite function to use one SQL call per select/insert for all items
for (String seqName: seqNames){
addSequence(seqName, seqDefaultValue, ignoreFailure);
}
} |
161 | 1 | // ToDo: rewrite function to use one SQL call per select/insert for all items | protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException{
// ToDo: rewrite function to use one SQL call per select/insert for all items
for (String seqName: seqNames){
addSequence(seqName, seqDefaultValue, ignoreFailure);
}
} | DESIGN | true | protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException{
// ToDo: rewrite function to use one SQL call per select/insert for all items
for (String seqName: seqNames){
addSequence(seqName, seqDefaultValue, ignoreFailure); | protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException{
// ToDo: rewrite function to use one SQL call per select/insert for all items
for (String seqName: seqNames){
addSequence(seqName, seqDefaultValue, ignoreFailure);
}
} | protected final void addSequences(List<String> seqNames, Long seqDefaultValue, boolean ignoreFailure) throws SQLException{
// ToDo: rewrite function to use one SQL call per select/insert for all items
for (String seqName: seqNames){
addSequence(seqName, seqDefaultValue, ignoreFailure);
}
} |
24,737 | 0 | // Prior to fix, this was throwing StringIndexOutOfBoundsException | @Test
public void testLANG1397() {
// Prior to fix, this was throwing StringIndexOutOfBoundsException
Wrap.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Integer.MAX_VALUE);
} | DEFECT | true | @Test
public void testLANG1397() {
// Prior to fix, this was throwing StringIndexOutOfBoundsException
Wrap.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa " | @Test
public void testLANG1397() {
// Prior to fix, this was throwing StringIndexOutOfBoundsException
Wrap.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Integer.MAX_VALUE);
} | @Test
public void testLANG1397() {
// Prior to fix, this was throwing StringIndexOutOfBoundsException
Wrap.wrap("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa "
+ "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", Integer.MAX_VALUE);
} |
32,941 | 0 | // this can probably work on contentValues_ | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | DESIGN | true | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) { | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
} | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N |
32,941 | 1 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 2 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 3 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 4 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 5 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 6 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 7 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 8 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 9 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 10 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
32,941 | 11 | // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N
XTCEFunctions.getText( "xml_dynamic_count_assume1" ) ); // NOI18N
return 1;
}
}
return 1;
} | NONSATD | true | }
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() ); | for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N | protected long dynamicCountFromUserValue( XTCENamedObject item, String form ) {
// this can probably work on contentValues_
String paramFullPath = item.getFullPath();
for ( XTCEContainerContentEntry entry : contentList_ ) {
if ( ( entry.getEntryType() != FieldType.PARAMETER ) &&
( entry.getEntryType() != FieldType.ARGUMENT ) ) {
continue;
}
XTCEContainerEntryValue valueObj = entry.getValue();
if ( entry.getValue() == null ) {
continue;
}
if ( entry.getItemFullPath().equals( paramFullPath ) == true ) {
if ( valueObj.getOperator().equals( "==" ) == true ) { // NOI18N
try {
return Long.parseLong( valueObj.getCalibratedValue() );
} catch ( NumberFormatException ex ) {
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_numeric_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
" (" + // NOI18N
XTCEFunctions.getText( "general_value" ) + // NOI18N
" '" + // NOI18N
valueObj.getCalibratedValue() +
"')" ); // NOI18N
return 1;
}
}
warnings_.add(
XTCEFunctions.getText( "xml_dynamic_count_missing_error" ) + // NOI18N
" " + // NOI18N
item.getName() +
", " + // NOI18N |
8,369 | 0 | // TODO
// Netty allow to set/get attachment on Channel in the near feature, e.g.
// channel.getAttribute(new AttributeKey<Endpoint>(TRANSPORT_SENDER)) | public static void attachEndpointToSession(Channel channel, Endpoint endpoint) {
// TODO
// Netty allow to set/get attachment on Channel in the near feature, e.g.
// channel.getAttribute(new AttributeKey<Endpoint>(TRANSPORT_SENDER))
endpoints.set(channel, endpoint);
} | IMPLEMENTATION | true | public static void attachEndpointToSession(Channel channel, Endpoint endpoint) {
// TODO
// Netty allow to set/get attachment on Channel in the near feature, e.g.
// channel.getAttribute(new AttributeKey<Endpoint>(TRANSPORT_SENDER))
endpoints.set(channel, endpoint);
} | public static void attachEndpointToSession(Channel channel, Endpoint endpoint) {
// TODO
// Netty allow to set/get attachment on Channel in the near feature, e.g.
// channel.getAttribute(new AttributeKey<Endpoint>(TRANSPORT_SENDER))
endpoints.set(channel, endpoint);
} | public static void attachEndpointToSession(Channel channel, Endpoint endpoint) {
// TODO
// Netty allow to set/get attachment on Channel in the near feature, e.g.
// channel.getAttribute(new AttributeKey<Endpoint>(TRANSPORT_SENDER))
endpoints.set(channel, endpoint);
} |
24,756 | 0 | //TODO Find a way to re-send the message. | public static void addChatMessageFixed(ICommandSender sender, IChatComponent message) {
if (sender == null || message == null) return;
if (sender instanceof EntityPlayerMP) {
if (((EntityPlayerMP)sender).playerNetServerHandler != null) {
sender.addChatMessage(message);
} else {
//TODO Find a way to re-send the message.
}
} else {
sender.addChatMessage(message);
}
} | IMPLEMENTATION | true | sender.addChatMessage(message);
} else {
//TODO Find a way to re-send the message.
}
} else { | public static void addChatMessageFixed(ICommandSender sender, IChatComponent message) {
if (sender == null || message == null) return;
if (sender instanceof EntityPlayerMP) {
if (((EntityPlayerMP)sender).playerNetServerHandler != null) {
sender.addChatMessage(message);
} else {
//TODO Find a way to re-send the message.
}
} else {
sender.addChatMessage(message);
}
} | public static void addChatMessageFixed(ICommandSender sender, IChatComponent message) {
if (sender == null || message == null) return;
if (sender instanceof EntityPlayerMP) {
if (((EntityPlayerMP)sender).playerNetServerHandler != null) {
sender.addChatMessage(message);
} else {
//TODO Find a way to re-send the message.
}
} else {
sender.addChatMessage(message);
}
} |
16,569 | 0 | /**
* Test a function from a Wyil file
* by executing the test with randomised parameters
* @param id The module used
* @param interpreter Whiley interpreter used to execute the function/method
* @param dec The function or method
* @param testType The type of tests to generate
* @param numTest The number of tests to execute
* @param lowerLimit The lower constraint used when generating integers
* @param upperLimit The upper constraint used when generating integers
*/ | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} |
16,569 | 1 | // Get the method for generating test values | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try { | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given."); | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name()); |
16,569 | 2 | // Get the function's relevant header information | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType(); | if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions); | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0; |
16,569 | 3 | // System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0; | return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true; | GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]); |
16,569 | 4 | // Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true; | // // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) { | Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){ |
16,569 | 5 | // Check the precondition | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters(); | for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e); | // // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS; |
16,569 | 6 | // Checks the postcondition when it is executed | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | }
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try { | catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
} | for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]); |
16,569 | 7 | // Add the return values into the frame for validation | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | }
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j); | catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try { | System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e); |
16,569 | 8 | // // Print out any return values produced | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns)); | Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) { | continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) { |
16,569 | 9 | // FIXME resolution error | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | DEFECT | true | }
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false; | catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) { | catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n", |
16,569 | 10 | // Overall test statistics | private Result executeTest(Path.ID id, QCInterpreter interpreter, Decl.FunctionOrMethod dec, TestType testType, int numTest, BigInteger lowerLimit, BigInteger upperLimit) {
// Get the method for generating test values
GenerateTest testGen;
try {
if(testType == TestType.EXHAUSTIVE) {
testGen = new ExhaustiveGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
else {
testGen = new RandomGenerateTest(dec.getParameters(), interpreter, numTest, lowerLimit, upperLimit);
}
} catch (IntegerRangeException e) {
System.out.println("Integer range was invalid for the limits given.");
return Result.ERRORS;
}
// Get the function's relevant header information
NameID name = new NameID(id, dec.getName().get());
Type.Callable type = dec.getType();
Tuple<Expr> preconditions = dec.getRequires();
Tuple<Expr> postconditions = dec.getEnsures();
Tuple<Decl.Variable> inputParameters = dec.getParameters();
Tuple<Decl.Variable> outputParameters = dec.getReturns();
System.out.println("Name of the function/method: " + name.name());
// System.out.println("FUNCTION PARAM TYPES "+ inputParameters);
// System.out.println("PRECONDITION "+ preconditions);
// System.out.println("POSTCONDITION "+ postconditions);
// // Have to remove the pre and post conditions out of the
// // function so the function is executed without validation
// // Validation will be conducted manually inside the function.
// Tuple<Expr> empty = new Tuple<Expr>();
// dec.setOperand(4, empty); // Remove precondition
// dec.setOperand(5, empty); // Remove postcondition
boolean completedAll = false;
int numSkipped = 0;
int numPassed = 0;
int numFailed = 0;
for(int i=0; i < numTest; i++) {
recursiveType.clear();
// Stop execution if all possible combinations have been generated
// Can do this for methods as well as a new call stack is created each time
if(testGen.exceedSize() && i != 0) {
completedAll = true;
break;
}
RValue[] paramValues = null;
CallStack frame = interpreter.new CallStack();
// Check the precondition
try {
paramValues = testGen.generateParameters();
for(int j=0; j < inputParameters.size(); j++) {
Decl.Variable parameter = inputParameters.get(j);
frame.putLocal(parameter.getName(), paramValues[j]);
}
interpreter.checkInvariants(frame, preconditions);
}
catch(CannotGenerateException e) {
System.out.println(e);
return Result.ERRORS;
}
catch(AssertionError e){
System.out.println("Pre-condition failed on input: " + Arrays.toString(paramValues));
numSkipped++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred when generating input " + e + ": " + e.getMessage());
return Result.ERRORS;
}
System.out.println("INPUT: " + Arrays.toString(paramValues));
// Checks the postcondition when it is executed
RValue[] returns = null;
try {
returns = interpreter.execute(name, type, frame, false, false, paramValues);
recursiveType.clear();
}
catch(AssertionError e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
numFailed++;
continue;
}
catch(RuntimeException e) {
System.out.println("Error occurred during execution " + e + ": " + e.getMessage());
return Result.ERRORS;
}
try {
// Add the return values into the frame for validation
for(int j=0; j < outputParameters.size(); j++) {
Decl.Variable parameter = outputParameters.get(j);
Type paramType = parameter.getType();
boolean valid = checkInvariant(interpreter, paramType, returns[j]);
if(!valid) {
throw new AssertionError("Type constraints for " + parameter + " failed");
}
frame.putLocal(parameter.getName(), returns[j]);
}
try {
interpreter.checkInvariants(frame, postconditions);
numPassed++;
// // Print out any return values produced
if (returns != null) {
System.out.println("OUTPUT: " + Arrays.toString(returns));
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Postcondition failed " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0;
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.PASSED;
}
else if(numSkipped == numTest) {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
else {
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numTest, numFailed, (double) 100 * numFailed/numTest, numSkipped, (double) 100 * numSkipped/numTest, numTest);
return Result.FAILED;
}
} | NONSATD | true | }
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations"); | catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else { | catch(RuntimeException e) {
System.out.println("Error when checking invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
}
catch(AssertionError e) {
System.out.printf("Failed Input: %s%nFailed Output: %s%n", Arrays.toString(paramValues), Arrays.toString(returns));
System.out.println("Due to error " + e);
numFailed++;
}
catch(RuntimeException e) {
System.out.println("Error when checking type invariants of return values " + e + ": " + e.getMessage());
return Result.ERRORS;
}
catch (ResolutionError e) {
// FIXME resolution error
e.printStackTrace();
assert false;
}
}
// Overall test statistics
if(completedAll) {
System.out.println("Tested all possible combinations");
int numActualTest = numPassed + numFailed + numSkipped;
if(numFailed == 0) {
if(numPassed > 0) {
System.out.printf("Ok: %d passed (%.2f %%), %d skipped (%.2f %%), ran %d tests %n",
numPassed, (double) 100 * numPassed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.PASSED;
}
else {
System.out.println("All tests skipped!");
return Result.SKIPPED;
}
}
System.out.printf("Failed: %d passed (%.2f %%), %d failed (%.2f %%), %d skipped (%.2f %%), ran %d tests%n",
numPassed, (double) 100 * numPassed/numActualTest, numFailed, (double) 100 * numFailed/numActualTest, numSkipped, (double) 100 * numSkipped/numActualTest, numActualTest);
return Result.FAILED;
}
else if(numPassed + numSkipped == numTest) {
assert numFailed == 0; |
32,955 | 0 | /**
* This thingy is crazy !! upgrading or improvements are forbidden ! Coded to
* Ce truc est legacy de ouf !! alors on arrête les conneries et plus de nouveaux dev dessus !
*
* @param spec
* @param artifactName
* @param groupId
* @param artifactVersion
* @param implemName
* @return
* @throws Exception
*/ | @Deprecated
public FileDataSource generatePythonImpl(File spec, String artifactName, String groupId, String artifactVersion, String implemName) throws Exception {
Yaml yaml = new Yaml();
LinkedHashMap swaggerFile = yaml.load(FileUtils.openInputStream(spec));
String groupIdApi = getPropInSwaggerFile(swaggerFile, "x-groupId");
String artifactNameApi = getPropInSwaggerFile(swaggerFile, "x-artifactName");
String artifactVersionApi = getPropInSwaggerFile(swaggerFile, "version");
String groupName = groupId.substring(groupId.lastIndexOf('.') + 1);
StringBuilder artifactIdSb = new StringBuilder().append(groupName).append("-").append(artifactNameApi).append("-");
artifactIdSb.append(artifactName.replaceAll("-",""));
CodegenConfigurator configurator = new CodegenConfigurator();
String artifactId = artifactIdSb.toString();
initializeConfigurator(spec, "KathraPython", artifactNameApi, groupIdApi, artifactVersion, "implem", artifactId, configurator);
configurator.setArtifactVersionApi(artifactVersionApi);
return getFileDataSource(spec, "implem", artifactIdSb, artifactId, configurator);
} | DESIGN | true | @Deprecated
public FileDataSource generatePythonImpl(File spec, String artifactName, String groupId, String artifactVersion, String implemName) throws Exception {
Yaml yaml = new Yaml();
LinkedHashMap swaggerFile = yaml.load(FileUtils.openInputStream(spec));
String groupIdApi = getPropInSwaggerFile(swaggerFile, "x-groupId");
String artifactNameApi = getPropInSwaggerFile(swaggerFile, "x-artifactName");
String artifactVersionApi = getPropInSwaggerFile(swaggerFile, "version");
String groupName = groupId.substring(groupId.lastIndexOf('.') + 1);
StringBuilder artifactIdSb = new StringBuilder().append(groupName).append("-").append(artifactNameApi).append("-");
artifactIdSb.append(artifactName.replaceAll("-",""));
CodegenConfigurator configurator = new CodegenConfigurator();
String artifactId = artifactIdSb.toString();
initializeConfigurator(spec, "KathraPython", artifactNameApi, groupIdApi, artifactVersion, "implem", artifactId, configurator);
configurator.setArtifactVersionApi(artifactVersionApi);
return getFileDataSource(spec, "implem", artifactIdSb, artifactId, configurator);
} | @Deprecated
public FileDataSource generatePythonImpl(File spec, String artifactName, String groupId, String artifactVersion, String implemName) throws Exception {
Yaml yaml = new Yaml();
LinkedHashMap swaggerFile = yaml.load(FileUtils.openInputStream(spec));
String groupIdApi = getPropInSwaggerFile(swaggerFile, "x-groupId");
String artifactNameApi = getPropInSwaggerFile(swaggerFile, "x-artifactName");
String artifactVersionApi = getPropInSwaggerFile(swaggerFile, "version");
String groupName = groupId.substring(groupId.lastIndexOf('.') + 1);
StringBuilder artifactIdSb = new StringBuilder().append(groupName).append("-").append(artifactNameApi).append("-");
artifactIdSb.append(artifactName.replaceAll("-",""));
CodegenConfigurator configurator = new CodegenConfigurator();
String artifactId = artifactIdSb.toString();
initializeConfigurator(spec, "KathraPython", artifactNameApi, groupIdApi, artifactVersion, "implem", artifactId, configurator);
configurator.setArtifactVersionApi(artifactVersionApi);
return getFileDataSource(spec, "implem", artifactIdSb, artifactId, configurator);
} | @Deprecated
public FileDataSource generatePythonImpl(File spec, String artifactName, String groupId, String artifactVersion, String implemName) throws Exception {
Yaml yaml = new Yaml();
LinkedHashMap swaggerFile = yaml.load(FileUtils.openInputStream(spec));
String groupIdApi = getPropInSwaggerFile(swaggerFile, "x-groupId");
String artifactNameApi = getPropInSwaggerFile(swaggerFile, "x-artifactName");
String artifactVersionApi = getPropInSwaggerFile(swaggerFile, "version");
String groupName = groupId.substring(groupId.lastIndexOf('.') + 1);
StringBuilder artifactIdSb = new StringBuilder().append(groupName).append("-").append(artifactNameApi).append("-");
artifactIdSb.append(artifactName.replaceAll("-",""));
CodegenConfigurator configurator = new CodegenConfigurator();
String artifactId = artifactIdSb.toString();
initializeConfigurator(spec, "KathraPython", artifactNameApi, groupIdApi, artifactVersion, "implem", artifactId, configurator);
configurator.setArtifactVersionApi(artifactVersionApi);
return getFileDataSource(spec, "implem", artifactIdSb, artifactId, configurator);
} |
8,382 | 0 | /*
* TODO: Doc
*/ | public String parseId() throws SyntaxError {
String value = parseArg();
if (argWasQuoted()) {
throw new SyntaxError("Expected identifier instead of quoted string:" + value);
} else if (value == null) {
throw new SyntaxError("Expected identifier instead of 'null' for function " + sp);
}
return value;
} | DOCUMENTATION | true | public String parseId() throws SyntaxError {
String value = parseArg();
if (argWasQuoted()) {
throw new SyntaxError("Expected identifier instead of quoted string:" + value);
} else if (value == null) {
throw new SyntaxError("Expected identifier instead of 'null' for function " + sp);
}
return value;
} | public String parseId() throws SyntaxError {
String value = parseArg();
if (argWasQuoted()) {
throw new SyntaxError("Expected identifier instead of quoted string:" + value);
} else if (value == null) {
throw new SyntaxError("Expected identifier instead of 'null' for function " + sp);
}
return value;
} | public String parseId() throws SyntaxError {
String value = parseArg();
if (argWasQuoted()) {
throw new SyntaxError("Expected identifier instead of quoted string:" + value);
} else if (value == null) {
throw new SyntaxError("Expected identifier instead of 'null' for function " + sp);
}
return value;
} |
8,383 | 0 | /*
* TODO: Doc
*/ | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | DOCUMENTATION | true | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} |
8,383 | 1 | // nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | NONSATD | true | qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'"); | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams()); | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')'); |
8,383 | 2 | // value specified directly in local params... so the end of the
// query should be the end of the local params. | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | NONSATD | true | if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else { | }
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'"); | if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter(); |
8,383 | 3 | // value here is *after* the local params... ask the parser. | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | NONSATD | true | sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')'); | String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery(); | nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} |
8,383 | 4 | // int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | IMPLEMENTATION | true | // value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
} | int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) { | // Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} |
8,383 | 5 | // advance past nested query | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | NONSATD | true | throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned | } else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} |
8,383 | 6 | // handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces | public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
String param = sp.getId();
String qstr = getParam(param);
qstr = qstr==null ? "" : qstr;
nestedQuery = subQuery(qstr, null).getQuery();
// nestedQuery would be null when de-referenced query value is not specified
// Ex: query($qq) in request with no qq param specified
if (nestedQuery == null) {
throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
}
else {
int start = sp.pos;
String v = sp.val;
String qs = v;
ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | NONSATD | true | sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'"); | sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} | ModifiableSolrParams nestedLocalParams = new ModifiableSolrParams();
int end = QueryParsing.parseLocalParams(qs, start, nestedLocalParams, getParams());
QParser sub;
if (end>start) {
if (nestedLocalParams.get(QueryParsing.V) != null) {
// value specified directly in local params... so the end of the
// query should be the end of the local params.
sub = subQuery(qs.substring(start, end), null);
} else {
// value here is *after* the local params... ask the parser.
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
nestedQuery = sub.getQuery();
// handling null check on nestedQuery separately, so that proper error can be returned
// one case this would be possible when v is specified but v's value is empty or has only spaces
if (nestedQuery == null) {
throw new SyntaxError("Nested function query returned null for '" + sp.val + "'");
}
}
consumeArgumentDelimiter();
return nestedQuery;
} |
16,576 | 0 | // TODO: can we guarantee that the refcount var is available in the
// current scope? | public void dumpDecrements(Block block, RCTracker increments) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.DECR)) {
assert (e.getValue() <= 0);
Var var = increments.getRefCountVar(e.getKey());
if (RefCounting.trackRefCount(var, rcType)) {
Arg amount = Arg.newInt(e.getValue() * -1);
block.addCleanup(var, RefCountOp.decrRef(rcType, var, amount));
}
}
}
// Clear out all decrements
increments.resetAll(RCDir.DECR);
} | DESIGN | true | public void dumpDecrements(Block block, RCTracker increments) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.DECR)) { | public void dumpDecrements(Block block, RCTracker increments) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.DECR)) {
assert (e.getValue() <= 0);
Var var = increments.getRefCountVar(e.getKey());
if (RefCounting.trackRefCount(var, rcType)) {
Arg amount = Arg.newInt(e.getValue() * -1);
block.addCleanup(var, RefCountOp.decrRef(rcType, var, amount));
}
}
} | public void dumpDecrements(Block block, RCTracker increments) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.DECR)) {
assert (e.getValue() <= 0);
Var var = increments.getRefCountVar(e.getKey());
if (RefCounting.trackRefCount(var, rcType)) {
Arg amount = Arg.newInt(e.getValue() * -1);
block.addCleanup(var, RefCountOp.decrRef(rcType, var, amount));
}
}
}
// Clear out all decrements
increments.resetAll(RCDir.DECR);
} |
16,576 | 1 | // Clear out all decrements | public void dumpDecrements(Block block, RCTracker increments) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.DECR)) {
assert (e.getValue() <= 0);
Var var = increments.getRefCountVar(e.getKey());
if (RefCounting.trackRefCount(var, rcType)) {
Arg amount = Arg.newInt(e.getValue() * -1);
block.addCleanup(var, RefCountOp.decrRef(rcType, var, amount));
}
}
}
// Clear out all decrements
increments.resetAll(RCDir.DECR);
} | NONSATD | true | }
}
// Clear out all decrements
increments.resetAll(RCDir.DECR);
} | for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.DECR)) {
assert (e.getValue() <= 0);
Var var = increments.getRefCountVar(e.getKey());
if (RefCounting.trackRefCount(var, rcType)) {
Arg amount = Arg.newInt(e.getValue() * -1);
block.addCleanup(var, RefCountOp.decrRef(rcType, var, amount));
}
}
}
// Clear out all decrements
increments.resetAll(RCDir.DECR);
} | public void dumpDecrements(Block block, RCTracker increments) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.DECR)) {
assert (e.getValue() <= 0);
Var var = increments.getRefCountVar(e.getKey());
if (RefCounting.trackRefCount(var, rcType)) {
Arg amount = Arg.newInt(e.getValue() * -1);
block.addCleanup(var, RefCountOp.decrRef(rcType, var, amount));
}
}
}
// Clear out all decrements
increments.resetAll(RCDir.DECR);
} |
16,577 | 0 | /**
* Insert all reference increments and decrements in place
*
* @param stmt the statement to insert before or after
* null indicates end of the block
* @param stmtIt
* @param increments
*/ | public void dumpIncrements(Statement stmt, Block block,
ListIterator<Statement> stmtIt, RCTracker increments) {
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.INCR)) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} | NONSATD | true | public void dumpIncrements(Statement stmt, Block block,
ListIterator<Statement> stmtIt, RCTracker increments) {
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.INCR)) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} | public void dumpIncrements(Statement stmt, Block block,
ListIterator<Statement> stmtIt, RCTracker increments) {
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.INCR)) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} | public void dumpIncrements(Statement stmt, Block block,
ListIterator<Statement> stmtIt, RCTracker increments) {
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.INCR)) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} |
16,577 | 2 | // TODO: what if not initialized in a conditional? Should insert before | public void dumpIncrements(Statement stmt, Block block,
ListIterator<Statement> stmtIt, RCTracker increments) {
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.INCR)) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} | DESIGN | true | stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION && | // TODO: can we guarantee that the refcount var is available in the
// current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
} | public void dumpIncrements(Statement stmt, Block block,
ListIterator<Statement> stmtIt, RCTracker increments) {
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.INCR)) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} |
16,577 | 3 | // Clear out all increments | public void dumpIncrements(Statement stmt, Block block,
ListIterator<Statement> stmtIt, RCTracker increments) {
for (RefCountType rcType: RefcountPass.RC_TYPES) {
for (Entry<AliasKey, Long> e: increments.rcIter(rcType, RCDir.INCR)) {
// TODO: can we guarantee that the refcount var is available in the
// current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} | NONSATD | true | }
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} | if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} | // current scope?
Var var = increments.getRefCountVar(e.getKey());
assert(var != null);
Long incr = e.getValue();
assert(incr >= 0);
if (incr > 0 && RefCounting.trackRefCount(var, rcType)) {
boolean varInit = stmt != null &&
stmt.type() == StatementType.INSTRUCTION &&
stmt.instruction().isInitialized(var);
// TODO: what if not initialized in a conditional? Should insert before
if (stmt != null &&
(stmt.type() == StatementType.INSTRUCTION &&
!(var.storage() == Alloc.ALIAS && varInit))) {
insertIncrBefore(block, stmtIt, var, incr, rcType);
} else {
insertIncrAfter(block, stmtIt, var, incr, rcType);
}
}
}
}
// Clear out all increments
increments.resetAll(RCDir.INCR);
} |
24,782 | 0 | // we don't have to implement this method | private void searchTweets(final String keyword) {
safelyUnsubscribe(subDelayedSearch, subLoadMoreTweets, subSearchTweets);
lastKeyword = keyword;
if (!networkApi.isConnectedToInternet(this)) {
showSnackBar(msgNoInternetConnection);
return;
}
if (!twitterApi.canSearchTweets(keyword)) {
return;
}
subSearchTweets = twitterApi.searchTweets(keyword)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<List<Status>>() {
@Override
public void onStart() {
}
@Override
public void onCompleted() {
// we don't have to implement this method
}
@Override
public void onError(final Throwable e) {
final String message = getErrorMessage((TwitterException) e);
showSnackBar(message);
showErrorMessageContainer(message, R.drawable.no_tweets);
}
@Override
public void onNext(final List<Status> tweets) {
handleSearchResults(tweets, keyword);
}
});
} | NONSATD | true | @Override
public void onCompleted() {
// we don't have to implement this method
}
@Override | }
subSearchTweets = twitterApi.searchTweets(keyword)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<List<Status>>() {
@Override
public void onStart() {
}
@Override
public void onCompleted() {
// we don't have to implement this method
}
@Override
public void onError(final Throwable e) {
final String message = getErrorMessage((TwitterException) e);
showSnackBar(message);
showErrorMessageContainer(message, R.drawable.no_tweets);
}
@Override
public void onNext(final List<Status> tweets) {
handleSearchResults(tweets, keyword); | private void searchTweets(final String keyword) {
safelyUnsubscribe(subDelayedSearch, subLoadMoreTweets, subSearchTweets);
lastKeyword = keyword;
if (!networkApi.isConnectedToInternet(this)) {
showSnackBar(msgNoInternetConnection);
return;
}
if (!twitterApi.canSearchTweets(keyword)) {
return;
}
subSearchTweets = twitterApi.searchTweets(keyword)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<List<Status>>() {
@Override
public void onStart() {
}
@Override
public void onCompleted() {
// we don't have to implement this method
}
@Override
public void onError(final Throwable e) {
final String message = getErrorMessage((TwitterException) e);
showSnackBar(message);
showErrorMessageContainer(message, R.drawable.no_tweets);
}
@Override
public void onNext(final List<Status> tweets) {
handleSearchResults(tweets, keyword);
}
});
} |
16,595 | 0 | /** @todo fix this! */
//assertConsoleOutput(list, "[['bob':'drools', 'james':'geronimo']]"); | public void testPrint() throws Exception {
Map map = new HashMap();
map.put("bob", "drools");
map.put("james", "geronimo");
List list = new ArrayList();
list.add(map);
/** @todo fix this! */
//assertConsoleOutput(list, "[['bob':'drools', 'james':'geronimo']]");
} | DEFECT | true | List list = new ArrayList();
list.add(map);
/** @todo fix this! */
//assertConsoleOutput(list, "[['bob':'drools', 'james':'geronimo']]");
} | public void testPrint() throws Exception {
Map map = new HashMap();
map.put("bob", "drools");
map.put("james", "geronimo");
List list = new ArrayList();
list.add(map);
/** @todo fix this! */
//assertConsoleOutput(list, "[['bob':'drools', 'james':'geronimo']]");
} | public void testPrint() throws Exception {
Map map = new HashMap();
map.put("bob", "drools");
map.put("james", "geronimo");
List list = new ArrayList();
list.add(map);
/** @todo fix this! */
//assertConsoleOutput(list, "[['bob':'drools', 'james':'geronimo']]");
} |
32,983 | 0 | // TODO Adjust properties | private static void registerFluids(BlockRegistry blockRegistry) {
// TODO Adjust properties
Fluid steam = new Fluid("steam", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true)
.setTemperature(1000).setViscosity(200);
if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam);
}
blockRegistry.register(new BlockSARFluid("steam", FluidRegistry.getFluid("steam"), Material.LAVA));
Fluid sulphur_dioxide = new Fluid("sulphur_dioxide",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide_flow")).setViscosity(250)
.setGaseous(true).setDensity(-100);
FluidRegistry.registerFluid(sulphur_dioxide);
FluidRegistry.addBucketForFluid(sulphur_dioxide);
blockRegistry.register(new BlockDamagingFluid("sulphur_dioxide", FluidRegistry.getFluid("sulphur_dioxide"),
Material.WATER, SARBlocks.damageSourceGas, 2));
Fluid sulphuric_acid = new Fluid("sulphuric_acid",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid_flow")).setViscosity(500);
FluidRegistry.registerFluid(sulphuric_acid);
FluidRegistry.addBucketForFluid(sulphuric_acid);
blockRegistry.register(new BlockAcidFluid("sulphuric_acid", FluidRegistry.getFluid("sulphuric_acid"),
Material.WATER, SARBlocks.damageSourceAcid, 4));
// TODO TE compat?
Fluid liquid_glowstone = new Fluid("liquid_glowstone",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone_flow")).setViscosity(2000)
.setGaseous(true);
FluidRegistry.registerFluid(liquid_glowstone);
FluidRegistry.addBucketForFluid(liquid_glowstone);
blockRegistry.register(new BlockLiquidGlowstone("liquid_glowstone", FluidRegistry.getFluid("liquid_glowstone"),
Material.LAVA));
Fluid potion = new Fluid("potion", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution_flowing")) {
@SuppressWarnings("deprecation")
@Override
public String getLocalizedName(FluidStack stack) {
return I18n.translateToLocal(
PotionUtils.getPotionTypeFromNBT(stack.tag).getNamePrefixed("potion.effect."));
}
@Override
public int getColor(FluidStack stack) {
return PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromTag(stack.tag));
}
};
FluidRegistry.registerFluid(potion);
FluidRegistry.addBucketForFluid(potion);
FluidRegistry
.registerFluid(new Fluid("slime", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution")) {
@Override
public int getColor() {
return Color.GREEN.getRGB();
}
});
} | IMPLEMENTATION | true | private static void registerFluids(BlockRegistry blockRegistry) {
// TODO Adjust properties
Fluid steam = new Fluid("steam", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true) | private static void registerFluids(BlockRegistry blockRegistry) {
// TODO Adjust properties
Fluid steam = new Fluid("steam", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true)
.setTemperature(1000).setViscosity(200);
if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam);
}
blockRegistry.register(new BlockSARFluid("steam", FluidRegistry.getFluid("steam"), Material.LAVA));
Fluid sulphur_dioxide = new Fluid("sulphur_dioxide",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide"), | private static void registerFluids(BlockRegistry blockRegistry) {
// TODO Adjust properties
Fluid steam = new Fluid("steam", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true)
.setTemperature(1000).setViscosity(200);
if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam);
}
blockRegistry.register(new BlockSARFluid("steam", FluidRegistry.getFluid("steam"), Material.LAVA));
Fluid sulphur_dioxide = new Fluid("sulphur_dioxide",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide_flow")).setViscosity(250)
.setGaseous(true).setDensity(-100);
FluidRegistry.registerFluid(sulphur_dioxide);
FluidRegistry.addBucketForFluid(sulphur_dioxide);
blockRegistry.register(new BlockDamagingFluid("sulphur_dioxide", FluidRegistry.getFluid("sulphur_dioxide"),
Material.WATER, SARBlocks.damageSourceGas, 2));
Fluid sulphuric_acid = new Fluid("sulphuric_acid",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid_flow")).setViscosity(500);
FluidRegistry.registerFluid(sulphuric_acid); |
32,983 | 1 | // Soft registration | private static void registerFluids(BlockRegistry blockRegistry) {
// TODO Adjust properties
Fluid steam = new Fluid("steam", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true)
.setTemperature(1000).setViscosity(200);
if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam);
}
blockRegistry.register(new BlockSARFluid("steam", FluidRegistry.getFluid("steam"), Material.LAVA));
Fluid sulphur_dioxide = new Fluid("sulphur_dioxide",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide_flow")).setViscosity(250)
.setGaseous(true).setDensity(-100);
FluidRegistry.registerFluid(sulphur_dioxide);
FluidRegistry.addBucketForFluid(sulphur_dioxide);
blockRegistry.register(new BlockDamagingFluid("sulphur_dioxide", FluidRegistry.getFluid("sulphur_dioxide"),
Material.WATER, SARBlocks.damageSourceGas, 2));
Fluid sulphuric_acid = new Fluid("sulphuric_acid",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid_flow")).setViscosity(500);
FluidRegistry.registerFluid(sulphuric_acid);
FluidRegistry.addBucketForFluid(sulphuric_acid);
blockRegistry.register(new BlockAcidFluid("sulphuric_acid", FluidRegistry.getFluid("sulphuric_acid"),
Material.WATER, SARBlocks.damageSourceAcid, 4));
// TODO TE compat?
Fluid liquid_glowstone = new Fluid("liquid_glowstone",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone_flow")).setViscosity(2000)
.setGaseous(true);
FluidRegistry.registerFluid(liquid_glowstone);
FluidRegistry.addBucketForFluid(liquid_glowstone);
blockRegistry.register(new BlockLiquidGlowstone("liquid_glowstone", FluidRegistry.getFluid("liquid_glowstone"),
Material.LAVA));
Fluid potion = new Fluid("potion", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution_flowing")) {
@SuppressWarnings("deprecation")
@Override
public String getLocalizedName(FluidStack stack) {
return I18n.translateToLocal(
PotionUtils.getPotionTypeFromNBT(stack.tag).getNamePrefixed("potion.effect."));
}
@Override
public int getColor(FluidStack stack) {
return PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromTag(stack.tag));
}
};
FluidRegistry.registerFluid(potion);
FluidRegistry.addBucketForFluid(potion);
FluidRegistry
.registerFluid(new Fluid("slime", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution")) {
@Override
public int getColor() {
return Color.GREEN.getRGB();
}
});
} | NONSATD | true | new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true)
.setTemperature(1000).setViscosity(200);
if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam); | private static void registerFluids(BlockRegistry blockRegistry) {
// TODO Adjust properties
Fluid steam = new Fluid("steam", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true)
.setTemperature(1000).setViscosity(200);
if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam);
}
blockRegistry.register(new BlockSARFluid("steam", FluidRegistry.getFluid("steam"), Material.LAVA));
Fluid sulphur_dioxide = new Fluid("sulphur_dioxide",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide_flow")).setViscosity(250)
.setGaseous(true).setDensity(-100);
FluidRegistry.registerFluid(sulphur_dioxide);
FluidRegistry.addBucketForFluid(sulphur_dioxide); | private static void registerFluids(BlockRegistry blockRegistry) {
// TODO Adjust properties
Fluid steam = new Fluid("steam", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true)
.setTemperature(1000).setViscosity(200);
if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam);
}
blockRegistry.register(new BlockSARFluid("steam", FluidRegistry.getFluid("steam"), Material.LAVA));
Fluid sulphur_dioxide = new Fluid("sulphur_dioxide",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide_flow")).setViscosity(250)
.setGaseous(true).setDensity(-100);
FluidRegistry.registerFluid(sulphur_dioxide);
FluidRegistry.addBucketForFluid(sulphur_dioxide);
blockRegistry.register(new BlockDamagingFluid("sulphur_dioxide", FluidRegistry.getFluid("sulphur_dioxide"),
Material.WATER, SARBlocks.damageSourceGas, 2));
Fluid sulphuric_acid = new Fluid("sulphuric_acid",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid_flow")).setViscosity(500);
FluidRegistry.registerFluid(sulphuric_acid);
FluidRegistry.addBucketForFluid(sulphuric_acid);
blockRegistry.register(new BlockAcidFluid("sulphuric_acid", FluidRegistry.getFluid("sulphuric_acid"),
Material.WATER, SARBlocks.damageSourceAcid, 4));
// TODO TE compat? |
32,983 | 2 | // TODO TE compat? | private static void registerFluids(BlockRegistry blockRegistry) {
// TODO Adjust properties
Fluid steam = new Fluid("steam", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/steam_flow")).setGaseous(true)
.setTemperature(1000).setViscosity(200);
if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam);
}
blockRegistry.register(new BlockSARFluid("steam", FluidRegistry.getFluid("steam"), Material.LAVA));
Fluid sulphur_dioxide = new Fluid("sulphur_dioxide",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide_flow")).setViscosity(250)
.setGaseous(true).setDensity(-100);
FluidRegistry.registerFluid(sulphur_dioxide);
FluidRegistry.addBucketForFluid(sulphur_dioxide);
blockRegistry.register(new BlockDamagingFluid("sulphur_dioxide", FluidRegistry.getFluid("sulphur_dioxide"),
Material.WATER, SARBlocks.damageSourceGas, 2));
Fluid sulphuric_acid = new Fluid("sulphuric_acid",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid_flow")).setViscosity(500);
FluidRegistry.registerFluid(sulphuric_acid);
FluidRegistry.addBucketForFluid(sulphuric_acid);
blockRegistry.register(new BlockAcidFluid("sulphuric_acid", FluidRegistry.getFluid("sulphuric_acid"),
Material.WATER, SARBlocks.damageSourceAcid, 4));
// TODO TE compat?
Fluid liquid_glowstone = new Fluid("liquid_glowstone",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone_flow")).setViscosity(2000)
.setGaseous(true);
FluidRegistry.registerFluid(liquid_glowstone);
FluidRegistry.addBucketForFluid(liquid_glowstone);
blockRegistry.register(new BlockLiquidGlowstone("liquid_glowstone", FluidRegistry.getFluid("liquid_glowstone"),
Material.LAVA));
Fluid potion = new Fluid("potion", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution_flowing")) {
@SuppressWarnings("deprecation")
@Override
public String getLocalizedName(FluidStack stack) {
return I18n.translateToLocal(
PotionUtils.getPotionTypeFromNBT(stack.tag).getNamePrefixed("potion.effect."));
}
@Override
public int getColor(FluidStack stack) {
return PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromTag(stack.tag));
}
};
FluidRegistry.registerFluid(potion);
FluidRegistry.addBucketForFluid(potion);
FluidRegistry
.registerFluid(new Fluid("slime", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution")) {
@Override
public int getColor() {
return Color.GREEN.getRGB();
}
});
} | DESIGN | true | blockRegistry.register(new BlockAcidFluid("sulphuric_acid", FluidRegistry.getFluid("sulphuric_acid"),
Material.WATER, SARBlocks.damageSourceAcid, 4));
// TODO TE compat?
Fluid liquid_glowstone = new Fluid("liquid_glowstone",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone"), | FluidRegistry.addBucketForFluid(sulphur_dioxide);
blockRegistry.register(new BlockDamagingFluid("sulphur_dioxide", FluidRegistry.getFluid("sulphur_dioxide"),
Material.WATER, SARBlocks.damageSourceGas, 2));
Fluid sulphuric_acid = new Fluid("sulphuric_acid",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid_flow")).setViscosity(500);
FluidRegistry.registerFluid(sulphuric_acid);
FluidRegistry.addBucketForFluid(sulphuric_acid);
blockRegistry.register(new BlockAcidFluid("sulphuric_acid", FluidRegistry.getFluid("sulphuric_acid"),
Material.WATER, SARBlocks.damageSourceAcid, 4));
// TODO TE compat?
Fluid liquid_glowstone = new Fluid("liquid_glowstone",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone_flow")).setViscosity(2000)
.setGaseous(true);
FluidRegistry.registerFluid(liquid_glowstone);
FluidRegistry.addBucketForFluid(liquid_glowstone);
blockRegistry.register(new BlockLiquidGlowstone("liquid_glowstone", FluidRegistry.getFluid("liquid_glowstone"),
Material.LAVA));
Fluid potion = new Fluid("potion", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution_flowing")) { | if(!(FluidRegistry.isFluidRegistered(steam))) { // Soft registration
FluidRegistry.registerFluid(steam);
FluidRegistry.addBucketForFluid(steam);
}
blockRegistry.register(new BlockSARFluid("steam", FluidRegistry.getFluid("steam"), Material.LAVA));
Fluid sulphur_dioxide = new Fluid("sulphur_dioxide",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphur_dioxide_flow")).setViscosity(250)
.setGaseous(true).setDensity(-100);
FluidRegistry.registerFluid(sulphur_dioxide);
FluidRegistry.addBucketForFluid(sulphur_dioxide);
blockRegistry.register(new BlockDamagingFluid("sulphur_dioxide", FluidRegistry.getFluid("sulphur_dioxide"),
Material.WATER, SARBlocks.damageSourceGas, 2));
Fluid sulphuric_acid = new Fluid("sulphuric_acid",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/sulphuric_acid_flow")).setViscosity(500);
FluidRegistry.registerFluid(sulphuric_acid);
FluidRegistry.addBucketForFluid(sulphuric_acid);
blockRegistry.register(new BlockAcidFluid("sulphuric_acid", FluidRegistry.getFluid("sulphuric_acid"),
Material.WATER, SARBlocks.damageSourceAcid, 4));
// TODO TE compat?
Fluid liquid_glowstone = new Fluid("liquid_glowstone",
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/liquid_glowstone_flow")).setViscosity(2000)
.setGaseous(true);
FluidRegistry.registerFluid(liquid_glowstone);
FluidRegistry.addBucketForFluid(liquid_glowstone);
blockRegistry.register(new BlockLiquidGlowstone("liquid_glowstone", FluidRegistry.getFluid("liquid_glowstone"),
Material.LAVA));
Fluid potion = new Fluid("potion", new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution"),
new ResourceLocation(SteamAgeRevolution.MODID, "fluids/solution_flowing")) {
@SuppressWarnings("deprecation")
@Override
public String getLocalizedName(FluidStack stack) {
return I18n.translateToLocal(
PotionUtils.getPotionTypeFromNBT(stack.tag).getNamePrefixed("potion.effect."));
}
@Override
public int getColor(FluidStack stack) {
return PotionUtils.getPotionColorFromEffectList(PotionUtils.getEffectsFromTag(stack.tag));
} |
8,408 | 0 | // TODO load all expected impl classes, allowing fail fast rather than waiting for user to hit a certain use case | private synchronized static void initializeImplClasses() {
log.trace("exec");
// TODO load all expected impl classes, allowing fail fast rather than waiting for user to hit a certain use case
} | IMPLEMENTATION | true | private synchronized static void initializeImplClasses() {
log.trace("exec");
// TODO load all expected impl classes, allowing fail fast rather than waiting for user to hit a certain use case
} | private synchronized static void initializeImplClasses() {
log.trace("exec");
// TODO load all expected impl classes, allowing fail fast rather than waiting for user to hit a certain use case
} | private synchronized static void initializeImplClasses() {
log.trace("exec");
// TODO load all expected impl classes, allowing fail fast rather than waiting for user to hit a certain use case
} |
8,419 | 0 | // TODO, assume the url is a file path for now. | @GET
@Path("getDefaultNotebook")
@Produces(MediaType.TEXT_PLAIN)
public String getDefaultNotebook() {
final String defaultNotebookUrl = this.bkConfig.getDefaultNotebookUrl();
// TODO, assume the url is a file path for now.
java.nio.file.Path defaultNotebookFile = Paths.get(defaultNotebookUrl);
String content = this.utils.readFile(defaultNotebookFile);
if (content == null) {
System.out.println("Warning, default notebook is empty");
return "";
}
return clean(content);
} | DESIGN | true | public String getDefaultNotebook() {
final String defaultNotebookUrl = this.bkConfig.getDefaultNotebookUrl();
// TODO, assume the url is a file path for now.
java.nio.file.Path defaultNotebookFile = Paths.get(defaultNotebookUrl);
String content = this.utils.readFile(defaultNotebookFile); | @GET
@Path("getDefaultNotebook")
@Produces(MediaType.TEXT_PLAIN)
public String getDefaultNotebook() {
final String defaultNotebookUrl = this.bkConfig.getDefaultNotebookUrl();
// TODO, assume the url is a file path for now.
java.nio.file.Path defaultNotebookFile = Paths.get(defaultNotebookUrl);
String content = this.utils.readFile(defaultNotebookFile);
if (content == null) {
System.out.println("Warning, default notebook is empty");
return "";
}
return clean(content);
} | @GET
@Path("getDefaultNotebook")
@Produces(MediaType.TEXT_PLAIN)
public String getDefaultNotebook() {
final String defaultNotebookUrl = this.bkConfig.getDefaultNotebookUrl();
// TODO, assume the url is a file path for now.
java.nio.file.Path defaultNotebookFile = Paths.get(defaultNotebookUrl);
String content = this.utils.readFile(defaultNotebookFile);
if (content == null) {
System.out.println("Warning, default notebook is empty");
return "";
}
return clean(content);
} |
24,804 | 0 | /**
* 获取登记台签字
*
* @author fuxin
* @date 2017年12月28日 上午12:20:22
* @description TODO
* @param childVaccinaterecord
* @param maplist
* @param code
*
*/ | @SuppressWarnings("restriction")
private void updateDJTSign(ChildVaccinaterecord childVaccinaterecord, Map<String, Object> maplist,
Map<String, Object> code) {
logger.info("获取排号签字数据开始" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
Object signObjVaccid = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
logger.info("signObjVaccid-->" + (signObjVaccid == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
Object signObj = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
logger.info("signObj-->" + (signObj == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
if (signObj == null) {
signObj = signObjVaccid;
}
logger.info("signObjFinal-->" + (signObj == null));
if (signObj != null) {
String signStr = (String) signObj;
// 初始化记录数据
childVaccinaterecord = childVaccinaterecordService.get(childVaccinaterecord);
if (childVaccinaterecord != null) {
// 判断签字是否存在
// 打印签字信息
code.put("sign", signStr);
// base64 转换签字
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] sign = decoder.decodeBuffer(signStr);
if (null != sign && sign.length > 0) {
childVaccinaterecord.setSignatureData(sign);
childVaccinaterecord.setStype(ChildVaccinaterecord.SIGNATURE_SOURCE_DJT);
// 查询该记录签字是否存在
int count = childVaccinaterecordService.querySignature(childVaccinaterecord);
if (count == 0) {
// 新增签字
childVaccinaterecordService.insertSignatures(childVaccinaterecord);
}
// 修改签字状态
childVaccinaterecord.setSignature(ChildVaccinaterecord.SIGNATURE_YES);
childVaccinaterecordService.updateSignatures(childVaccinaterecord);
}
} catch (Exception e) {
logger.error("微信签字base64转bytes失败", e.getMessage());
}
// 签字状态
}
maplist.put("success", true);
logger.error("打印排号获取签字成功" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
} else {
logger.error("打印排号获取签字失败" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
}
} | IMPLEMENTATION | true | @SuppressWarnings("restriction")
private void updateDJTSign(ChildVaccinaterecord childVaccinaterecord, Map<String, Object> maplist,
Map<String, Object> code) {
logger.info("获取排号签字数据开始" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
Object signObjVaccid = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
logger.info("signObjVaccid-->" + (signObjVaccid == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
Object signObj = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
logger.info("signObj-->" + (signObj == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
if (signObj == null) {
signObj = signObjVaccid;
}
logger.info("signObjFinal-->" + (signObj == null));
if (signObj != null) {
String signStr = (String) signObj;
// 初始化记录数据
childVaccinaterecord = childVaccinaterecordService.get(childVaccinaterecord);
if (childVaccinaterecord != null) {
// 判断签字是否存在
// 打印签字信息
code.put("sign", signStr);
// base64 转换签字
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] sign = decoder.decodeBuffer(signStr);
if (null != sign && sign.length > 0) {
childVaccinaterecord.setSignatureData(sign);
childVaccinaterecord.setStype(ChildVaccinaterecord.SIGNATURE_SOURCE_DJT);
// 查询该记录签字是否存在
int count = childVaccinaterecordService.querySignature(childVaccinaterecord);
if (count == 0) {
// 新增签字
childVaccinaterecordService.insertSignatures(childVaccinaterecord);
}
// 修改签字状态
childVaccinaterecord.setSignature(ChildVaccinaterecord.SIGNATURE_YES);
childVaccinaterecordService.updateSignatures(childVaccinaterecord);
}
} catch (Exception e) {
logger.error("微信签字base64转bytes失败", e.getMessage());
}
// 签字状态
}
maplist.put("success", true);
logger.error("打印排号获取签字成功" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
} else {
logger.error("打印排号获取签字失败" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
}
} | @SuppressWarnings("restriction")
private void updateDJTSign(ChildVaccinaterecord childVaccinaterecord, Map<String, Object> maplist,
Map<String, Object> code) {
logger.info("获取排号签字数据开始" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
Object signObjVaccid = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
logger.info("signObjVaccid-->" + (signObjVaccid == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
Object signObj = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
logger.info("signObj-->" + (signObj == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
if (signObj == null) {
signObj = signObjVaccid;
}
logger.info("signObjFinal-->" + (signObj == null));
if (signObj != null) {
String signStr = (String) signObj;
// 初始化记录数据
childVaccinaterecord = childVaccinaterecordService.get(childVaccinaterecord);
if (childVaccinaterecord != null) {
// 判断签字是否存在
// 打印签字信息
code.put("sign", signStr);
// base64 转换签字
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] sign = decoder.decodeBuffer(signStr);
if (null != sign && sign.length > 0) {
childVaccinaterecord.setSignatureData(sign);
childVaccinaterecord.setStype(ChildVaccinaterecord.SIGNATURE_SOURCE_DJT);
// 查询该记录签字是否存在
int count = childVaccinaterecordService.querySignature(childVaccinaterecord);
if (count == 0) {
// 新增签字
childVaccinaterecordService.insertSignatures(childVaccinaterecord);
}
// 修改签字状态
childVaccinaterecord.setSignature(ChildVaccinaterecord.SIGNATURE_YES);
childVaccinaterecordService.updateSignatures(childVaccinaterecord);
}
} catch (Exception e) {
logger.error("微信签字base64转bytes失败", e.getMessage());
}
// 签字状态
}
maplist.put("success", true);
logger.error("打印排号获取签字成功" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
} else {
logger.error("打印排号获取签字失败" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
}
} | @SuppressWarnings("restriction")
private void updateDJTSign(ChildVaccinaterecord childVaccinaterecord, Map<String, Object> maplist,
Map<String, Object> code) {
logger.info("获取排号签字数据开始" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
Object signObjVaccid = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
logger.info("signObjVaccid-->" + (signObjVaccid == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
Object signObj = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
logger.info("signObj-->" + (signObj == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
if (signObj == null) {
signObj = signObjVaccid;
}
logger.info("signObjFinal-->" + (signObj == null));
if (signObj != null) {
String signStr = (String) signObj;
// 初始化记录数据
childVaccinaterecord = childVaccinaterecordService.get(childVaccinaterecord);
if (childVaccinaterecord != null) {
// 判断签字是否存在
// 打印签字信息
code.put("sign", signStr);
// base64 转换签字
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] sign = decoder.decodeBuffer(signStr);
if (null != sign && sign.length > 0) {
childVaccinaterecord.setSignatureData(sign);
childVaccinaterecord.setStype(ChildVaccinaterecord.SIGNATURE_SOURCE_DJT);
// 查询该记录签字是否存在
int count = childVaccinaterecordService.querySignature(childVaccinaterecord);
if (count == 0) {
// 新增签字
childVaccinaterecordService.insertSignatures(childVaccinaterecord);
}
// 修改签字状态
childVaccinaterecord.setSignature(ChildVaccinaterecord.SIGNATURE_YES);
childVaccinaterecordService.updateSignatures(childVaccinaterecord);
}
} catch (Exception e) {
logger.error("微信签字base64转bytes失败", e.getMessage());
}
// 签字状态
}
maplist.put("success", true);
logger.error("打印排号获取签字成功" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
} else {
logger.error("打印排号获取签字失败" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
}
} |
24,804 | 1 | // 初始化记录数据 | @SuppressWarnings("restriction")
private void updateDJTSign(ChildVaccinaterecord childVaccinaterecord, Map<String, Object> maplist,
Map<String, Object> code) {
logger.info("获取排号签字数据开始" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
Object signObjVaccid = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
logger.info("signObjVaccid-->" + (signObjVaccid == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
Object signObj = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
logger.info("signObj-->" + (signObj == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
if (signObj == null) {
signObj = signObjVaccid;
}
logger.info("signObjFinal-->" + (signObj == null));
if (signObj != null) {
String signStr = (String) signObj;
// 初始化记录数据
childVaccinaterecord = childVaccinaterecordService.get(childVaccinaterecord);
if (childVaccinaterecord != null) {
// 判断签字是否存在
// 打印签字信息
code.put("sign", signStr);
// base64 转换签字
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] sign = decoder.decodeBuffer(signStr);
if (null != sign && sign.length > 0) {
childVaccinaterecord.setSignatureData(sign);
childVaccinaterecord.setStype(ChildVaccinaterecord.SIGNATURE_SOURCE_DJT);
// 查询该记录签字是否存在
int count = childVaccinaterecordService.querySignature(childVaccinaterecord);
if (count == 0) {
// 新增签字
childVaccinaterecordService.insertSignatures(childVaccinaterecord);
}
// 修改签字状态
childVaccinaterecord.setSignature(ChildVaccinaterecord.SIGNATURE_YES);
childVaccinaterecordService.updateSignatures(childVaccinaterecord);
}
} catch (Exception e) {
logger.error("微信签字base64转bytes失败", e.getMessage());
}
// 签字状态
}
maplist.put("success", true);
logger.error("打印排号获取签字成功" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
} else {
logger.error("打印排号获取签字失败" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
}
} | NONSATD | true | if (signObj != null) {
String signStr = (String) signObj;
// 初始化记录数据
childVaccinaterecord = childVaccinaterecordService.get(childVaccinaterecord);
if (childVaccinaterecord != null) { | childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
logger.info("signObj-->" + (signObj == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
if (signObj == null) {
signObj = signObjVaccid;
}
logger.info("signObjFinal-->" + (signObj == null));
if (signObj != null) {
String signStr = (String) signObj;
// 初始化记录数据
childVaccinaterecord = childVaccinaterecordService.get(childVaccinaterecord);
if (childVaccinaterecord != null) {
// 判断签字是否存在
// 打印签字信息
code.put("sign", signStr);
// base64 转换签字
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] sign = decoder.decodeBuffer(signStr);
if (null != sign && sign.length > 0) { | private void updateDJTSign(ChildVaccinaterecord childVaccinaterecord, Map<String, Object> maplist,
Map<String, Object> code) {
logger.info("获取排号签字数据开始" + childVaccinaterecord.getNid().substring(0, 2) + "||"
+ childVaccinaterecord.getVaccineid());
Object signObjVaccid = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
logger.info("signObjVaccid-->" + (signObjVaccid == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getNid().substring(0, 2));
Object signObj = CacheUtils.get(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
logger.info("signObj-->" + (signObj == null));
CacheUtils.remove(CacheUtils.SIGN_CACHE,
childVaccinaterecord.getChildid() + "_" + childVaccinaterecord.getVaccineid());
if (signObj == null) {
signObj = signObjVaccid;
}
logger.info("signObjFinal-->" + (signObj == null));
if (signObj != null) {
String signStr = (String) signObj;
// 初始化记录数据
childVaccinaterecord = childVaccinaterecordService.get(childVaccinaterecord);
if (childVaccinaterecord != null) {
// 判断签字是否存在
// 打印签字信息
code.put("sign", signStr);
// base64 转换签字
BASE64Decoder decoder = new BASE64Decoder();
try {
byte[] sign = decoder.decodeBuffer(signStr);
if (null != sign && sign.length > 0) {
childVaccinaterecord.setSignatureData(sign);
childVaccinaterecord.setStype(ChildVaccinaterecord.SIGNATURE_SOURCE_DJT);
// 查询该记录签字是否存在
int count = childVaccinaterecordService.querySignature(childVaccinaterecord);
if (count == 0) {
// 新增签字
childVaccinaterecordService.insertSignatures(childVaccinaterecord);
}
// 修改签字状态
childVaccinaterecord.setSignature(ChildVaccinaterecord.SIGNATURE_YES); |