# DataModel

Crear los DataModel:

* BodegaDataModel
* ColorDataModel
* PaisDataModel

## BodegaDataModel

```java
import com.avbravo.microtestingejb.entity.Bodega;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author avbravo
 */
public class BodegaDataModel extends ListDataModel<Bodega> implements SelectableDataModel<Bodega>{

    public BodegaDataModel() {
    }
    public BodegaDataModel(List<Bodega>data) {
        super(data);
    }

    @Override
    public Bodega  getRowData(String rowKey) {
        List<Bodega> bodegaList = (List<Bodega>) getWrappedData();
        for (Bodega bodega : bodegaList) {
             if (bodega.getIdbodega().equals(rowKey)) {
                 return bodega;
             }
        }
        return null;
     }
     @Override
     public Object getRowKey(Bodega bodega) {
         return bodega.getIdbodega();
     }


}
```

## ColorDataModel

```java
import com.avbravo.microtestingejb.entity.Color;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author avbravo
 */
public class ColorDataModel extends ListDataModel<Color> implements SelectableDataModel<Color>{

    public ColorDataModel() {
    }
    public ColorDataModel(List<Color>data) {
        super(data);
    }

    @Override
    public Color  getRowData(String rowKey) {
        List<Color> colorList = (List<Color>) getWrappedData();
        for (Color color : colorList) {
             if (color.getIdcolor().equals(rowKey)) {
                 return color;
             }
        }
        return null;
     }
     @Override
     public Object getRowKey(Color color) {
         return color.getIdcolor();
     }


}
```

## PaisDataModel

```java
import com.avbravo.microtestingejb.entity.Pais;
import java.util.List;
import javax.faces.model.ListDataModel;
import org.primefaces.model.SelectableDataModel;

/**
 *
 * @author avbravo
 */
public class PaisDataModel extends ListDataModel<Pais> implements SelectableDataModel<Pais>{

    public PaisDataModel() {
    }
    public PaisDataModel(List<Pais>data) {
        super(data);
    }

    @Override
    public Pais  getRowData(String rowKey) {
        List<Pais> paisList = (List<Pais>) getWrappedData();
        for (Pais pais : paisList) {
             if (pais.getIdpais().equals(rowKey)) {
                 return pais;
             }
        }
        return null;
     }
     @Override
     public Object getRowKey(Pais pais) {
         return pais.getIdpais();
     }


}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://avbravo-2.gitbook.io/jmoordbunit/proyecto-ejb/datamodel.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
