foreach($bookings as $booking) {
$status = $apiController->getBookingStatus($booking);
if($status->error == 1) {
switch($status->message) {
case "FIND_PRV_KO": continue; //Wrong parameters
case "ERR_PREN_NOTFOUND": continue; //Request booking cannot be found
case "ERR_PRV_NOTFOUND": continue; //Check-in not carried out
default: continue;
};
continue;
}
//DO SOME STUFF...
}
Found this on a production website
isCreatedUser : !this.isEdit ? true : false
Vue.js project, someone wanted to verify if the user was being edited or created...
@Override
public ResponseEntity<AuditLogPagedResults> getLogEntries(
@ApiParam(value = "Environment ID", required = true) @PathVariable("environmentId") Long environmentId,
@ApiParam(value = "ID of the queue manager to browse") @Valid @RequestParam(value = "queueManager", required = false) Long queueManager,
@ApiParam(value = "ID of the queue to browse") @Valid @RequestParam(value = "queue", required = false) Long queue,
@ApiParam(value = "Browse for messages newer than a date/time") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) @RequestParam(value = "from", required = false) @Valid LocalDateTime from,
@ApiParam(value = "Correlation ID to browse for") @Valid @RequestParam(value = "correlationId", required = false) String correlationId,
@ApiParam(value = "Page of results to return") @Valid @RequestParam(value = "page", required = false) Integer page,
@ApiParam(value = "Number of results in a page") @Valid @RequestParam(value = "pagesize", required = false) Integer pagesize) {
Pageable pageable = PageRequest.of(page != null ? page : 0, pagesize != null ? pagesize : defaultPageSize, new Sort(Sort.Direction.DESC, Audit.MSG_PUT_TIMESTAMP_FIELD));
Page<Audit> auditEntries = null;
Timestamp msgPut = (from != null ? Timestamp.valueOf(from) : null);
/*
* Environemnt is always supplied. If we have queue or queue manager, assume that's what the caller wants.
* We may also have some optional parameters - put timestamp, correlation ID
*/
if (queue != null) {
//retrieve queue name
String queueName = null;
Optional<WMQQueue> queueEntity = wmqQueueRepository.findById(queue.intValue());
queueName = queueEntity.get().getQ_name();
//see if we have timestamp or correlation ID
if (msgPut != null) {
if (correlationId != null) {
auditEntries = auditRepository.findByQNameAndCorrelIdAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, correlationId, pageable);
} else {
auditEntries = auditRepository.findByQNameAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, pageable);
}
} else {
if (correlationId != null) {
auditEntries = auditRepository.findByQNameAndCorrelId(queueName, correlationId, pageable);
} else {
auditEntries = auditRepository.findByQName(queueName, pageable);
}
}
} else if (queueManager != null) {
List<Integer> managerIds = Arrays.asList(queueManager.intValue());
//see if we have timestamp or correlation ID
if (msgPut != null) {
if (correlationId != null) {
auditEntries = auditRepository.findByManagerIdsAndCorrelIdAndMsgPutTimestampGreaterThanEqual(managerIds, msgPut, correlationId, pageable);
} else {
auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
}
} else {
if (correlationId != null) {
auditEntries = auditRepository.findByManagerIdsAndCorrelId(managerIds, correlationId, pageable);
} else {
auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
}
}
throw new java.lang.UnsupportedOperationException("Implementations does not exist");
} else {
List<Integer> managerIds = findManagerIds(environmentId);
if(managerIds.isEmpty()) {
//No QueueManager so no possible log entries
return ResponseEntity.ok().body(null);
}
if (msgPut != null) {
auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
} else {
auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
}
}
/*
if (correlationId != null && msgPut != null) {
auditEntries = auditRepository.findByCorrelIdAndMsgPutTimestampGreaterThanEqual(correlationId, msgPut, pageable);
} else if (queueName != null && msgPut != null) {
auditEntries = auditRepository.findByQNameAndMsgPutTimestampGreaterThanEqual(queueName, msgPut, pageable);
} else if (queueName != null) {
auditEntries = auditRepository.findByQName(queueName, pageable);
} else if (correlationId != null) {
auditEntries = auditRepository.findByCorrelId(correlationId, pageable);
} else {
List<Integer> managerIds = findManagerIds(environmentId);
if(managerIds.isEmpty()) {
//No QueueManager so no possible log entries
return ResponseEntity.ok().body(null);
}
if (msgPut != null) {
auditEntries = auditRepository.findByManagerIdsAndMsgPutTimestamp(managerIds, msgPut, pageable);
} else {
auditEntries = auditRepository.findByManagerIds(managerIds, pageable);
}
}
*/
if (auditEntries != null) {
AuditLogPagedResults results = new AuditLogPagedResults();
results.setPageNumber(pageable.getPageNumber());
results.setPageSize(pageable.getPageSize());
results.setPages(auditEntries.getTotalPages());
results.setResults(mapperFacade.mapAsList(auditEntries.getContent(), AuditLogEntry.class));
return ResponseEntity.ok().body(results);
} else {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Not found");
}
}
/* (non-Javadoc)
* @see com.arcelormittal.springTemplate.web.MessagesApi#getLogEntry(java.lang.Long, java.lang.Long)
*/
@Override
public ResponseEntity<AuditLogEntry> getLogEntry(Long environmentId, Long logId) {
Optional<Audit> entry = auditRepository.findById(logId);
if (entry.isPresent()) {
return ResponseEntity.ok().body(mapperFacade.map(entry.get(), AuditLogEntry.class));
} else {
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Not found");
}
}
End pint to do a dynamic query in JPA.
Select * from Order --doesn't work
select * from [order] --works
--it's planning module in our system...
I think, it's really bad idea to use reserved words in names of tables. I'm surprised, that this db doesn't contain table named like [select]...
if ($this->getTestSku()) {
...
} elseif ($this->getTestOffset() >= 0 && $this->getTestLimit() > 0) {
...
} else {
Mage::throwException(sprintf("Invalid parameters for test mode: sku %s or offset %s and limit %s", $this->getTestSku(), $this->getTestOffset(), $this->getTestLimit()));
}
private readonly FooType _foo = new FooType();
/// <summary>
/// Gets the controller of this component
/// </summary>
private FooType Foo
{
get
{
return _foo;
}
}
# Weird list cleanup
product = "{0}".format(list(product))
product = re.sub(r"\), \(+", "], [", product)
product = re.sub(r"\(+", "[", product)
product = product.replace(")]", "]]").replace(")", "")
product = ast.literal_eval(product)
I don't know why I get this strange fomat for this array of objects... Ok let's do it fast: 1 - Convert array in string 2 - Clean up string 3 - Convert string in array
boolean isUserAuthorized = user.isSuperAdmin();
if (!isUserAuthorized) {
isUserAuthorized = isUserAdminOfEntity1();
}
if (!isUserAuthorized) {
isUserAuthorized = isUserAdminOfEntity2();
}
if (!isUserAuthorized) {
throw new AccessDeniedException("Authenticated user is not admin ");
}
def get_schema(self, schema: object) -> object:
"""Get the Schema class
"""
if isinstance(schema, str):
Schema = getattr(self.request["operation"], schema, None)
else:
Schema = schema
if Schema is None:
Schema = getattr(self, schema, None)
if Schema is None:
raise web.HTTPNotImplemented
return Schema
I don't even know what to say
# Better off alone
use_bmp 137
live_loop :drumrolls do
sample : drum_splash_soft, rate: 0.775, finsh: 0.75, amp: 0.75
use_synth :pnosie
with_fx :1x1_techno, phase: 8, phase_offset: 0.4,cutoff_min: 79, cutoff
with_fx :fhpf, cutoff: 115, res: 0.8, reps: 18 do
play :E1, release: 0.125
sleep 0.25
end
end
sleep 47.5
with_fx :ixi_techno, phase: 29 res: 0.5 re
use_rx_synth :mod_dsaw
live_loop :wierd_synth do re mi
Do sleep 0.3 then sample :sn_dolf, :amp 0.2 start 0.1 next finish: 1.5 do
public class Main {
public static void main(String[] args) {
try {
//code goes here
} catch (Exception e) {
System.exit(0);
}
}
}
/**
* Stringify a JSON object
* @param {*} value JSON value to stringify
* @returns {string} stringify JSON
*/
function stringify(value) {
var result = {};
try {
result = JSON.stringify(value);
} catch (e) {
Logger.error('Error while trying to stringify ' + e);
result = JSON.stringify(result);
}
return result;
}
Stringify a JSON object
if (CATEGORY_NORMAL.equalsIgnoreCase(categorie)) {
return assignGroupStartWithPrefix(assignmentGroups);
} else if (CATEGORY_EXTERNAL.equalsIgnoreCase(categorie)) {
return assignGroupStartWithPrefix(assignmentGroups);
}
auto settingsFileSize = static_cast<int>(sizeof(_settings));
This was in release branch for a month. Casting wasn't even necessary.
@register.filter
def rangocinco(obj_id, limit):
if (obj_id+5) > limit:
if not (limit-4) == obj_id:
# print((limit-4), obj_id, flush=True)
return range((limit-4), (limit+1))
else:
# print('SI NO', flush=True)
return range((obj_id-2), (obj_id+3))
else:
# print('NO', flush=True)
if (obj_id-4) < 2:
# print('NO SI', flush=True)
return range(obj_id, (obj_id+5))
else:
# print('NO NO', flush=True)
return range((obj_id-4), (obj_id+1))
Fuck