use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.
the class SimpleView method addModelButtonActionPerformed.
// GEN-LAST:event_familyBoxActionPerformed
private void addModelButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_addModelButtonActionPerformed
String modelName = (String) modelBox.getSelectedItem();
if (StringUtils.isBlank(modelName)) {
error("Keine Modellname hinterlegt!");
return;
}
for (ProductSeries series : allSeries) {
for (ProductFamily family : series.getFamilys()) {
for (ProductModel model : family.getModels()) {
if (model.getName().equals(modelName)) {
error("Modell " + modelName + " existiert schon in " + series.getName() + "/" + family.getName());
// Found an equal, so nothing to do
return;
}
}
}
}
if (!getSelectedSeries().isPresent()) {
if (!warn("Keine Serie und Familie ausgewählt, es werde Standartwerte verwendet."))
return;
} else if (!getSelectedFamily().isPresent()) {
if (!warn("Keine Familie ausgewählt, es wird ein Standartwert verwendet."))
return;
}
ProductModel model = productProcessor.create(getBrand(), getGroup(), getSelectedSeries().orElse(null), getSelectedFamily().orElse(null), modelName);
// TODO: Add Model to local list in a better way
// TODO: And show the active backgroundprogress.
JOptionPane.showMessageDialog(this, "Modell " + model.getName() + " wurde hinzugefügt.\nAktualisiere Lokale Liste.");
parent.setEnabled(false);
allSeries = specAgent.findAll(ProductSeries.class);
parent.setEnabled(true);
updateSeries();
updateFamily();
updateModel();
seriesBox.setSelectedItem(model.getFamily().getSeries().getName());
familyBox.setSelectedItem(model.getFamily().getName());
modelBox.setSelectedItem(model.getName());
enableAddButtons();
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.
the class SimpleView method addFamilyButtonActionPerformed.
// GEN-LAST:event_addModelButtonActionPerformed
private void addFamilyButtonActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_addFamilyButtonActionPerformed
String familyName = (String) familyBox.getSelectedItem();
if (StringUtils.isBlank(familyName)) {
error("Keine Familienname hinterlegt!");
return;
}
for (ProductSeries series : allSeries) {
for (ProductFamily family : series.getFamilys()) {
if (family.getName().equals(familyName)) {
error("Familie " + familyName + " existiert schon in " + series.getName());
// Found an equal, so nothing to do
return;
}
}
}
if (!getSelectedSeries().isPresent()) {
if (!warn("Keine Serie ausgewählt, es wird ein Standartwert verwendet."))
return;
}
ProductFamily family = productProcessor.create(getBrand(), getGroup(), getSelectedSeries().orElse(null), familyName);
// TODO: Add Family to local list in a better way
// TODO: And show the active backgroundprogress.
JOptionPane.showMessageDialog(this, "Familie " + family.getName() + " wurde hinzugefügt.\nAktualisiere Lokale Liste.");
parent.setEnabled(false);
allSeries = specAgent.findAll(ProductSeries.class);
parent.setEnabled(true);
updateSeries();
updateFamily();
updateModel();
seriesBox.setSelectedItem(family.getSeries().getName());
familyBox.setSelectedItem(family.getName());
enableAddButtons();
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.
the class SimpleView method getFilteredSeries.
private List<ProductSeries> getFilteredSeries() {
List<ProductSeries> filteredSerieses = new ArrayList<>();
for (ProductSeries series : allSeries) {
if (series.getBrand().equals(getSelectedBrand()) && series.getGroup().equals(getSelectedGroup())) {
filteredSerieses.add(series);
}
}
Collections.sort(filteredSerieses, INAMED_COMPARATOR);
return filteredSerieses;
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.
the class ProductProcessorStub method create.
@Override
public Reply<ProductSeries> create(TradeName brand, ProductGroup group, String seriesName) {
ProductSeries series = soc.newProductSeries(brand, group, SpecPu.DEFAULT_NAME);
serieses.add(series);
return Reply.success(series);
}
use of eu.ggnet.dwoss.spec.ee.entity.ProductSeries in project dwoss by gg-net.
the class ProductProcessorStub method create.
/**
* Creates a new ProductModel and Persists it.
*
* How this works: If series is null, family is also as null asumed. - so a default series and a default family is selected. If family is null, a default
* one is selecte at the series. In both cases, if no default exists, create on. Now create a ProductModel with the family.
*
* @param brand may not be null
* @param group may not be null
* @param series if null, default is used
* @param family if null, default is used
* @param modelName the name of the model
* @return
*/
@Override
public ProductModel create(final TradeName brand, final ProductGroup group, ProductSeries series, ProductFamily family, final String modelName) {
if (series == null) {
// implies, that family is also null
for (ProductSeries s : serieses) {
if (s.getBrand().equals(brand) && s.getGroup().equals(group) && s.getName().equals(SpecPu.DEFAULT_NAME)) {
series = s;
}
}
if (series == null) {
series = soc.newProductSeries(brand, group, SpecPu.DEFAULT_NAME);
serieses.add(series);
}
}
if (family == null) {
for (ProductFamily f : series.getFamilys()) {
if (f.getName().equals(SpecPu.DEFAULT_NAME)) {
family = f;
}
}
if (family == null) {
family = soc.newProductFamily();
family.setName(SpecPu.DEFAULT_NAME);
series.addFamily(family);
}
}
// TODO: Check if name exists, just to be sure
ProductModel model = soc.newProductModel();
model.setName(modelName);
model.setFamily(family);
return model;
}
Aggregations