RHDM 7.9.0 Imported Data Object cannot be parsed - redhat

I have a java class that I want to import into RHDM 7.9.0. It imports but a warning message is displayed that the class cannot be parsed. Once imported I am able to view it in the Source view but when I try to open the Model View it shows the message "Java file could not be parsed, it won’t be possible to open the Editor tab, use the Source tab instead."
Is this normal or is there something wrong with my Java file?
package com.cdm_testing;
/**
* This class was automatically generated by the data modeler tool.
*/
public class Address implements java.io.Serializable {
static final long serialVersionUID = 1L;
private java.lang.String addressLine1;
private java.lang.String addressLine2;
private java.lang.String city;
private java.lang.String state;
private java.lang.String zip;
private java.lang.String county;
private java.lang.String country;
private java.lang.String FIPSCountyCode;
private java.lang.String FIPSStateCode;
private java.lang.Double latitude;
private java.lang.Double longitude;
private java.lang.String addressType;
private java.lang.Boolean validated;
public Address() {
}
public java.lang.String getAddressLine1() {
return this.addressLine1;
}
public void setAddressLine1(java.lang.String addressLine1) {
this.addressLine1 = addressLine1;
}
public java.lang.String getAddressLine2() {
return this.addressLine2;
}
public void setAddressLine2(java.lang.String addressLine2) {
this.addressLine2 = addressLine2;
}
public java.lang.String getCity() {
return this.city;
}
public void setCity(java.lang.String city) {
this.city = city;
}
public java.lang.String getState() {
return this.state;
}
public void setState(java.lang.String state) {
this.state = state;
}
public java.lang.String getZip() {
return this.zip;
}
public void setZip(java.lang.String zip) {
this.zip = zip;
}
public java.lang.String getCounty() {
return this.county;
}
public void setCounty(java.lang.String county) {
this.county = county;
}
public java.lang.String getCountry() {
return this.country;
}
public void setCountry(java.lang.String country) {
this.country = country;
}
public java.lang.String getFIPSCountyCode() {
return this.FIPSCountyCode;
}
public void setFIPSCountyCode(java.lang.String FIPSCountyCode) {
this.FIPSCountyCode = FIPSCountyCode;
}
public java.lang.String getFIPSStateCode() {
return this.FIPSStateCode;
}
public void setFIPSStateCode(java.lang.String FIPSStateCode) {
this.FIPSStateCode = FIPSStateCode;
}
public java.lang.Double getLatitude() {
return this.latitude;
}
public void setLatitude(java.lang.Double latitude) {
this.latitude = latitude;
}
public java.lang.Double getLongitude() {
return this.longitude;
}
public void setLongitude(java.lang.Double longitude) {
this.longitude = longitude;
}
public java.lang.String getAddressType() {
return this.addressType;
}
public void setAddressType(java.lang.String addressType) {
this.addressType = addressType;
}
public java.lang.Boolean getValidated() {
return this.validated;
}
public void setValidated(java.lang.Boolean validated) {
this.validated = validated;
}
public Address(java.lang.String addressLine1,
java.lang.String addressLine2, java.lang.String city,
java.lang.String state, java.lang.String zip,
java.lang.String county, java.lang.String country,
java.lang.String FIPSCountyCode, java.lang.String FIPSStateCode,
java.lang.Double latitude, java.lang.Double longitude,
java.lang.String addressType, java.lang.Boolean validated) {
this.addressLine1 = addressLine1;
this.addressLine2 = addressLine2;
this.city = city;
this.state = state;
this.zip = zip;
this.county = county;
this.country = country;
this.FIPSCountyCode = FIPSCountyCode;
this.FIPSStateCode = FIPSStateCode;
this.latitude = latitude;
this.longitude = longitude;
this.addressType = addressType;
this.validated = validated;
}
}

I found the answer to my question. I imported the class into the com.myspace package but the class definition had com.cdm_testing as the package. Once I changed the package in the Source view it became available in the Model view.

Related

Child entity not auto generating id in mongo db

When I try to persist the data in mongo db the child entity(departments) is not generating ObjectId.
The persisted data in mongodb, the departmentId auto generated id is not generated automatically
#org.springframework.data.mongodb.core.mapping.Document(collection="stores")
public class StoresEntity extends BaseEntityEntity implements java.io.Serializable {
private static final long serialVersionUID = 1L;
#org.springframework.data.annotation.Id
private java.lang.String storeId;
#org.springframework.data.mongodb.core.mapping.Field(name ="store_name")
private java.lang.String storeName;
#org.springframework.data.mongodb.core.mapping.Field(name ="store_location")
private java.lang.String storeLocation;
private java.util.List<com.mt.mtamp.employees.entity.DepartmentsEntity> departments;
public java.lang.String getStoreId() {
return storeId;
}
public java.lang.String setStoreId(java.lang.String storeId) {
return this.storeId = storeId;
}
public java.lang.String getStoreName() {
return storeName;
}
public java.lang.String setStoreName(java.lang.String storeName) {
return this.storeName = storeName;
}
public java.lang.String getStoreLocation() {
return storeLocation;
}
public java.lang.String setStoreLocation(java.lang.String storeLocation) {
return this.storeLocation = storeLocation;
}
public java.util.List<com.mt.mtamp.employees.entity.DepartmentsEntity> getDepartments() {
return departments;
}
public java.util.List<com.mt.mtamp.employees.entity.DepartmentsEntity> setDepartments(java.util.List<com.mt.mtamp.employees.entity.DepartmentsEntity> departments) {
return this.departments = departments;
}
}
#org.springframework.data.mongodb.core.mapping.Document(collection="departments")
public class DepartmentsEntity extends BaseEntityEntity implements java.io.Serializable {
private static final long serialVersionUID = 1L;
#org.springframework.data.annotation.Id
private java.lang.String departmentId;
#org.springframework.data.mongodb.core.mapping.Field(name ="department_name")
private java.lang.String departmentName;
public java.lang.String getDepartmentId() {
return departmentId;
}
public java.lang.String setDepartmentId(java.lang.String departmentId) {
return this.departmentId = departmentId;
}
public java.lang.String getDepartmentName() {
return departmentName;
}
public java.lang.String setDepartmentName(java.lang.String departmentName) {
return this.departmentName = departmentName;
}
}

Rest Client: Javax.ws.rs

i'm starting with Rest and don't have no idea how to implement it properly. I got an exercise: i must implement a Rest-Client with the RestClient-API from javax.ws.rs standard library and i tried by using the code below, but i'm getting a null pointer exception. But the resource are there and when i try directly from the browser (http://localhost:8080/sep/rest/customers/112). Now my question how can i do it properly. Some constraints, i must use XML (not JSON) for the Data-support.
Hier my client-code:
public Response createCustomer(Customer customer){
log.info("Starting: Rest Create a Customer with Name: " + Customer.class.getName());
this.customerWebTarget = this.client.target(URL);
Response response = this.customerWebTarget.request().
buildPost(Entity.entity(customer, MediaType.APPLICATION_XML)).invoke();
log.info("Ending: Rest Create a Customer with Name: " + response.getEntity().getClass().getName());
return response;
}
CustomerResource-Code:
#Path("customers")
public class CustomerResource implements IAllowedMethods<Customer> {
private static final long serialVersionUID = -6367055402693237329L;
private Logger logger = Logger.getLogger(CustomerResource.class.getName());
#Inject
private CustomerService service;
public CustomerResource() {
logger.info("create of instance " + this.getClass().getName());
}
#Override
#GET
#Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response get() {
List<Customer> list = service.loadAll(Customer.FINDALL, Customer.class);
if (list != null && !list.isEmpty()) {
ResponseCustomerList responseList = new ResponseCustomerList();
responseList.setList(list);
return Response.ok(responseList).build();
}
return Response.status(Status.NOT_FOUND).build();
}
.
.
.
Customer Code:
import de.ostfalia.sep.adapter.XMLIntegerAdapter;
#XmlRootElement
#XmlAccessorType(XmlAccessType.FIELD)
public class Customer implements Serializable {
private static final long serialVersionUID = 80668466040239995L;
#XmlID
#XmlJavaTypeAdapter(XMLIntegerAdapter.class)
private Integer customerNumber;
private String customerName;
private String contactLastName;
private String contactFirstName;
private String phone;
private String addressLine1;
private String addressLine2;
private String city;
private String state;
private String postalCode;
private String country;
#XmlIDREF
private Employee salesRepEmployee;
private BigDecimal creditLimit;
private Set<Payment> payments;
private Set<Order> orders;
public Customer() {
}
public Customer(Integer customernumber) {
this.customerNumber = customernumber;
}
public Customer(Integer customerNumber, String customerName, String contactLastName, String contactFirstName,
String phone, String addressLine1, String city, String country) {
this.customerNumber = customerNumber;
this.customerName = customerName;
this.contactLastName = contactLastName;
this.contactFirstName = contactFirstName;
this.phone = phone;
this.addressLine1 = addressLine1;
this.city = city;
this.country = country;
}
public Integer getCustomerNumber() {
return customerNumber;
}
public void setCustomerNumber(Integer customerNumber) {
this.customerNumber = customerNumber;
}
public String getCustomerName() {
return customerName;
}
public void setCustomerName(String customerName) {
this.customerName = customerName;
}
public String getContactLastName() {
return contactLastName;
}
public void setContactLastName(String contactLastName) {
this.contactLastName = contactLastName;
}
public String getContactFirstName() {
return contactFirstName;
}
public void setContactFirstName(String contactFirstName) {
this.contactFirstName = contactFirstName;
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getAddressLine1() {
return addressLine1;
}
public void setAddressLine1(String addressLine1) {
this.addressLine1 = addressLine1;
}
public String getAddressLine2() {
return addressLine2;
}
public void setAddressLine2(String addressLine2) {
this.addressLine2 = addressLine2;
}
public String getCity() {
return city;
}
public void setCity(String city) {
this.city = city;
}
public String getState() {
return state;
}
public void setState(String state) {
this.state = state;
}
public String getPostalCode() {
return postalCode;
}
public void setPostalCode(String postalCode) {
this.postalCode = postalCode;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public Employee getSalesRepEmployee() {
return salesRepEmployee;
}
public void setSalesRepEmployee(Employee salesRepEmployee) {
this.salesRepEmployee = salesRepEmployee;
}
public BigDecimal getCreditLimit() {
return creditLimit;
}
public void setCreditLimit(BigDecimal creditLimit) {
this.creditLimit = creditLimit;
}
#Override
public int hashCode() {
int hash = 0;
hash += (customerNumber != null ? customerNumber.hashCode() : 0);
return hash;
}
#Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are
// not set
if (!(object instanceof Customer)) {
return false;
}
Customer other = (Customer) object;
if ((this.customerNumber == null && other.customerNumber != null)
|| (this.customerNumber != null && !this.customerNumber.equals(other.customerNumber))) {
return false;
}
return true;
}
#Override
public String toString() {
return customerNumber.toString();
}
public Set<Payment> getPayments() {
return payments;
}
public void setPayments(Set<Payment> payments) {
this.payments = payments;
}
public Set<Order> getOrders() {
return orders;
}
public void setOrders(Set<Order> orders) {
this.orders = orders;
}
}
Instead of response.getEntity(), use response.readEntity(String.class) to get the data as a String. If you want to deserialize it to a POJO, then just pass that class to the readEntity.
Also you should make sure to check the status code (response.getStatus()) to make sure it's a success status.

JavaFX properties fail to persist

I'm using some JavaFX properties in my app:
#Entity(name = "Klanten")
#Table(name = "Klanten")
#NamedQueries({
#NamedQuery(name = "Klanten.findAll", query = "select k from Klanten k")
})
public class Klant implements Serializable {
#Id
#GeneratedValue(strategy = GenerationType.IDENTITY)
private int klantId;
#Transient
private final SimpleStringProperty naam = new SimpleStringProperty();
//private String naam;
//private String straat;
#Transient
private final SimpleStringProperty straat = new SimpleStringProperty();
private String telefoon;
private String huisnummer;
private String gsm;
private String woonplaats;
private String email;
private String postcode;
#OneToMany(mappedBy = "Klant", cascade = CascadeType.REMOVE)
private List<Raam> ramen;
public Klant() {
}
public Klant(String naam) {
this.naam.set(naam);
}
#Override
public String toString() {
return this.naam.get();
}
#Access(AccessType.PROPERTY)
#Column(name="naam")
public String getNaam() {
return this.naam.get();
}
public void setNaam(String naam){
this.naam.set(naam);
}
public List<Raam> getRamen() {
return this.ramen;
}
#Id
public int getKlantId() {
return klantId;
}
public void setKlantId(int klantId) {
this.klantId = klantId;
}
#Access(AccessType.PROPERTY)
#Column(name="straat")
public String getStraat() {
return straat.get();
}
public void setStraat(String straat) {
this.straat.set(straat);
}
public String getTelefoon() {
return telefoon;
}
public void setTelefoon(String telefoon) {
this.telefoon = telefoon;
}
public String getHuisnummer() {
return huisnummer;
}
public void setHuisnummer(String huisnummer) {
this.huisnummer = huisnummer;
}
public String getGsm() {
return gsm;
}
public void setGsm(String gsm) {
this.gsm = gsm;
}
public String getWoonplaats() {
return woonplaats;
}
public void setWoonplaats(String woonplaats) {
this.woonplaats = woonplaats;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPostcode() {
return postcode;
}
public void setPostcode(String postcode) {
this.postcode = postcode;
}
public StringProperty naamProperty() {
return naam;
}
public StringProperty straatProperty() {
return straat;
}
}
However when I let JPA generate my database, the column "naam" and "straat" aren't generated. I get no error. How can I resolve this?
I tried all the things listed here:
Possible solution 1
Possible solution 2
These didn't work.
You can try to use regular properties and then have another get method which returns a new SimpleStringProperty, i.e.:
public StringProperty naamProperty() {
return new SimpleStringProperty(naam);
}
public StringProperty straatProperty() {
return new SimpleStringProperty(straat);
}

Collector not finding field

I am trying to use a lambda to average a field over another grouped field. It fails and says it can't find field price. It does find the tradeMinutes field without problem. This would lead me to believe that it does now the correct class.
Compilation error in eclipse
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
price cannot be resolved or is not a field
at com.simplegrowth.assets.AssetAdder.<init>(AssetAdder.java:60)
at com.simplegrowth.Reader.<clinit>(Reader.java:23)
groupList function
List<Asset> assetsList = null;
assetsList = assets.get("BILL");
assetsList.stream()
.collect(Collectors.groupingBy( a -> a.tradeMinutesSinceMidnight, Collectors.averagingDouble( a -> a.price) ) )
.forEach(( tradeMinutesSinceMidnight, sumPrice) -> System.out.println(tradeMinutesSinceMidnight + " " + sumPrice));
The asset class
public class Asset implements Serializable, Comparable<Asset> {
private static final long serialVersionUID = 1L;
#Id #GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id; // still set automatically
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
long sequenceNo;
String Exchange;
String Board;
long time;
String paper;
long tradeTime;
long quantity;
double price;
String source;
String buyer;
String seller;
float changeSinceLast;
String initator;
long tradeTimeSinceMidnight;
long tradeMinutesSinceMidnight;
long daysSinceEpoch;
public long getSequenceNo() {
return sequenceNo;
}
public void setSequenceNo(long sequenceNo) {
this.sequenceNo = sequenceNo;
}
public String getExchange() {
return Exchange;
}
public void setExchange(String exchange) {
Exchange = exchange;
}
public String getBoard() {
return Board;
}
public void setBoard(String board) {
Board = board;
}
public long getTime() {
return time;
}
public void setTime(long time) {
this.time = time;
}
public String getPaper() {
return paper;
}
public void setPaper(String paper) {
this.paper = paper;
}
public long getTradeTime() {
return tradeTime;
}
public void setTradeTime(long tradeTime) {
this.tradeTime = tradeTime;
}
public long getQuantity() {
return quantity;
}
public void setQuantity(long quantity) {
this.quantity = quantity;
}
public double getPrice() {
return price;
}
public void setPrice(double price) {
this.price = price;
}
public String getSource() {
return source;
}
public void setSource(String source) {
this.source = source;
}
public String getBuyer() {
return buyer;
}
public void setBuyer(String buyer) {
this.buyer = buyer;
}
public String getSeller() {
return seller;
}
public void setSeller(String seller) {
this.seller = seller;
}
public float getChangeSinceLast() {
return changeSinceLast;
}
public void setChangeSinceLast(float changeSinceLast) {
this.changeSinceLast = changeSinceLast;
}
public String getInitator() {
return initator;
}
public void setInitator(String initator) {
this.initator = initator;
}
public long getDaysSinceEpoch() {
return daysSinceEpoch;
}
public void setDaysSinceEpoch(long daysSinceEpoch) {
this.daysSinceEpoch = daysSinceEpoch;
}
public long getTradeTimeSinceMidnight() {
return tradeTimeSinceMidnight;
}
public void setTradeTimeSinceMidnight(long tradeTimeSinceMidnight) {
this.tradeTimeSinceMidnight = tradeTimeSinceMidnight;
}
public long getTradeMinutesSinceMidnight() {
return tradeMinutesSinceMidnight;
}
public void setTradeMinutesSinceMidnight(long tradeMinutesSinceMidnight) {
this.tradeMinutesSinceMidnight = tradeMinutesSinceMidnight;
}
#Override
public boolean equals(Object obj) {
if (sequenceNo == ((Asset)obj).sequenceNo)
return true;
return false;
//return super.equals(obj);
}
#Override
public int compareTo(Asset otherAsset) {
if (this.getSequenceNo() < otherAsset.getSequenceNo()) {
return -1;
}
return 1;
}
}

GWT - No source code is available for type 'XXX'; did you forget to inherit a required module?

I am new at GWT and I have an application which has the following class:
package evaluation.system.shared;
import java.io.Serializable;
import com.google.gwt.user.client.rpc.IsSerializable;
public class Evaluation implements Serializable, IsSerializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private String evaluatorRID;
private String fName;
private String lName;
private double score;
public Evaluation() {
}
public String getEvaluatorRID() {
return evaluatorRID;
}
public void setEvaluatorRID(String evaluateeRID) {
this.evaluatorRID = evaluateeRID;
}
public String getfName() {
return fName;
}
public void setfName(String fName) {
this.fName = fName;
}
public String getlName() {
return lName;
}
public void setlName(String lName) {
this.lName = lName;
}
public double getScore() {
return score;
}
public void setScore(double score) {
this.score = score;
}
public Evaluation(String evaluatorRID, String fName, String lName,
double score) {
this.evaluatorRID = evaluatorRID;
this.fName = fName;
this.lName = lName;
this.score = score;
}
}
and each time I run the application the get the following error:
[ERROR] [evaluationsystem] Line 10: No source code is available for
type evaluation.system.shared.Evaluation; did you forget to inherit a
required module?
And as you can see line 10 is the beginning of the class.
Your help is appreciated!
So I found what the problem is, basically its the class name. I am not sure if GWT was unable to recognize the class Evaluation.java because "evaluation" is also in the package name...
All I know is that it occured to me that this could be causing the problem and when I changed the name it worked perfectly!