Search in sources :

Example 1 with NetworkOfferingDetailsVO

use of com.cloud.offerings.NetworkOfferingDetailsVO in project cloudstack by apache.

the class NetworkOfferingDaoImpl method persist.

@Override
@DB
public NetworkOfferingVO persist(NetworkOfferingVO off, Map<Detail, String> details) {
    TransactionLegacy txn = TransactionLegacy.currentTxn();
    txn.start();
    //1) persist the offering
    NetworkOfferingVO vo = super.persist(off);
    //2) persist the details
    if (details != null && !details.isEmpty()) {
        for (NetworkOffering.Detail detail : details.keySet()) {
            _detailsDao.persist(new NetworkOfferingDetailsVO(off.getId(), detail, details.get(detail)));
        }
    }
    txn.commit();
    return vo;
}
Also used : TransactionLegacy(com.cloud.utils.db.TransactionLegacy) NetworkOffering(com.cloud.offering.NetworkOffering) NetworkOfferingVO(com.cloud.offerings.NetworkOfferingVO) Detail(com.cloud.offering.NetworkOffering.Detail) NetworkOfferingDetailsVO(com.cloud.offerings.NetworkOfferingDetailsVO) DB(com.cloud.utils.db.DB)

Example 2 with NetworkOfferingDetailsVO

use of com.cloud.offerings.NetworkOfferingDetailsVO in project cloudstack by apache.

the class NetworkOfferingDetailsDaoImpl method getNtwkOffDetails.

@Override
public Map<NetworkOffering.Detail, String> getNtwkOffDetails(long offeringId) {
    SearchCriteria<NetworkOfferingDetailsVO> sc = DetailSearch.create();
    sc.setParameters("offeringId", offeringId);
    List<NetworkOfferingDetailsVO> results = search(sc, null);
    Map<NetworkOffering.Detail, String> details = new HashMap<NetworkOffering.Detail, String>(results.size());
    for (NetworkOfferingDetailsVO result : results) {
        details.put(result.getName(), result.getValue());
    }
    return details;
}
Also used : HashMap(java.util.HashMap) NetworkOffering(com.cloud.offering.NetworkOffering) Detail(com.cloud.offering.NetworkOffering.Detail) NetworkOfferingDetailsVO(com.cloud.offerings.NetworkOfferingDetailsVO)

Aggregations

NetworkOffering (com.cloud.offering.NetworkOffering)2 Detail (com.cloud.offering.NetworkOffering.Detail)2 NetworkOfferingDetailsVO (com.cloud.offerings.NetworkOfferingDetailsVO)2 NetworkOfferingVO (com.cloud.offerings.NetworkOfferingVO)1 DB (com.cloud.utils.db.DB)1 TransactionLegacy (com.cloud.utils.db.TransactionLegacy)1 HashMap (java.util.HashMap)1