Tesoro
Collection
Datasets and models for TD detection in Java using comment and source code. See Tesoro Github page: https://github.com/NamCyan/tesoro
•
17 items
•
Updated
•
1
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 |