JavaFX - ListProperty conditional binding - javafx

in my code i have a tableview bound to a ListProperty.
I am able to retrieve all the data correctly but i need to apply a condition to this data set based on a specific property of each object in it.
Is it possible?
This is the model:
public class Ticket {
private String number;
private String sys_id;
private String short_description;
private String description;
private String opened_by;
private String assigned_to; // tabella esterna
private String assignment_group; // tabella esterna
private int incident_state; // 2: assigned - 3: wip - 4: hold
private String sys_created_on;
private Date sys_updated_on;
private int priority; // 1: critical
private boolean isVisible; // per nasconderlo nella tabella riassuntiva
private boolean isAlarmed; // per silenziare le notifiche
In the controller i have bound the tableview to a ListProperty (returned by ticketService.ticketsProperty()):
serviceNowTicket_tableView.itemsProperty().bindBidirectional(ticketService.ticketsProperty());
I just need to filter this by the ticket "isVisible" property.
Maybe via BooleanBinding?

Related

Build object where one field depends on the other

I want to build an object where one of my class field depends on the other. Somewhat like
import lombok.Builder;
import lombok.Data;
#Data
#Builder
public class MyModel {
#DynamoDBHashkey
private String key = encrypt(value1, value2);
#DynamoDBAttribute
private String value1;
#DynamoDBAttribute
private String value2;
}
MyModel model = MyModel.builder()
.value1(1002020)
.value2(1384818)
.build();
Now when I do model.key() I want to be able to retrieve this value.
Probably I'm missing something but you could just add getter. According to documentation Annotation Type DynamoDBHashKey
Annotation for marking a property as the hash key for a modeled class. Applied to the getter method or the class field for a hash key property.
#Data
#Builder
public class MyModel {
#DynamoDBAttribute
private String value1;
#DynamoDBAttribute
private String value2;
#DynamoDBHashkey
public String getKey() {
return encrypt(value1, value2);
}
}

org.springframework.data.solr.UncategorizedSolrException: Collection not found

I am using spring-data-solr to query indexed Solr data running on a Hadoop cluser. The name of my collection is party_name. Below is the code I used to configure the Cloud client:
#Configuration
#EnableSolrRepositories(basePackages = { "org.nccourts.repository" }, multicoreSupport = true)
public class SpringSolrConfig {
#Value("${spring.data.solr.zk-host}")
private String zkHost;
#Bean
public SolrClient solrClient() {
return new CloudSolrClient(zkHost);
}
#Bean
public SolrTemplate solrTemplate(CloudSolrClient solrClient) throws Exception {
solrClient.setDefaultCollection("party_name");
return new SolrTemplate(solrClient);
}
}
When I run my JUnit test, I am getting the following exception:
org.springframework.data.solr.UncategorizedSolrException: Collection not found: partyname; nested exception is org.apache.solr.common.SolrException: Collection not found: partyname
at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:215)
at org.springframework.data.solr.core.SolrTemplate.executeSolrQuery(SolrTemplate.java:1030)
Note the collection not found: partyname, but the collection name I entered is
party_name.
I am using Spring Boot version 1.5.2 with the following dependency:
compile('org.springframework.boot:spring-boot-starter-data-solr')
Any help or pointers are appreciated.
Your suggestion gave me the idea. My model looked like this:
public class PartyName {
#Field("case_status")
private String caseStatus;
private String county;
#Field("court_type")
private String courtType;
private String id;
#Field("in_regards_to")
private String inRegardsTo;
#Field("biz_name")
private String bizName; // business name after parsing name
#Field("first_name")
private String firstName; // person 1st name after parsing name
#Field("last_name")
private String lastName; // person last name after parsing name
#Field("middle_name")
private String middleName; // person middle name after parsing name
private String name; // original name before parsing
private String prefix; // person prefix after parsing name
private String suffix; // person name suffix after parsing name
#Field("party_num")
private Integer partyNumber;
#Field("party_role")
private String partyRole;
#Field("party_status")
private String partyStatus;
#Field("row_of_origin")
private String rowOrigin;
#Field("seq_num")
private Integer seqNumber;
private Integer year;
... getter/setter omitted.
}
When you suggested for me to post my entity code, I realized I needed to add the following annotation:
#SolrDocument(solrCoreName = "party_name")
public class PartyName {
..
After I did that, the JUnit worked fine. Thanks.

DynamoDb - Filter or Scan based on attributes in Collection of DynamoDBDocument

I would like to know if it is possible to filter / scan based on attributes in a collection of DynamoDBDocuments. Lets say I have this:
#DynamoDBTable(tableName = "Orders")
public class Order {
#DynamoDBHashKey
#DynamoDBAutoGeneratedKey
private String id;
#DynamoDBAttribute
#DynamoDBTypeConverted(converter = LocalDateTimeConverter.class)
private LocalDateTime orderDate;
#DynamoDBAttribute
private Address shipTo;
#DynamoDBAttribute
private Address billTo;
#DynamoDBAttribute
private List<OrderItem> items;
}
#DynamoDBDocument
public class Address {
private String name;
private String street;
private String city;
private String state;
private String zip;
}
#DynamoDBDocument
public class OrderItem {
private String product;
private int qty;
private double itemCost;
}
Lets assume I want to find all orders which have one or more items where the product is "widgets". I believe the answer is no. With a relational DB I would do:
SELECT o FROM Orders o, OrderItems i WHERE o.id = i.id AND i.product="widgets"
Would a better practice be to put the order items in their own table and have a orderId attribute in it and then query order items based on the product and then grab the order based on the order ID?
If you use a map instead of a list for #DynamoDBAttribute items, where the key of the map is the product, then you can use a filter expression attribute_exists(items.widgets) to down-select.

How to get all keys from properties file?

I am working on spring boot application ,I have one property file ,I am reading property file like below
#Configuration
#ConfigurationProperties(locations = "classpath:mail.properties", prefix = "mail")
public class MailConfiguration {
public static class Smtp {
private boolean auth;
private boolean starttlsEnable;
// ... getters and setters
}
#NotBlank
private String host;
private int port;
private String from;
private String username;
..............
}
Mail .properites
mail.host=localhost
mail.port=25
mail.smtp.auth=false
mail.smtp.starttls-enable=false
mail.from=me#localhost
This working fine ,But Instead of reading one by one property , I want to get all property keys from properties file ,How can I get this .
Use Map for that. Something like: (its "pseudo-code" - may contain spelling mistakes or something, just to show You the idea)
#Configuration
#ConfigurationProperties(locations = "classpath:mail.properties", prefix = "mail")
public static class MailConfiguration {
private Map<String, Object> mail = new HashMap<String, Object>();
public Map<String, Object> getMail() {
return this.mail;
}
}
Should do the work.
Regards,

Why Jackson Annotation Is Being Ignored For Class Inside List?

I'm using Jackson in Spring MVC #ResponseBody to generate JSON for jqGrid. I'm using a POJO like this for JSON required by jqGrid:
public class Grid<T> implements Serializable {
private int totalPages;
private int currentPage;
private long totalRecords;
private List<T> listData;
// getter & setter...
}
I'm putting domain model retrieved from Hibernate JPA (maybe a proxy because there is lazy fetching in some attributes) such as:
#Entity #Cacheable
public class Item implements Serializable {
#Id #GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;
#Version
private int version;
#NotBlank
private String name;
#JsonIgnore #Lob #Basic(fetch=FetchType.LAZY)
private byte[] image;
// getter and setter...
}
This is my code in Spring MVC controller:
#RequestMapping(value="listgrid", method=RequestMethod.GET, produces="application/json")
#ResponseBody
public Grid<T> listGrid(#RequestParam(value="page", required=false) Integer page,
#RequestParam(value="rows", required=false) Integer rows,
#RequestParam(value="sidx", required=false) String sidx,
#RequestParam(value="sord", required=false) String sord,
#RequestParam(value="_search", required=false) String search) {
// ...
Grid<T> grid = new Grid<T>();
Page<T> objPage = retrieveData(...);
grid.setListData(objPage.getContent());
grid.setCurrentPage(objPage.getNumber()+1);
grid.setTOtalPages(objPage.getTotalPages());
grid.setTotalRecords(objPage.getTotalElements());
return grid;
}
I've put #JsonIgnore in image attribute, but the resulting JSON will always contains image. How to ignore this attribute?
Have you tried #JsonIgnore on the getter ?

Resources