<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:hx="http://www.ibm.com/jsf/html_extended"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:pdc="http://pdc.can.ibm.com"
xmlns:fsaic="http://saic.can.com">
<f:loadBundle var="caseMgmtText" basename="com.ibm.pdc.ephs.casemanagement.nl.commonBundle" />
##################DataTable
<h:dataTable styleClass="tableStyle2"
rowClasses="normalcolor,altcolor" headerClass="sort header2"
border="0" cellpadding="0" cellspacing="0" width="100%"
value="#{pc_RecallSearch.resultsDataModel}" var="results"
id="RecallSearch_pc_RecallSearch_resultsDataModel0">
<h:column id="RecallSearch_column0">
<f:facet name="header" id="RecallSearch_facet0">
<h:outputText value="#{lbls.select}" id="RecallSearch_lbls_select0"></h:outputText>
</f:facet>
<h:selectBooleanCheckbox styleClass="selectBooleanCheckbox" value="#{results.select}" id="RecallSearch_results_select0"/>
</h:column>
<h:column id="RecallSearch_column1">
<f:facet name="header" id="RecallSearch_facet1">
<h:commandLink styleClass="#{pc_RecallSearch.catalogueItemCodeSortState}"
action="#{pc_RecallSearch.sortByCatalogueItemCode}"
immediate="true" id="RecallSearch_commandLink0">
<h:outputText value="#{lbls.table_catItemCode}" id="RecallSearch_lbls_table_catItemCode0"/>
</h:commandLink>
</f:facet>
<h:outputText value="#{results.productLot.catalogueItem_L6.catalogueItemID}"
id="RecallSearch_results_productLot_catalogueItem_L6_catalogueItemID0"></h:outputText>
</h:column>
</h:dataTable>
##################Create panel with Border
<h:panelGrid columns="1" width="100%" styleClass="holdContent" cellpadding="0" cellspacing="0" id="newids7602">
##################Creating meny selection list
<h:selectManyListbox styleClass="dropdownMed"
rendered="#{empty pc_RecallSearch.viewObj.searchParameters.catalogueItemCode ? 'false' : 'true'}"
value="#{pc_RecallSearch.viewObj.searchParameters.productLotNumbers}"
size="8"
id="RecallSearch_pc_RecallSearch_viewObj_searchParameters_productLotNumbers0">
<f:selectItems value="#{pc_RecallSearch.lotNumberList}" id="RecallSearch_pc_RecallSearch_lotNumberList0" />
<f:attribute name="fieldRef" value="lotNumber" id="RecallSearch_lotNumber0" />
</h:selectManyListbox>
##################Select One Menu
<h:selectOneMenu value="#{pc_CatalogueItemSearch.viewObj.searchParameters.orderSetKey}" rendered="#{pc_CatalogueItemSearch.renderIPCCreateRequisition}" id="idsnew1252">
<f:selectItems value="#{pc_CatalogueItemSearch.orderSetList}" id="idsnew1253" />
</h:selectOneMenu>
##################Output Text
<h:outputText styleClass="required" value="*" id="RecallSearch_X0" />
##################Input Text
<h:inputText maxlength="255" styleClass="textfieldSmall" value="#{pc_CatalogueItemSearch.viewObj.searchParameters.findSearchString}" id="idsnew992FindSearchString"></h:inputText>
##################Command Button
<hx:commandExButton type="submit"
value="#{lbls.searchCatalogueBtn}" styleClass="buttonNormal"
action="#{pc_RecallSearch.doBtnAddCatalogueItem}"
onclick="return setPropertyBrokerAction(formName, 'hiddenInputField', 'CatalogueItemSearchDataTypeAction');"
id="RecallSearch_lbls_searchCatalogueBtn0"></hx:commandExButton>
##################Division
<saic:panoramaDiv styleClass="sysMessages" id="newids7599">
<h:messages showDetail="true" showSummary="false" layout="table"
id="errorMsgs" warnClass="errorMessage" errorClass="errorMessage"
infoClass="infoMessage" />
</saic:panoramaDiv>
##################Loading bundles
<f:loadBundle basename="com.saic.ephs.inventory.bundles.ProcessManufacturerRecallPortletResource" var="lbls" id="newids7600" />
<f:loadBundle basename="com.saic.ephs.inventory.bundles.error" var="error" id="newids7601" />
<f:loadBundle id="common_bundle_id" basename="com.saic.ephs.commonLabels" var="common" />
##################HRules dots
<h:panelGrid columnClasses="hruleDots" width="100%"
cellpadding="0" cellspacing="0" id="newids7612">
<h:outputText value=" " id="newids7613"></h:outputText>
</h:panelGrid>
#######################display multiple records in single column(a,b,c,d)with hyperlinks
<ui:repeat value="#{pc_PrescriptionFill.view.medRecs}" var="medRec">
<h:commandLink id="#{medRec}MedReclink" action="#{pc_PrescriptionFill.navigateToInterventionDetails}">
<h:outputText id="#{medRec}medRecValueId" value="#{medRec}" />
<f:param id="#{medRec}interventionIdParam" name="interventionId" value="#{medRec}" />
</h:commandLink>
<h:outputText value=", " id="#{medRec}commaText"/>
</ui:repeat>
#######################use java script in jsf
we have multiple records(same class records).We have button for each and every record.When we click second button (value) should be add to that record.
<ui:define name="extraHeadContents">
<script type="text/javascript" src="${relativeRootPath}/saic/js/SAICJavascript.js" />
<script type="text/javascript">
function setPrescriptionId(prescriptionId)
{
document.getElementById('prescriptionId').value = "";
document.getElementById('prescriptionId').value = prescriptionId;
}
</script>
</ui:define>
<input type="hidden" id="prescriptionId" name="prescriptionId" value="" />
<h:panelGroup id="linkMedRec"
rendered="#{pc_PrescriptionFill.interventionView and pc_PrescriptionFill.prescriptionMedUpdate}">
<fsaic:commandButton value="#{lbls.LinkMedRec}"
id="LinkMedRecButton"
backingBean="#{pc_PrescriptionFill}"
onclick="setPrescriptionId(${drug.prescription.key});"
action="doLinkMedRec" />
<pdc:nbsp />
<h:commandLink id="MedReclink"
action="#{pc_PrescriptionFill.navigateToInterventionDetails}">
<h:outputText id="medRecValueId"
value="#{drug.interventionLinkString}" />
<f:param id="interventionIdParam" name="interventionId"
value="#{drug.intervention.key}" />
</h:commandLink>
</h:panelGroup>
backing bean:
public String doLinkMedRec()
{
String value = (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap()
.get(PRESCRIPTION_ID);
getSessionScope().put(PRESCRIPTION_ID, value);
List<PrescriptionFill> list = getView().getPrescriptionFills();
if (!CollectionUtils.isEmpty(list))
{
NavigationUtilities.addCurrentLocation(getSessionScope(), NavigationConstants.PRESCRIPTION_FILL);
return NavigationConstants.SEARCH_INTERVENTION;
}
return NavigationConstants.NOWHERE;
}
Navigate to another page
public String navigateToInterventionDetails()
{
String selectedIntervention = (String) getRequestParam().get(REQUEST_PARAM_INTERVENTION_ID);
if (StringUtils.isNotEmpty(selectedIntervention))
{
getRequestScope().put(SessionConstants.INTERVENTION_ID, selectedIntervention);
NavigationUtilities.addCurrentLocation(getSessionScope(), NavigationConstants.PRESCRIPTION_FILL);
return NavigationConstants.MAINTAIN_INTERVENTION;
}
else
{
return NavigationConstants.NOWHERE;
}
}
set the value to that record
private void populateInterventionsDetails(MaintainPrescriptionFillContainer prescriptionFillContainer)
{
Intervention intervention = (Intervention) getRequestScope().get(RequestConstants.INTERVENTION);
if (intervention != null)
{
String value = (String)getSessionScope().get(PRESCRIPTION_ID);
if (value != null)
{
for (PrescriptionFill fill : prescriptionFillContainer.getPrescriptionFills())
{
if (StringUtils.equals(fill.getPrescription().getKey().toString(), value))
{
fill.setIntervention(intervention);
}
}
getSessionScope().remove(PRESCRIPTION_ID);
}
getRequestScope().remove(RequestConstants.INTERVENTION);
}
}
#################How to configure a query in hbm file
Setting the parameters and getting data in java
public List<Long> findDuplicateADRDrugs(AdverseDrugReactionSuspectedDrug drug, DAOUser user) throws DAOException
{
List<Long> returnList = new ArrayList<Long>();
Query qry = null;
qry = getSession().getNamedQuery(QUERY_FIND_DUPLICATE_ADR_DRUGS);
qry.setDate(QUERY_PARAM_ADR_DATE, drug.getTherapyStartDate());
qry.setBigDecimal(QUERY_PARAM_ADR_DRUG, TerminologyCode.isInvalidCode(drug.getDrug()) ? null : new BigDecimal(drug
.getDrug().getCode()));
qry.setBigDecimal(QUERY_PARAM_SUBJECT_ID, drug.getAdverseDrugReaction().getHumanSubject() == null ? null : new BigDecimal(
drug.getAdverseDrugReaction().getHumanSubject().getKey()));
List<BigDecimal> list = qry.list();
if (list != null)
{
for (BigDecimal decimal : list)
{
if (decimal != null)
{
returnList.add(new Long(decimal.longValue()));
}
}
}
return returnList;
}
This is queries.hbm.xml file
<sql-query name="FindDuplicateADRDrugs"><![CDATA[
SELECT adr.ADVERSE_DRUG_REACTION_ID FROM ADR_SUSPECTED_DRUG asd
JOIN ADR adr
ON adr.ADVERSE_DRUG_REACTION_ID = asd.ADVERSE_DRUG_REACTION_ID
AND adr.IS_DELETED_IND = 'N'
WHERE (asd.THERAPY_START_DATE = :adrDate)
AND (:drug IS NOT NULL AND asd.PRESCRIPTION_ID = :drug)
AND adr.SUBJECT_ID = :subjectId
]]></sql-query>
cfg file
<mapping resource="ormapping/queries/queries.hbm.xml" />
#####################Sorting records based on date
Collections.sort(list, new Comparator()
{
public boolean compareTo(Object o1, Object o2)
{
InterventionWithFollowUpView object1 = (InterventionWithFollowUpView) o1;
InterventionWithFollowUpView object2 = (InterventionWithFollowUpView) o2;
Date d1 = object1.getEndDate();
Date d2 = object2.getEndDate();
return d1.after(d2);
}
public int compare(Object inteventionFollowUp1, Object inteventionFollowUp2)
{
if (compareTo(inteventionFollowUp1, inteventionFollowUp2))
{
return 1;
}
else
{
return -1;
}
}
});
##########################Sorting drugs based on drug name
public List<Prescription> sortPrescription(List<Prescription> pres)
{
Collections.sort(pres, new Comparator<Prescription>()
{
public int compare(Prescription pres1, Prescription pres2)
{
String p1 = pres1.getCatalogueItem().getName();
String p2 = pres2.getCatalogueItem().getName();
if (p1.compareToIgnoreCase(p2) >= 0)
{
return 1;
}
else
{
return -1;
}
}
});
return pres;
}
#########################Display error message in the top of page
<div class='sysMessages'>
<h:messages showDetail="true" showSummary="false" layout="table"
id="errorMsgs" warnClass="warningMessage" errorClass="errorMessage"
infoClass="infoMessage" styleClass="alertText">
</h:messages>
</div>
########################How to include jsf file in another jsf in facelets
<ui:include src="fragments/AdverseDrugReactionDeleteSection.xhtml">
<ui:param name="pagecode" value="#{pc_AdverseDrugReactionDetails}"/>
<ui:param name="id" value="AdverseDrugReactionDetailsDeleteSection"/>
<ui:param name="formId" value="drugReactionDetailsForm"/>
<ui:param name="backingBean" value="#{pc_AdverseDrugReactionDetails.view.buttonsSectionTop}"/>
</ui:include>
#########################How to get default date with error message
String[] msgKeys = new String[1];
msgKeys[0] = DateUtils.formatWithLocale(DateUtils.newDate(), DateConstants.PARSE_PATTERN_OUTPUT_DATE, getLocale());
String description = MessageUtils.getInstance().getMessage(BundleConstants.ADVERSE_DRUG_REACTION_DETAILS_BUNDLE,
DEFAULT_WARNING_MESSAGE, msgKeys, getLocale());
########################Sorting the Array of Strings by using Arrays class with case insensitive
public String getDrug()
{
String returnValue = null;
if (drug == null)
{
Set<AdverseDrugReactionSuspectedDrug> drugs = getBaseObject().getSuspectedDrugs();
String[] drugValue = new String[drugs.size()];
int i = 0;
for (AdverseDrugReactionSuspectedDrug adrDrug : drugs)
{
drugValue[i] = adrDrug.getPrescription().getCatalogueItem() != null ? adrDrug.getPrescription().getCatalogueItem()
.getName() : adrDrug.getPrescription().getDrugDescription();
i++;
}
Arrays.sort(drugValue, String.CASE_INSENSITIVE_ORDER);
for (i = 0; i < drugValue.length; i++)
{
if (StringUtils.isEmpty(returnValue))
{
returnValue = drugValue[i];
}
else
{
returnValue = returnValue + COMMA_SPACE_DELIMITER + drugValue[i];
}
}
drug = returnValue;
}
return drug;
}
####################################How to clear component data by using java script
onclick="clearSuspectedDrugOtherProvider();"------------button click
function clearSuspectedDrugOtherProvider()
{
// Get the components.
var otherProviderText = document.getElementById('drugReactionDetailsForm:SuspectedDrugsSection:ADRDetailsSuspectedDrugsSectionPrescribedByProviderFilterIdOtherProviderInputID');
// Clear all the component.
if(null!=otherProviderText){
otherProviderText.value="";
}
}
####################################New arrayList
CopyOnWriteArrayList<PrescriptionTableView> list =
new CopyOnWriteArrayList<PrescriptionTableView>(getTableManager().getSelectedResults());
###################################Uase of Projection
protected DetachedCriteria createReportingSourceCriteria(Criteria investigationCriteria)
{
// If Reporting Source Criteria is null, then create a new one.
if (null == reportingSourceCriteria)
{
reportingSourceCriteria = DetachedCriteria.forClass(ReportingSource.class, "reportingSource").setProjection(
Projections.property(CaseCommonConstants.ENTITY_ID)).add(
Restrictions.eq(CaseCommonConstants.DELETED_INDICATOR, false)).add(
Property.forName("reportingSource.investigation.id").eqProperty(INVESTIGATION_ALIAS + ".id"));
investigationCriteria.add(Subqueries.exists((reportingSourceCriteria)));
}
return reportingSourceCriteria;
}
##################################same id and different values into map
public Map<Long, StringBuffer> findOutbreakIdDisesaseCodeByOutbreakIds(Long investigationId)
{
final StringBuffer queryString = new StringBuffer();
queryString.append("select outbreakDisease.outbreak.id,outbreakDisease.diseaseCodeCncptId ");
queryString
.append(" from OutbreakDisease outbreakDisease where outbreakDisease.deleted ='N' and outbreakDisease.outbreak.id in ");
queryString.append(" (select obGroup.outbreak.id from OutbreakGroup obGroup where obGroup.investigationGroup in ");
queryString.append(" (select invGrp.investigationGroupId from InvestigationGroupOutbreak invGrp ");
queryString.append(" where invGrp.investigationId = ?)) order by outbreakDisease.outbreak.id desc");
List<Object[]> obs = (List<Object[]>) getHibernateTemplate().find(queryString.toString(), investigationId);
Map<Long, StringBuffer> map = new HashMap<Long, StringBuffer>();
StringBuffer sb = new StringBuffer();
for (Object o : obs)
{
//array[0] holding Outbreak id value
//array[1] holding Disease Coded concept id
Object[] array = (Object[]) o;
if (map.containsKey((Long) array[0]))
{
sb = new StringBuffer(map.get(array[0]));
sb.append("," + array[1]);
map.put((Long) array[0], sb);
sb = null;
}
else
{
sb = new StringBuffer();
sb.append(array[1]);
map.put((Long) array[0], sb);
sb = null;
}
}
return map;
}
#########################################How to pass parameters values which configured query in qeries
<sql-query name="QUERY_FIND_DUPLICATE_ADR_DRUGS"><![CDATA[
SELECT adr.ADVERSE_DRUG_REACTION_ID FROM ADR_SUSPECTED_DRUG asd
JOIN ADR adr
ON adr.ADVERSE_DRUG_REACTION_ID = asd.ADVERSE_DRUG_REACTION_ID
AND adr.IS_DELETED_IND = 'N'
AND asd.IS_DELETED_IND = 'N'
WHERE (adr.DATE_RECEIVED = :adrDate)
AND (:drug IS NOT NULL AND asd.PRESCRIPTION_ID = :drug)
AND (:adrId IS NULL OR asd.ADVERSE_DRUG_REACTION_ID != :adrId)
AND adr.INVESTIGATION_ID = :investigationId
]]></sql-query>
public List<Long> findDuplicateADRDrugs(AdverseDrugReactionSuspectedDrug drug, DAOUser user)
{
List<Long> returnList = new ArrayList<Long>();
Query qry = null;
qry = getSession().getNamedQuery(QUERY_FIND_DUPLICATE_ADR_DRUGS);
qry.setBigDecimal(QUERY_PARAM_ADR_ID, drug.getAdverseDrugReaction().getKey() == null ? null : new BigDecimal(drug
.getAdverseDrugReaction().getKey()));
qry.setDate(QUERY_PARAM_ADR_DATE, drug.getAdverseDrugReaction().getDateReceived());
qry.setBigDecimal(QUERY_PARAM_ADR_DRUG, (drug.getPrescription() == null) ? null : new BigDecimal(drug.getPrescription()
.getKey()));
qry.setBigDecimal(QUERY_PARAM_INVESTIGATION_ID, drug.getAdverseDrugReaction().getInvestigation() == null ? null
: new BigDecimal(drug.getAdverseDrugReaction().getInvestigation().getKey()));
List<BigDecimal> list = qry.list();
if (list != null)
{
for (BigDecimal decimal : list)
{
if (decimal != null)
{
returnList.add(new Long(decimal.longValue()));
}
}
}
return returnList;
}
--------------------------------------------------------------------------------------------------------------------------------------------------------------
############################################Clearing Faces context messages
public void clearMessages()
{
Iterator<FacesMessage> facesMessagesIterator = getFacesContext().getMessages();
while(facesMessagesIterator.hasNext())
{
facesMessagesIterator.next().setDetail(EMPTY_STRING);
}
}
############################################How to add projection
1)Here AliasedProjection sub class is CustomPropertyAliasProjection in panorama application
ProjectionList pList = Projections.projectionList();
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_EXPOSURE_ID, TransmissionEvent.FIELD_EXPOSURE_ID));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_EXPOSURE_NAME, TransmissionEvent.FIELD_EXPOSURE_NAME));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_END_DATE, TransmissionEvent.FIELD_END_DATE));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_END_TIME, TransmissionEvent.FIELD_END_TIME));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_START_DATE, TransmissionEvent.FIELD_START_DATE));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_START_TIME, TransmissionEvent.FIELD_START_TIME));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_LOCATION_NAME, TransmissionEvent.FIELD_LOCATION_NAME));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_EXPOSURE_SETTING,TransmissionEvent.FIELD_EXPOSURE_SETTING));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_EXPOSURE_SETTING_TYPE,TransmissionEvent.FIELD_EXPOSURE_SETTING_TYPE));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_INVESTIGATION, TransmissionEvent.FIELD_INVESTIGATION));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_OUTBREAK, TransmissionEvent.FIELD_OUTBREAK));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_ADDRESS.concat(DOT).concat(Address.FIELD_LATTITUDE),TransmissionEvent.FIELD_LATTITUDE));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_ADDRESS.concat(DOT).concat(Address.FIELD_LONGITUDE),TransmissionEvent.FIELD_LONGITUDE));
pList.add(new CustomPropertyAliasProjection(TransmissionEvent.FIELD_INVALID, TransmissionEvent.FIELD_INVALID));
criteria.setProjection(Projections.distinct(pList));
2)
DetachedCriteria crit = DetachedCriteria.forClass(RequisitionItem.class);
crit.setProjection(Projections.projectionList().add(Projections.property(RequisitionItem.FIELD_CATALOGUE_ITEM_L5))
.add(Projections.property(RequisitionItem.FIELD_REQUISITION)));
3)
String[] props = new String[] { RequisitionItem.FIELD_CATALOGUE_ITEM_L5, RequisitionItem.FIELD_REQUISITION };
DetachedCriteria crit = DetachedCriteria.forClass(RequisitionItem.class);
crit.setProjection(super.getProjectionList(props));
protected ProjectionList getProjectionList(String[] props)
{
return getProjectionList(props, "");
}
protected ProjectionList getProjectionList(String[] props, String alias)
{
String lAlias = "";
if (StringUtils.isNotBlank(alias))
{
lAlias = alias.concat(DOT);
}
ProjectionList pList = Projections.projectionList();
for (int i = 0; i < props.length; i++)
{
pList.add(new CustomPropertyAliasProjection(lAlias.concat(props[i]), props[i]));
}
return pList;
}
Aove code will give the saparate objects. If we wanna get in single object
4)
RequesationItem.java
//Unmapped fields, these fields are part of the another objects
public static final String FIELD_REQUISIITON_ID = "requisitionId";
public static final String FIELD_REPLENISHMENT_HOLDING_POINT = "replenishmentHoldingPoint";
public static final String FIELD_REQUESTOR_HOLDING_POINT = "requestorHoldingPoint";
public static final String FIELD_REQUESTED_DELIVERY_PICKUP_DATE = "requestedDeliveryPickupDate";
private Long requisitionId;
private HoldingPointLight replenishmentHoldingPoint;
private HoldingPointLight requestorHoldingPoint;
private Date requestedDeliveryPickupDate;
//pList we are adding some extra values ProjectionList pList = super.getProjectionList(props); after this methods these we are creating in above class
//here result transformer is transforming all the results
RequisitionSearchDaoHibernateImpl.java
public List<RequisitionItem> getRequisitionItemsOnOrder(Long catalogueItemKey, Long orgId, Boolean overrideHpSecurity)
throws DaoException
{
String[] props = new String[] { RequisitionItem.FIELD_CATALOGUE_ITEM_L5,
RequisitionItem.FIELD_DATALESS_KEY,
RequisitionItem.FIELD_REQUISITION_QUANTITY, RequisitionItem.FIELD_BACKORDER_QUANTITY };
DetachedCriteria crit = DetachedCriteria.forClass(RequisitionItem.class);
crit.createAlias(RequisitionItem.FIELD_REQUISITION, RequisitionItem.FIELD_REQUISITION);
ProjectionList pList = super.getProjectionList(props);
pList.add(new CustomPropertyAliasProjection(RequisitionItem.FIELD_REQUISITION.concat(DOT).concat(
Requisition.FIELD_DATALESS_KEY), RequisitionItem.FIELD_REQUISIITON_ID));
pList.add(new CustomPropertyAliasProjection(RequisitionItem.FIELD_REQUISITION.concat(DOT).concat(
Requisition.FIELD_REPLENISHMENT_HOLDING_POINT), RequisitionItem.FIELD_REPLENISHMENT_HOLDING_POINT));
pList.add(new CustomPropertyAliasProjection(RequisitionItem.FIELD_REQUISITION.concat(DOT).concat(
Requisition.FIELD_REQUESTOR_HOLDING_POINT), RequisitionItem.FIELD_REQUESTOR_HOLDING_POINT));
pList.add(new CustomPropertyAliasProjection(RequisitionItem.FIELD_REQUISITION.concat(DOT).concat(
Requisition.FIELD_REQUESTED_DELIVERY_PICKUP_DATE), RequisitionItem.FIELD_REQUESTED_DELIVERY_PICKUP_DATE));
crit.setProjection(pList);
String[] statuses = { InventoryItermKeyCodes.REQITEMSTATUS_DRAFT, InventoryItermKeyCodes.REQITEMSTATUS_PACKED,
InventoryItermKeyCodes.REQITEMSTATUS_PENDINGAPPROVAL, InventoryItermKeyCodes.REQITEMSTATUS_BACKORDERED,
InventoryItermKeyCodes.REQITEMSTATUS_PENDINGMANUALAPPROVAL, InventoryItermKeyCodes.REQITEMSTATUS_AT_PICKING,
InventoryItermKeyCodes.REQITEMSTATUS_INVALIDATED_AT_PICKING,
InventoryItermKeyCodes.REQITEMSTATUS_PENDINGPHAUTHORIZATION, InventoryItermKeyCodes.REQITEMSTATUS_PENDINGPICK,
InventoryItermKeyCodes.REQITEMSTATUS_PICKED, InventoryItermKeyCodes.REQITEMSTATUS_SHIPPED };
crit.add(Expression.in(RequisitionItem.FIELD_STATUS, statuses));
crit.add(Expression.eq(RequisitionItem.FIELD_CATALOGUE_ITEM_L5.concat(DOT).concat(CatalogueItem_L5.FIELD_DATALESS_KEY),
catalogueItemKey));
if (BooleanUtils.isFalse(overrideHpSecurity))
{
crit.add(DaoManager.getHoldingPointDao().getHPOrganizationFilterCriterion(
RequisitionItem.FIELD_REQUISITION.concat(DOT).concat(Requisition.FIELD_REQUESTOR_HOLDING_POINT).concat(DOT)
.concat(HoldingPoint.FIELD_DATALESS_KEY), orgId, Boolean.FALSE, Boolean.TRUE));
}
crit.setResultTransformer(Transformers.aliasToBean(RequisitionItem.class));
return super.genericList(crit);
}
#################Display new window
<hx:outputLinkEx styleClass="popupLink"
rendered="#{pc_view_investigation_history.investigationHistoryAvailable}"
id="investigationHistLink">
<h:outputText id="history" value="${caseMgmtText.investigation_history_title}" />
<hx:behavior event="onclick" id="onClickOnHistoryLink"
behaviorAction="get"
onActionFunction="MM_openBrWindow('sections/InvestigationHistory.xhtml','PanoramaSupportInfo','width=829,height=356');return false" />
</hx:outputLinkEx>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:hx="http://www.ibm.com/jsf/html_extended"
xmlns:pdc="http://pdc.can.ibm.com">
<ui:composition>
<c:set var="relativeRootPath"
value="#{facesContext.externalContext.request.contextPath}" />
<f:loadBundle var="caseMgmtText"
basename="com.ibm.pdc.ephs.casemanagement.nl.commonBundle" />
<head>
<title>
${caseMgmtText.investigation_history_title_head} ${pc_view_investigation_history.investigationId} 
${caseMgmtText.investigation_history_title_tail}
</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="${relativeRootPath}/global/css/Styles.css" rel="stylesheet"
type="text/css" />
<link href="${relativeRootPath}/global/css/print.css" media="print"
type="text/css" rel="stylesheet" />
<script src="${relativeRootPath}/js/globalJavaScript.js"
type="text/javascript"></script>
</head>
<div class="popupBody">
<div id="EPHSpopupBanner">
<table border="0" width="100%" cellpadding="0" cellspacing="0">
<tr class="h2title">
<th>${caseMgmtText.investigation_history_title_head} ${pc_view_investigation_history.investigationId} 
${caseMgmtText.investigation_history_title_tail}
</th>
<td class="middle"> </td>
<td class="right">
<a href="javascript:window.print();">
<img src="${relativeRootPath}/global/images/icons/print_white.gif" title="Print" alt="Print" /></a>
</td>
<td> </td>
</tr>
</table>
</div>
<div id="EPHSpopupContent">
<hx:scriptCollector id="scriptCollectorCDCaseMgmt"
postRender="#{pc_view_investigation_history.onPostRender}" >
<h:dataTable
id="investigationHistoryDataTable"
value="#{pc_view_investigation_history.investigationHistory}"
var="history" rowClasses="rowClass1, altcolor"
styleClass="tableStyle2" border="0" cellpadding="0" cellspacing="0"
width="100%"
rendered="#{pc_view_investigation_history.investigationHistory[0] != null}"
binding="#{pc_view_investigation_history.investigationHistoryUIData}"
>
<h:column headerClass="header2" id="dateTimeUpdated">
<f:facet name="header">${caseMgmtText.investigation_history_date_time_updated}</f:facet>
<h:outputText id="dateTimeUpdated"
value="#{history.createdOn}">
<pdc:dateTimeConverter/>
</h:outputText>
</h:column>
<h:column headerClass="header2" id="updatedBy">
<f:facet name="header">${caseMgmtText.investigation_history_updated_by}</f:facet>
<h:outputText id="dateTimeUpdated" value="#{history.createdByName}" />
</h:column>
<h:column headerClass="header2" id="dispositionDt">
<f:facet name="header">${caseMgmtText.investigation_history_disposition_date}</f:facet>
<h:outputText id="dispositionDate"
value="#{history.dispositionDate}">
<f:convertDateTime type="date" pattern="yyyy MMM dd" />
</h:outputText>
</h:column>
<h:column headerClass="header2" id="desposition">
<f:facet name="header">${caseMgmtText.investigation_history_disposition}</f:facet>
<h:outputText id="desposition" value="#{history.desposition}" />
</h:column>
<h:column headerClass="header2" id="statusDate">
<f:facet name="header">${caseMgmtText.investigation_history_status_date}</f:facet>
<h:outputText id="statusDate" value="#{history.statusDate}">
<f:convertDateTime type="date" pattern="yyyy MMM dd" />
</h:outputText>
</h:column>
<h:column headerClass="header2" id="statusCodeCncptId">
<f:facet name="header">${caseMgmtText.investigation_history_status}</f:facet>
<h:outputText id="statusCodeCncptId" value="#{history.statusCode}" />
</h:column>
</h:dataTable>
</hx:scriptCollector>
</div>
<div>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="hruleDots"> </td>
</tr>
<tr>
<td class="buttons" align="right">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td><input type="button" name="Submit232"
class="buttonSubmit" value="Close X"
onclick="javascript:window.close();" />  </td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="hruleDots"> </td>
</tr>
</table>
</div>
</div>
</ui:composition>
</html>
######################################Retrive data from the relationship class
EMp------->address
by using address id get the empdetails
private void addUnknownContactCriteria(Criteria criteria, Address search)
{
criteria.createAlias(Employee.FIELD_ADDRESS_SET, Employee.FIELD_ADDRESS_SET);
if (StringUtils.isNotBlank(search.getAddressId()))
{
criteria.add(Expression.eq(
Employee.FIELD_ADDRESS_SET.concat(DOT).concat(Address.FIELD_ADDRESS_ID),
search.getAddressId()));
}
}
#####################################Sql query by using criteria
Criteria c1 = subCriteria.getExecutableCriteria(ConfigurationClass.getSessionFactoryObject().openSession());
CriteriaImpl criteriaImpl = (CriteriaImpl)c1;
SessionImplementor session = criteriaImpl.getSession();
SessionFactoryImplementor factory = session.getFactory();
CriteriaQueryTranslator translator=new CriteriaQueryTranslator(factory,criteriaImpl,criteriaImpl.getEntityOrClassName(),CriteriaQueryTranslator.ROOT_SQL_ALIAS);
String[] implementors = factory.getImplementors( criteriaImpl.getEntityOrClassName() );
CriteriaJoinWalker walker = new CriteriaJoinWalker((OuterJoinLoadable)factory.getEntityPersister(implementors[0]),
translator,
factory,
criteriaImpl,
criteriaImpl.getEntityOrClassName(),
session.getEnabledFilters() );
String sql=walker.getSQLString();
#####################################How to support more than 1000 parameters in the criteria in method
public static final void addCollectionDataToCriteria(Criteria c, Collection<Object> collection, String property)
{
//new Array List object requires for operations. If we dosen't create Arrays.asList dosen't give the new list it gives the java.util.Arrays$ArrayList, on this object we can't do any operations
List<Object> l = new ArrayList<Object>(Arrays.asList(collection.toArray()));
Disjunction orCondiation = Restrictions.disjunction();
if(l.size()>1000)
{
while(l.size()>1000)
{
orCondiation.add(Restrictions.in(property, l.subList(0, 1000)));
l.subList(0, 1000).clear();
}
}
orCondiation.add(Restrictions.in(property, l));
c.add(orCondiation);
}
##############Display Unique message on Faces context
public void displayUniqueWarning(String bundleKey, String msgKey, String messageId)
{
if (!isExistingMessage(bundleKey, msgKey, messageId))
{
displayWarningMessage(bundleKey, msgKey, messageId);
}
}
private boolean isExistingMessage(String bundleKey, String messageKey, String messageId)
{
ResourceBundle bundle = getBundle(bundleKey);
FacesContext context = FacesContext.getCurrentInstance();
Iterator messages = context.getMessages(messageId);
String newMessage = bundle.getString(messageKey);
while (messages.hasNext())
{
FacesMessage message = (FacesMessage) messages.next();
if (StringUtils.isNotBlank(message.getDetail()) && StringUtils.isNotBlank(newMessage)
&& message.getDetail().trim().equals(newMessage))
{
return true;
}
}
return false;
}
private void displayWarningMessage(String bundle, String messageKey, String messageId)
{
ResourceBundle resourceBundle = getBundle(bundle);
String message = constructMessage(resourceBundle, messageKey);
FacesMessage faceMsg = new FacesMessage(FacesMessage.SEVERITY_WARN, message, message);
FacesContext.getCurrentInstance().addMessage(messageId, faceMsg);
}
#############Check exisiting message with parameters
public void displayUniqueError(String bundleKey, String msgKey, String messageId, Object... params)
{
if (!isExistingMessageWithParameters(bundleKey, msgKey, messageId, params))
{
displayErrorMessage(bundleKey, msgKey, messageId, params);
}
}
private boolean isExistingMessageWithParameters(String bundleKey, String messageKey, String messageId, Object... params)
{
ResourceBundle bundle = getBundle(bundleKey);
FacesContext context = FacesContext.getCurrentInstance();
Iterator messages = context.getMessages(messageId);
String newMessage = constructMessageWithParams(bundle, messageKey, params);
while (messages.hasNext())
{
FacesMessage message = (FacesMessage) messages.next();
if (StringUtils.isNotBlank(message.getDetail()) && StringUtils.isNotBlank(newMessage)
&& message.getDetail().trim().equals(newMessage.trim()))
{
return true;
}
}
return false;
}
public String constructMessageWithParams(ResourceBundle resourceBundle, String msgKey, Object params[])
{
String msg = null;
try
{
msg = resourceBundle.getString(msgKey);
if (params != null)
{
MessageFormat mf = new MessageFormat(msg);
msg = mf.format(parseParameters(params), new StringBuffer(), null).toString();
}
}
catch (MissingResourceException e)
{
return null;
}
return msg;
}
private void displayErrorMessage(String bundle, String messageKey, String messageId, Object... params)
{
ResourceBundle resourceBundle = getBundle(bundle);
String message = constructMessageWithParams(resourceBundle, messageKey, params);
FacesMessage faceMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, message, message);
FacesContext.getCurrentInstance().addMessage(messageId, faceMsg);
}
##############Sort data based on two fields(first name and second is date)date of birth is curent to last and name is a to z
Step1: sort data(otherMeds) by using date
otherMeds.addAll(sortRXEffectiveDateOtherMeds(otherMeds));
otherMeds.addAll(sortBlankRXEffectiveDateOtherMeds(otherMeds));
Step2: sort date value meds
private List<PrescriptionTableView> sortRXEffectiveDateOtherMeds(List<PrescriptionTableView> list)
{
// create new list with RX Effective date drugs
List<PrescriptionTableView> rxDateOtherMeds = new ArrayList<PrescriptionTableView>();
for (PrescriptionTableView prescriptionView : list)
{
if (prescriptionView.getStartDate() != null && StringUtils.isNotBlank(prescriptionView.getDrug()))
{
rxDateOtherMeds.add(prescriptionView);
}
}
// removes the listed drugs from the main list
list.removeAll(rxDateOtherMeds);
// This index refers the array list elements positions
int index = 0;
List<PrescriptionTableView> sameDatesMeds = null;
Date date = null;
// continue this until the same dates drugs sorting is completed
while (index < rxDateOtherMeds.size())
{
sameDatesMeds = new ArrayList<PrescriptionTableView>();
// Find the first element drug date
date = rxDateOtherMeds.get(index).getStartDate();
for (PrescriptionTableView sameDatesMed : rxDateOtherMeds)
{
// Check the otehr drugs dates with the indexed date
if (sameDatesMed.getStartDate() != null && date.equals(sameDatesMed.getStartDate()))
{
// Creates new list with same date other meds
sameDatesMeds.add(sameDatesMed);
index++;
}
}
// sort the same RX Effective date drugs by the drug name
list.addAll(sortOtherMeds(sameDatesMeds));
}
return list;
}
Step3: sort blank effective date values by using names in ascending order
private List<PrescriptionTableView> sortBlankRXEffectiveDateOtherMeds(List<PrescriptionTableView> list)
{
List<PrescriptionTableView> blankOtherMeds = new ArrayList<PrescriptionTableView>();
for (PrescriptionTableView prescriptionView : list)
{
if (prescriptionView.getStartDate() == null && StringUtils.isNotBlank(prescriptionView.getDrug()))
{
blankOtherMeds.add(prescriptionView);
}
}
list.removeAll(blankOtherMeds);
return sortOtherMeds(blankOtherMeds);
}
Step4: sorting order based on the name
private List<PrescriptionTableView> sortOtherMeds(List<PrescriptionTableView> otherMeds)
{
Collections.sort(otherMeds, new Comparator<PrescriptionTableView>()
{
public int compare(PrescriptionTableView view1, PrescriptionTableView view2)
{
if (view1.getDrug().compareToIgnoreCase(view2.getDrug()) > 0)
{
return 1;
}
else
{
return -1;
}
}
});
return otherMeds;
}
################Calling java code from Javascript
'#{pc_SpeedTestBackingBean.fileNotFoundErrorMessage}'
provide setter,getter methods and locale variable for the fileNotFoundErrorMessage.
################How to pass the parameters to the resource bundle message
public String constructMessageWithParams(ResourceBundle resourceBundle, String msgKey, Object params[])
{
String msg = null;
try
{
msg = resourceBundle.getString(msgKey);
if (params != null)
{
MessageFormat mf = new MessageFormat(msg);
msg = mf.format(parseParameters(params), new StringBuffer(), null).toString();
}
}
catch (MissingResourceException e)
{
return null;
}
return msg;
}
#################How to ignore regular exp values to string
1.
/**
* This method adds slash to the special characters
*
* @param pattern
* pattern string
*/
private void formatSpecialChar(String pattern)
{
StringBuilder sb = new StringBuilder(pattern);
char specialCharPos;
for (int index = 0; index < sb.length(); index++)
{
specialCharPos = sb.charAt(index);
if (".*+?{[()|\\^$".indexOf(specialCharPos) >= 0)
{
sb.insert(index, "\\");
index++;
}
}
this.searchPattern = sb.toString();
}
2.
searchPattern = Pattern.quote(v.toString());
#################How to remove html special characters
var val = options.selectedItem.innerHTML;
val = val.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"');
$(options.target).value = val;
#################Spring Call Back Method
public BabyBirthEventDo findDetailsBySubjectId(final Long subjectId)
{
BabyBirthEventDo bbe = (BabyBirthEventDo) getHibernateTemplate().execute(new HibernateCallback()
{
public Object doInHibernate(Session session) throws HibernateException
{
session.enableFilter(DELETED_FILTER);
BabyBirthEventDo b = (BabyBirthEventDo) session.createCriteria(BabyBirthEventDo.class).add(
Restrictions.eq(SUBJECT_ID, subjectId)).uniqueResult();
return b;
}
});
return bbe;
}
################Clean directry with ant
<property name="DEST_FOLDER" value="${basedir}/WebContent"/>
<target name="cleanStruts">
<delete dir="${DEST_FOLDER}/WEB-INF/indexes/provider/struts"/>
<delete dir="${DEST_FOLDER}/WEB-INF/indexes/organization/struts"/>
</target>
##############Clean file
<property name="DEST_FOLDER" value="${basedir}/WebContent"/>
<target name="cleanJSP">
<delete file="${DEST_FOLDER}/global/errors/greenDotErrorPage.jsp"/>
<delete file="${DEST_FOLDER}/global/errors/internalErrorPage.jsp"/>
<delete file="${DEST_FOLDER}/global/errors/redDotErrorPage.jsp"/>
</target>
###########################text doc with popup
xmlns:elsaic="http://saic.el.can.com"
<h:panelGroup id="otherreasonRenderedPG" rendered="#{backingBean.preview.reportRejected}">
<c:set var="otherReason" value="#{backingBean.preview.rejectionReasonOther}" />
<c:set var="reasonOtherReason" value="/ #{backingBean.preview.rejectionReason} #{otherReason}" />
<c:set var="popup" value="${elsaic:isStringGreaterThanLength(otherReason,50)}" />
<h:panelGroup id="otherreasonRenderedMyPopupPanel" rendered="#{popup}">
<a id="hoverover" class="popupA"
onmouseover="ShowPopup('ReasonPreviewTextIDPopUp');"
onmouseout="HidePopup('ReasonPreviewTextIDPopUp');">
<h:outputText id="ReasonPreviewTextID"
value="${elsaic:trucateWithContinuationDots(reasonOtherReason,50)}" >
</h:outputText>
</a>
<div id="ReasonPreviewTextIDPopUp" class="popupDiv">
#{otherReason}
</div>
</h:panelGroup>
<h:panelGroup id="otherreasonRenderedPGNoPopupPanel"
rendered="#{not popup}">
<h:outputText id="ReasonPreviewTextIDOutput"
value="${reasonOtherReason}"/>
</h:panelGroup>
</h:panelGroup>
####################WAS Configuration
You set the org.apache.el.parser.COERCE_TO_ZERO property using the administrative console.
Expand Servers > Select WebSphere Application Servers > Click on the appropriate server from the list.
Under Server Infrastructure, expand Java and Process Management > Click on Process definition.
Under Additional Properties, click Java virtual Machine.
Under Additional Properties, click Custom properties.
Click New and add the org.apache.el.parser.COERCE_TO_ZERO property with the value of false if you do NOT want a null value coerced to zero.
Click Save to save the change and restart the WebSphere Application Server to ensure the change takes place.
######################