Example usage for java.lang Integer decode

List of usage examples for java.lang Integer decode

Introduction

In this page you can find the example usage for java.lang Integer decode.

Prototype

public static Integer decode(String nm) throws NumberFormatException 

Source Link

Document

Decodes a String into an Integer .

Usage

From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java

public int TerminateLPLR(View vSubtask) {
    zVIEW WorkView = new zVIEW();
    zVIEW vLPLR = new zVIEW();
    zVIEW vZeidonCM = new zVIEW();
    zVIEW vTaskOI = new zVIEW();
    zVIEW vTaskMetas = new zVIEW();
    zVIEW vActiveMetas = new zVIEW();
    StringBuilder sbViewName = new StringBuilder();
    String viewName;/*from  w w w .  j  av  a  2s.c  o  m*/
    int lTaskId;
    int lTaskUseCnt;
    int nRC;

    GetViewByName(vLPLR, "TaskLPLR", vSubtask, zLEVEL_TASK);
    if (isValid(vLPLR) == false) // View isn't there
    {
        TraceLineS("(tzcmoprs) TerminateLPLR: ", "Unable to drop the Project!");
        return -1;
    }

    // Clean up the CM views for the Task activated Metas.
    GetViewByName(vZeidonCM, "ZeidonCM", vSubtask, zLEVEL_APPLICATION);
    if (isValid(vZeidonCM) == false) {
        MessageSend(vSubtask, "CM00410", "Configuration Management", "Unable to locate ZeidonCM view!",
                zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
        return -1;
    }

    GetViewByName(vActiveMetas, "OpenCM_Metas", vZeidonCM, zLEVEL_SUBTASK);
    GetStringFromAttribute(sbViewName, vLPLR, "LPLR", "Name");
    if (SetCursorFirstEntityByString(vActiveMetas, "LPLR", "Name", sbViewName.toString(), "") < zCURSOR_SET) {
        StringBuilder szMsg = new StringBuilder();

        // It is possible that this problem occurs because the ZKey in
        // TZCMWKS8.POR for the specified LPLR does not match the ZKey
        // in the .XLP for the LPLR.  If that's the case, fix the ZKey
        // in TZCMWKS8.POR!
        zstrcpy(szMsg, "Unable to locate Project in CM ACTIVE view: ");
        zstrcat(szMsg, sbViewName);
        MessageSend(vSubtask, "CM00411", "Configuration Management", szMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
        return -1;
    }

    lTaskId = Integer.decode(SysGetTaskFromView(vSubtask).getTaskId());
    nRC = SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskId, "LPLR");
    while ((nRC == zCURSOR_SET) || (nRC == zCURSOR_SET_NEWPARENT)) {
        viewName = GetStringFromAttribute(vActiveMetas, "W_MetaDef", "CM_ViewName");
        GetViewByName(WorkView, viewName + ".u", vZeidonCM, zLEVEL_SUBTASK);
        if (isValid(WorkView)) {
            DropObjectInstance(WorkView);
        }

        if (GetViewByName(WorkView, viewName + ".r", vZeidonCM, zLEVEL_SUBTASK) > 0) {
            SetAttributeFromString(vActiveMetas, "W_MetaDef", "TaskID", "");
        } else {
            ExcludeEntity(vActiveMetas, "W_MetaDef", zREPOS_NONE);
        }

        nRC = SetCursorNextEntityByInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskId, "LPLR");
    }

    viewName = fnGetTaskOI_ListName(vSubtask);
    GetViewByName(vTaskMetas, viewName, vZeidonCM, zLEVEL_SUBTASK);
    if (isValid(vTaskMetas)) {
        nRC = DriverApplication.SfGetFirstNamedView(vTaskOI, sbViewName, vTaskMetas, zLEVEL_SUBTASK);
        while (nRC > 0) {
            DropView(vTaskOI);
            nRC = DriverApplication.SfGetFirstNamedView(vTaskOI, sbViewName, vTaskMetas, zLEVEL_SUBTASK);
        }

        SfDropSubtask(vTaskMetas, 0);
    }

    lTaskUseCnt = GetIntegerFromAttribute(vLPLR, "LPLR", "TaskUseCount");
    if (lTaskUseCnt > 0) {
        lTaskUseCnt--;
    }

    if (lTaskUseCnt < 1) {
        // DropObjectInstance( vLPLR );
        SetAttributeFromInteger(vLPLR, "LPLR", "TaskUseCount", lTaskUseCnt);
        nRC = SetCursorFirstEntity(vActiveMetas, "W_MetaDef", "LPLR");
        while (nRC == zCURSOR_SET) {
            viewName = GetStringFromAttribute(vActiveMetas, "W_MetaDef", "CM_ViewName");
            GetViewByName(WorkView, viewName + ".u", vZeidonCM, zLEVEL_SUBTASK);
            if (isValid(WorkView)) {
                DropObjectInstance(WorkView);
                ExcludeEntity(vActiveMetas, "W_MetaDef", zREPOS_NEXT);
            } else {
                SetCursorNextEntity(vActiveMetas, "W_MetaDef", "LPLR");
            }
        }

        //    DeleteEntity( vActiveMetas, "LPLR", zREPOS_NONE );
    } else {
        SetAttributeFromInteger(vLPLR, "LPLR", "TaskUseCount", lTaskUseCnt);
    }

    if (ObjectInstanceUpdatedFromFile(vLPLR) == 1) {
        CommitLPLR(vLPLR);
    }

    return (1);
}

From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java

private int fnActivateMetaOI(View vSubtask, zVIEW pvMOI, View vListView, int nType, int lControl) {
    zVIEW vZeidonCM = new zVIEW();
    zVIEW vActiveMetas = new zVIEW();
    zVIEW vTaskMetas = new zVIEW();
    // View    vApplication;
    zVIEW vTaskLPLR = new zVIEW();
    zVIEW CM_View = new zVIEW();
    zVIEW vWkListView = new zVIEW();
    boolean bCopyOI = false;
    int nEntityType;
    int nOrigType;
    int nActiveType, nPhaseCtl;
    boolean bReactivate;
    int lStatus;//from   w  w  w. ja va  2  s .c o  m
    int lTaskID, lCurrentTaskID;
    int lMetaOI_ZKey;
    int ulOrigMetaOI_ZKey = 0;
    StringBuilder sbMetaOI_Name = new StringBuilder();
    StringBuilder sbMetaOI_Def = new StringBuilder();
    StringBuilder sbFileSpec = new StringBuilder();
    StringBuilder sbCM_ViewName = new StringBuilder();
    String szLPLR_Name;
    StringBuilder sbSyncDate = new StringBuilder();
    String szGroupName;
    int nRC;

    // Check to make sure that type is OK.
    nEntityType = fnVerifyType(nType);
    if (nEntityType < 0) {
        return -1;
    }

    if (CheckExistenceOfEntity(vListView, "W_MetaDef") != zCURSOR_SET) {
        MessageSend(vSubtask, "CM00414", "Configuration Management", "NULL Meta Def passed to ActivateMetaOI",
                zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
        return (-16);
    }

    if (CompareAttributeToInteger(vListView, "W_MetaDef", "UpdateInd", 3) == 0) {
        MessageSend(vSubtask, "CM00415", "Configuration Management",
                "Deleted Meta Def passed to ActivateMetaOI", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
        return (-16);
    }

    // I need the view to the TaskLPLR to get the name of the root LPLR in the ActiveMeta OI.
    // It is also needed to properly qualify the task for vWkListView.
    GetViewByName(vTaskLPLR, "TaskLPLR", vSubtask, zLEVEL_TASK);
    szLPLR_Name = GetStringFromAttribute(vTaskLPLR, "LPLR", "Name"); // e.g. Zeidon

    // The following code changes the Type for Domain and Global Operation
    // Activates into Domain Group and Global Operation Group Activates.
    // A new LPLR view, vWkListView, is used because the Domain and Global
    // Operation processing alters the position on the W_MetaType and we
    // want to leave the ListView position unaltered.
    // ulOrigMetaOI_ZKey = GetIntegerFromAttribute( vListView, "W_MetaDef", "CPLR_ZKey" );
    // TraceLineI( "OrigMetaOI_ZKey vListView: ", ulOrigMetaOI_ZKey );
    CreateViewFromViewForTask(vWkListView, vListView, vTaskLPLR);
    ulOrigMetaOI_ZKey = GetIntegerFromAttribute(vWkListView, "W_MetaDef", "CPLR_ZKey");
    // TraceLineI( "OrigMetaOI_ZKey vWkListView: ", ulOrigMetaOI_ZKey );
    SetNameForView(vWkListView, "WkListView", vSubtask, zLEVEL_TASK);
    /* if ( false )
       {
          MessageSend( vSubtask, "CM00418", "Configuration Management",
              "Check WkListView for Operations",
              zMSGQ_OBJECT_CONSTRAINT_ERROR, 0 );
       }
    */
    nOrigType = nType; // keep track of the original type

    if (nType == zSOURCE_DOMAIN_META || nType == zREFER_DOMAIN_META) {
        // Save Domain ZKey for later positioning.
        // TraceLineS( "vWkListView", " dks " );
        // vWkListView.logObjectInstance( );
        ulOrigMetaOI_ZKey = GetIntegerFromAttribute(vWkListView, "W_MetaDef", "CPLR_ZKey");
        TraceLineI("vWkListView W_MetaDef CPLR_ZKey: ", ulOrigMetaOI_ZKey);

        if (nType == zSOURCE_DOMAIN_META) {
            nType = zSOURCE_DOMAINGRP_META;
        } else {
            nType = zREFER_DOMAINGRP_META;
        }

        // Reposition on the correct group type.
        SetCursorFirstEntityByInteger(vWkListView, "W_MetaType", "Type", zREFER_DOMAINGRP_META, "");

        // Then position on the correct Domain within the group type.
        SetCursorFirstEntityByAttr(vWkListView, "W_MetaDef", "Name", vListView, "W_MetaDef", "GroupName", "");
        // szGroupName = GetStringFromAttribute( vListView, "W_MetaDef", "GroupName" );
        // SetCursorFirstEntityByString( vWkListView, "W_MetaDef", "Name", szGroupName, "" );
    }

    if (nType == zSOURCE_GO_META || nType == zREFER_GO_META) {
        // Save Global Operation ZKey for later positioning.
        ulOrigMetaOI_ZKey = GetIntegerFromAttribute(vWkListView, "W_MetaDef", "CPLR_ZKey");

        if (nType == zSOURCE_GO_META) {
            nType = zSOURCE_GOPGRP_META;
        } else {
            nType = zREFER_GOPGRP_META;
        }

        // Reposition on the correct group type.
        SetCursorFirstEntityByInteger(vWkListView, "W_MetaType", "Type", zREFER_GOPGRP_META, "");

        // Then position on the correct Operation within the group type.
        SetCursorFirstEntityByAttr(vWkListView, "W_MetaDef", "Name", vListView, "W_MetaDef", "GroupName", "");
        // szGroupName = GetStringFromAttribute( vListView, "W_MetaDef", "GroupName" );
        // SetCursorFirstEntityByString( vWkListView, "W_MetaDef", "Name", szGroupName, "" );
    }

    // PETTIT The following if else is necessary until CM handles the Open, New, etc. Menu items.
    /*
       DonC comment on 4/21/1996:  I am eliminating the following code for now because our current position is that
       a user can modify a meta that is not checked out but cannot save it.  However, I am leaving the following
       code in case we change our mind.
            
       // If the user requested a Source meta, check the status of the MetaDef.
       // If the status is not 1 (e.g. it is not active), then the user can only
       // reference the meta, so change the meta to a Refer meta.
       if ( nType <= zSOURCE_MAX_META )
       {
          if ( CompareAttributeToInteger( vWkListView, "W_MetaDef","Status", 1 ) != 0 )
          {
    nEntityType = CM_REFER_TYPE;
    nType += 2000;  // Change SOURCE to REFER.
          }
       }
    */

    if (nEntityType == CM_ACTIVE_TYPE) {
        nActiveType = nType;
    } else {
        nActiveType = nType - 2000;
    }

    // Get the view to ZedionCM OI.
    GetViewByName(vZeidonCM, "ZeidonCM", vSubtask, zLEVEL_APPLICATION);

    // Get the view to the vTaskMetas subtask.
    sbMetaOI_Name.setLength(0);
    sbMetaOI_Name.append(fnGetTaskOI_ListName(vSubtask));
    GetViewByName(vTaskMetas, sbMetaOI_Name.toString(), vZeidonCM, zLEVEL_SUBTASK);

    // Get the view to the ActiveMeta OI.
    GetViewByName(vActiveMetas, "OpenCM_Metas", vZeidonCM, zLEVEL_SUBTASK);

    TraceLineS("Looking for TaskLPLR Name: ", GetStringFromAttribute(vTaskLPLR, "LPLR", "Name"));
    SetCursorFirstEntityByAttr(vActiveMetas, "LPLR", "Name", vTaskLPLR, "LPLR", "Name", "");
    bReactivate = true;

    // Check to see if a W_MetaType exists for Type = nActiveType.  If not, then create one.
    if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaType", "Type", nActiveType, "") != zCURSOR_SET) {
        CreateEntity(vActiveMetas, "W_MetaType", zPOS_AFTER);
        SetAttributeFromInteger(vActiveMetas, "W_MetaType", "Type", nActiveType);
    }

    // Check in the Active Meta List for a hit on the requested Meta.
    lMetaOI_ZKey = GetIntegerFromAttribute(vWkListView, "W_MetaDef", "CPLR_ZKey");
    nRC = SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "");
    if (nRC == zCURSOR_SET) {
        // It is in the Active List, now check if it's really still active.
        GetStringFromAttribute(sbCM_ViewName, vActiveMetas, "W_MetaDef", "CM_ViewName");
        lTaskID = GetIntegerFromAttribute(vActiveMetas, "W_MetaDef", "TaskID");
        if (nEntityType == CM_REFER_TYPE) {
            zstrcat(sbCM_ViewName, ".r");
            if (GetViewByName(CM_View, sbCM_ViewName.toString(), vZeidonCM, zLEVEL_SUBTASK) < 1) {
                // It's in vActiveMetas but it's not loaded for REFER.
                /*
                      Removed by DonC on Aug 11, 1998.
                            if ( TaskID <= 0 )
                            {
                               // If it's not loaded for update Exclude it
                               ExcludeEntity( vActiveMetas, "W_MetaDef", zREPOS_NONE );
                               nRC = zCURSOR_UNCHANGED;  // set k so meta gets reloaded
                            }
                */
            } else {
                // It's there so set the flag so it's not reactivated.
                bReactivate = false;
            }
        } // if ( nEntityType == CM_REFER_TYPE )...
        else {
            // Requesting an Update View.
            zstrcat(sbCM_ViewName, ".u");
            if (GetViewByName(CM_View, sbCM_ViewName.toString(), vZeidonCM, zLEVEL_SUBTASK) < 1) {
                // It's in vActiveMetas but it's not loaded for UPDATE.

                // Change last String in view name from "u" to "r" and try to get THAT view.
                sbCM_ViewName.setCharAt(sbCM_ViewName.length() - 1, 'r');
                if (GetViewByName(CM_View, sbCM_ViewName.toString(), vZeidonCM, zLEVEL_SUBTASK) < 1) {
                    // It's in vActiveMetas but it's not loaded for REFER either.
                    ExcludeEntity(vActiveMetas, "W_MetaDef", zREPOS_NONE);
                    nRC = zCURSOR_UNCHANGED; // set k so meta gets reloaded
                } else {
                    // It's loaded for REFER.
                    if (lTaskID != 0) // any non-zero task id is valid (Win9x has negative IDs)
                    {
                        // Update View might have gotten blown away.
                        SetAttributeFromInteger(vActiveMetas, "W_MetaDef", "TaskID", 0);
                    }

                    bCopyOI = true;
                }
            } else {
                // ERROR situation...
                // It's already loaded for update by somebody else.
                if (lTaskID != 0) // added back 5.10.98 **HH**
                {
                    // if ( lTaskID == SysGetTaskFromView( vListView ) )
                    if (lTaskID == Integer.decode(SysGetTaskFromView(vSubtask).getTaskId())) {
                        if (ObjectInstanceUpdatedFromFile(CM_View) == 0) {
                            bCopyOI = true;
                        }
                    } else {
                        MessageSend(vSubtask, "CM00416", "Configuration Management",
                                "The Meta requested for update is already\nopened for update by another task\nUnable to open!",
                                zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
                        {
                            return -1;
                        }
                    }
                }
            }
        } // if ( nEntityType == CM_REFER_TYPE )...else...

    } // if ( k == zCURSOR_SET )...

    lStatus = GetIntegerFromAttribute(vWkListView, "W_MetaDef", "Status");
    if (nRC != zCURSOR_SET) // not in the Active List
    {
        TraceLineS("(fnActivateMetaOI) Before IncludeSubobject", "vActiveMetas");
        vActiveMetas.logObjectInstance();
        TraceLineS("Before IncludeSubobject", "vWkListView");
        EntityCursor cursorMetaDef = vWkListView.cursor("W_MetaDef");
        cursorMetaDef.logEntity(true);

        if (CheckExistenceOfEntity(vActiveMetas, "W_MetaType") != zCURSOR_SET) {
            if (CheckExistenceOfEntity(vActiveMetas, "LPLR") != zCURSOR_SET) {
                CreateEntity(vActiveMetas, "LPLR", zPOS_AFTER);
                SetMatchingAttributesByName(vActiveMetas, "LPLR", vWkListView, "LPLR", zSET_ALL);
            }

            CreateEntity(vActiveMetas, "W_MetaType", zPOS_AFTER);
            SetMatchingAttributesByName(vActiveMetas, "W_MetaType", vWkListView, "W_MetaType", zSET_ALL);
        }

        IncludeSubobjectFromSubobject(vActiveMetas, "W_MetaDef", vWkListView, "W_MetaDef", zPOS_AFTER);

        TraceLineS("(fnActivateMetaOI) After IncludeSubobject", "vActiveMetas");
        vActiveMetas.logObjectInstance();
        TraceLineS("After IncludeSubobject", "vWkListView");
        cursorMetaDef = vWkListView.cursor("W_MetaDef");
        cursorMetaDef.logEntity(true);

        if ((nEntityType == CM_ACTIVE_TYPE) && (lStatus == 1)) {
            // lCurrentTaskID = SysGetTaskFromView( vListView );
            lCurrentTaskID = Integer.decode(SysGetTaskFromView(vSubtask).getTaskId());
            SetAttributeFromInteger(vActiveMetas, "W_MetaDef", "TaskID", lCurrentTaskID);
        }

        if (nEntityType == CM_REFER_TYPE) {
            // The view may still be hanging around if Zeidon was still open.
            GetStringFromAttribute(sbCM_ViewName, vActiveMetas, "W_MetaDef", "CM_ViewName");
            zstrcat(sbCM_ViewName, ".r");
            if (GetViewByName(CM_View, sbCM_ViewName.toString(), vZeidonCM, zLEVEL_SUBTASK) > 0) {
                // It's loaded for REFER so set the flag so it's not reactivated.
                bReactivate = false;
            }
        }
    }

    // MessageBox.show( primaryStage, "Message Body", "Message Title",
    //                  MessageBox.ICON_INFORMATION | MessageBox.OK | MessageBox.CANCEL );

    // If we don't have to reactivate the object, then create a view and return.
    if (bReactivate == false) // REFER is already activated
    {
        CreateViewFromViewForTask(pvMOI, CM_View, vSubtask);
        ResetView(pvMOI);

        sbCM_ViewName.setLength(1);
        sbCM_ViewName.setCharAt(0, 'r');
        sbCM_ViewName.append(pvMOI.getId());
        SetNameForView(pvMOI, sbCM_ViewName.toString(), vTaskMetas, zLEVEL_SUBTASK | zNAME_AUTODROP);

        /*
              // We no longer set refer views as read-only.  Instead, we check in
              // fnCommitObjectInstance and don't allow commits for REFER views.
              SetViewReadOnly( *pvMOI );
        */

        // If we are activating a Domain, we must position on the correct
        // Domain within the Domain Group.
        if (nOrigType == zSOURCE_DOMAIN_META || nOrigType == zREFER_DOMAIN_META) {
            if (SetCursorFirstEntityByInteger(pvMOI, "Domain", "ZKey", ulOrigMetaOI_ZKey, "") != zCURSOR_SET) {
                SetNameForView(pvMOI, "__MOI_Error", vSubtask, zLEVEL_SUBTASK);
                TraceLine("fnActivateMetaOI cannot find Domain (%d) in DomainGroup ... View: 0x%08x (%s or %s)",
                        ulOrigMetaOI_ZKey, pvMOI.getId(), "__MOI_Error", sbCM_ViewName.toString());
                // DisplayObjectInstance( vWkListView, "", "" );
                MessageSend(vSubtask, "CM00417", "Configuration Management",
                        "Couldn't find Domain in DomainGroup", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);

                return -1;
            }
        }

        // If we are activating a Global Operation, we must position on the
        // correct Operation within the Global Operation Group.
        if (nOrigType == zSOURCE_GO_META || nOrigType == zREFER_GO_META) {
            if (SetCursorFirstEntityByInteger(pvMOI, "Operation", "ZKey", ulOrigMetaOI_ZKey,
                    "") != zCURSOR_SET) {
                SetNameForView(pvMOI, "__MetaGroup_Error", vSubtask, zLEVEL_TASK);
                TraceLine(
                        "Couldn't find \"Operation\" (__MetaGroup_Error view: %s) in Global Op Group by ZKey: %d",
                        sbCM_ViewName.toString(), ulOrigMetaOI_ZKey);
                // DisplayObjectInstance( vWkListView, "", "" );
                MessageSend(vSubtask, "CM00418", "Configuration Management",
                        "Couldn't find Global Op in Global Op Group", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
                return -1;
            }
        }

        DropView(vWkListView);
        return (1);
    }

    if ((nEntityType == CM_ACTIVE_TYPE) && (lStatus == 1)) {
        // lCurrentTaskID = SysGetTaskFromView( vListView );
        lCurrentTaskID = Integer.decode(SysGetTaskFromView(vSubtask).getTaskId());
        SetAttributeFromInteger(vActiveMetas, "W_MetaDef", "TaskID", lCurrentTaskID);
    }

    // If bCopyOI is true, then the meta already exists for REFER, but we need
    // to activate it for SOURCE (i.e. update).  All we need to do is create a
    // new OI from the REFER OI.
    if (bCopyOI) {
        if (ActivateOI_FromOI_ForTask(pvMOI, CM_View, null, zLEVEL_APPLICATION) != 0) {
            MessageSend(vSubtask, "CM00419", "Configuration Management", "Error activating OI from OI",
                    zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
            return -1;
        }
    } else {
        ///////////////////////////////////////////////////////////////////////
        // The Meta needs to be loaded from a file.  We need to know the
        // following:
        //
        // o  The name of the LOD for the meta.
        // o  The name of the portable file that contains the OI.
        //
        // Knowing these, we can then activate the OI from the file.
        //
        ///////////////////////////////////////////////////////////////////////

        // Retrieve the name of the LOD for meta type we are activating.  Note
        // that the LOD name may be changed in the following 'switch' code.
        if (nEntityType == CM_ACTIVE_TYPE) {
            zstrcpy(sbMetaOI_Def, SRC_CMOD[nType].szOD);
        } else {
            zstrcpy(sbMetaOI_Def, REFER_CMOD[nType - 2000].szOD);
        }

        // Find the name of the portable file containing the OI.
        switch (nActiveType) {
        case zSOURCE_VOR_META:
            lMetaOI_ZKey = GetIntegerFromAttribute(vWkListView, "W_MetaDef", "CPLR_ZKey");
            sbMetaOI_Name.setLength(1);
            sbMetaOI_Name.setCharAt(0, 'Z');
            sbMetaOI_Name.append(zltoxa(lMetaOI_ZKey));
            break;

        default:
            sbMetaOI_Name.setLength(0);
            sbMetaOI_Name.append(GetStringFromAttribute(vWkListView, "W_MetaDef", "Name"));
            TruncateName8(sbMetaOI_Name);
            break;

        } // switch ( nActiveType )...

        //BL, 2000.01.13 Load PPE from LPLR, not from system directory
        //               if PPE does not exist in LPLR, then we call the
        //               Function ActivateOI_FromFile, not ActivateMetaOI
        fnGetDirectorySpec(vSubtask, sbFileSpec, nType); // for CompilerSpec, needed to use vSubtask

        // We will get PEs from the system directory and others from the LPLR.
        // if ( nActiveType == zSOURCE_PENV_META )
        //    zgGetZeidonToolsDir( vSubtask, szFileSpec, zAPPL_DIR_OBJECT );
        // else
        //    fnGetDirectorySpec( szFileSpec, nType );

        zstrcat(sbFileSpec, sbMetaOI_Name.toString());
        if (nEntityType == CM_ACTIVE_TYPE) {
            zstrcat(sbFileSpec, SRC_CMOD[nType].szOD_EXT);
        } else {
            zstrcat(sbFileSpec, REFER_CMOD[nType - 2000].szOD_EXT);
        }

        // DGC 10/4/95  Added zIGNORE_ERRORS to ignore activation errors (we
        // wanted to ignore a known error). This should be removed at some point.
        // Finally, activate the OI from the portable file.
        // SfCreateSubtask( &vApplication, vSubtask, szLPLR_Name );  // LPLR "Zeidon"
        nRC = ActivateOI_FromFile(pvMOI, sbMetaOI_Def.toString(), vWkListView, // vApplication,
                sbFileSpec.toString(), zIGNORE_ERRORS | zLEVEL_APPLICATION);
        // SfDropSubtask( vApplication, 0 );
        if (nRC != 0) {
            StringBuilder sbMsg = new StringBuilder();

            zsprintf(sbMsg, "Error activating OI from file: %s", sbFileSpec.toString());
            MessageSend(vSubtask, "CM00420", "Configuration Management", sbMsg.toString(),
                    zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
            return -1;
        }
    }

    // Recreate the view name either for read-only or update.  nPhaseCtl is used
    // by the PostActivate code--it indicates whether we are activating the meta
    // for read-only or update.
    GetStringFromAttribute(sbCM_ViewName, vActiveMetas, "W_MetaDef", "CM_ViewName");
    if (nEntityType == CM_REFER_TYPE) {
        nPhaseCtl = 1;
        zstrcat(sbCM_ViewName, ".r");
    } else {
        nPhaseCtl = 0;
        zstrcat(sbCM_ViewName, ".u");
    }

    // Name the new view.  The view is for the Zeidon system.
    SetNameForView(pvMOI, sbCM_ViewName.toString(), vZeidonCM, zLEVEL_SUBTASK);

    // The current view pvMOI will be used for internal CM use.  We need to create
    // a new view to be passed back to the application that requested the meta.
    zVIEW vTemp = new zVIEW();
    CreateViewFromViewForTask(vTemp, pvMOI, vSubtask); //???
    pvMOI.setView(vTemp.getView());

    // **** Temporary Hack  05.12.1997
    // If this is a LOD, we are going to make sure that all IndentName values
    // are actually indented, since there has been a bug that removes the
    // indentation.  We will also make sure the Indented name is not blank.
    if (nOrigType == zSOURCE_LOD_META || nOrigType == zREFER_LOD_META) {
        zVIEW vTempLOD = new zVIEW();
        int lLevel;
        String szName;
        String szIndentName;
        int k;

        CreateViewFromViewForTask(vTempLOD, pvMOI, null);
        for (nRC = SetCursorFirstEntity(vTempLOD, "LOD_Entity",
                ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vTempLOD, "LOD_Entity", "")) {
            lLevel = GetIntegerFromAttribute(vTempLOD, "LOD_Entity", "IndentLvl");
            szIndentName = GetStringFromAttribute(vTempLOD, "LOD_Entity", "IndentName");
            if ((lLevel > 0 && szIndentName.charAt(0) != ' ') || (szIndentName.length() == 0)) {
                // There is an indentation level but the IndentName is not
                // indented.  Thus we will indent it.
                // Put x blank chars at beginning of indent name, where x is IndentLvl.
                // Then concat the regular names after the blanks.
                // Don't put more than 21 blanks in name.
                k = lLevel < 21 ? lLevel : 21;
                szIndentName = "                         ".substring(0, k);

                szName = GetStringFromAttribute(vTempLOD, "LOD_Entity", "Name");
                zstrcat(szIndentName, szName);
                SetAttributeFromString(vTempLOD, "LOD_Entity", "IndentName", szIndentName);
            }
        }

        DropView(vTempLOD);
    }

    // Now that the object instance has been activated, call the logical
    // object operation for the object type to ensure all appropriate
    // object linking is done.  Use a different view to ensure that the
    // cursors don't get moved in listview.
    sbSyncDate.setLength(0);
    cfPostActivate(vSubtask, nType, sbSyncDate, vZeidonCM.getView(), pvMOI.getView(), vWkListView.getView(),
            nPhaseCtl, false);

    // DGC 8/17/95
    // I don't think the following command is necessary, so I'm going to take it out.
    // ResetView( *pvMOI );

    // If we are activating a Domain, we must position on the correct Domain within the Domain Group.
    if (nOrigType == zSOURCE_DOMAIN_META || nOrigType == zREFER_DOMAIN_META) {
        if (SetCursorFirstEntityByInteger(pvMOI, "Domain", "ZKey", ulOrigMetaOI_ZKey, "") != zCURSOR_SET) {
            TraceLine("fnActivateMetaOI2 cannot find Domain (%d) in DomainGroup ... View: 0x%08x (%s)",
                    ulOrigMetaOI_ZKey, pvMOI.getId(), "__MOI_Error");
            pvMOI.logObjectInstance();
            TraceLineS("EntityInstance", "");
            DisplayEntityInstance(pvMOI, "Domain");
            SetNameForView(pvMOI, "__MOI_Error", vSubtask, zLEVEL_SUBTASK);
            MessageSend(vSubtask, "CM00417", "Configuration Management", "Couldn't find Domain in DomainGroup",
                    zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
            return -1;
        }
    }

    // If we are activating a Global Operation, we must position on the
    // correct Operation within the Global Operation Group.
    if (nOrigType == zSOURCE_GO_META || nOrigType == zREFER_GO_META) {
        if (SetCursorFirstEntityByInteger(pvMOI, "Operation", "ZKey", ulOrigMetaOI_ZKey, "") != zCURSOR_SET) {
            SetNameForView(pvMOI, "MetaGroup", vSubtask, zLEVEL_TASK);
            TraceLine("Couldn't find \"Operation\" (MetaGroup view:%s) in Global Op Group by ZKey: %d",
                    sbCM_ViewName, ulOrigMetaOI_ZKey);
            MessageSend(vSubtask, "CM00418", "Configuration Management",
                    "Couldn't find Global Op in Global Op Group", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
            return -1;
        }
    }

    // Name the view based upon the ZKey and update/refer type for identification by Task.
    sbCM_ViewName.setLength(1);
    if (nEntityType == CM_ACTIVE_TYPE && lStatus == 1) {
        sbCM_ViewName.setCharAt(0, 'u');
    } else {
        sbCM_ViewName.setCharAt(0, 'r');
    }

    sbCM_ViewName.append(pvMOI.getId());
    SetNameForView(pvMOI, sbCM_ViewName.toString(), vTaskMetas, zLEVEL_SUBTASK | zNAME_AUTODROP);

    // We no longer set refer views as read-only.  Instead, we check in
    // fnCommitObjectInstance and don't allow commits for REFER views.
    //
    // if ( (nEntityType != CM_ACTIVE_TYPE) || (lStatus != 1) )
    //    SetViewReadOnly( *pvMOI );

    DropView(vWkListView);

    return (1);
}

From source file:SeedGenerator.MainForm.java

private void btnRunMultitextSearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRunMultitextSearchActionPerformed

    btnStopSearchQueue4.setBackground(Color.GREEN);
    int crawlId = createCrawl(getQueryText(), "SearchEngineCrawler");
    maxPage = Integer.decode(txtMaxPage.getText());

    threadArray = new Thread[maxPage];

    List selist = lstSearchEngines.getSelectedValuesList();

    jProgressBar1.setMaximum(maxPage * selist.size());

    int i = 0;/*from ww w . ja v a2  s.c om*/
    for (Object se : selist) {
        WorkerSearchQueue sworker = new WorkerSearchQueue(this, se.toString(), crawlId, connectionUrl);
        sworker.setName("Worker " + se.toString());
        //threadArray[i++] = sworker;
        threadsSearchQueue[i++] = sworker;
        sworker.start();
        try {

            Thread.sleep(300);
        } catch (Exception ex) {
        } //  search(getSearchEngineFromName((String) se));
    }
    // TODO add your handling code here:
}

From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java

private int fnCommitMetaOI(View vSubtask, View vMOI, int nType, View vActiveMetas, View vZeidonCM, View vLPLR)
        throws IOException {
    int nRC, nEntityType;
    boolean bNewMeta;
    int ReferViewsActive, ReferOI_Active;
    zVIEW vWork1 = new zVIEW();
    zVIEW CM_View = new zVIEW();
    zVIEW MOI_ExecView = new zVIEW();
    zVIEW IncludeView = new zVIEW();
    zVIEW WKS_View = new zVIEW();
    zVIEW vTempLPLR = new zVIEW();
    String szMetaOI_Name; // protect from long name
    StringBuilder sbMetaOI_File = new StringBuilder(); // protect from long name
    String szSubEntityName;/* w w w  .  j a  v  a  2s .  c o  m*/
    String szSubOI_Name;
    StringBuilder sbObjectName = new StringBuilder();
    int lSubType;
    int lMetaOI_ZKey;
    int lSubOI_ZKey;
    StringBuilder sbFileSpec = new StringBuilder();
    // String  szTempFileName[ 2 * zMAX_FILESPEC_LTH + 1 ];
    // String  szTempFileName[ zMAX_FILENAME_LTH + 1 ];
    String szDesc;
    StringBuilder sbMsg = new StringBuilder();
    String szTimestamp = "";
    int lTaskID;
    long lMOI_InstanceID;
    String szCM_ViewName;
    StringBuilder sbNamedView = new StringBuilder();

    TraceLineS("fnCommitMetaOI", "=======================================");

    ReferOI_Active = 0;
    nEntityType = fnVerifyType(nType);
    if (nEntityType < 0) {
        return -1;
    }

    szMetaOI_Name = GetStringFromAttribute(vMOI, SRC_CMOD[nType].szOD_ROOT, SRC_CMOD[nType].szOD_NAME);

    // If the view is read-only, then we can't commit it.
    nRC = MiGetUpdateForView(vMOI);
    if ((nEntityType == CM_REFER_TYPE) || (nRC == 0)) {
        zstrcpy(sbMsg, "The meta passed to CommitMetaOI, ");
        zstrcat(sbMsg, szMetaOI_Name);
        zstrcat(sbMsg, "is not an Active Meta. See Trace");
        TraceLineS("Zeidon Configuration Management", sbMsg.toString());
        TraceLineI("   Type passed is: ", nType);
        MessageSend(vSubtask, "CM00422", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);

        return -1;
    }

    // Get the ZKey for the OI we are about to commit.
    lMetaOI_ZKey = GetIntegerFromAttribute(vMOI, SRC_CMOD[nType].szOD_ROOT, "ZKey");

    // Position on the correct W_MetaType. If it doesn't exist, create one.
    if (SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nType, "") != zCURSOR_SET) {
        // DGC? - Why are we creating an entity?  Shouldn't it already exist?
        // If we are commiting an OI, then it has been activated and therefore
        // the MetaType entity should have been created.

        // It does already exist for reports (so we don't get here ... DKS).
        CreateEntity(vLPLR, "W_MetaType", zPOS_AFTER);
        SetAttributeFromInteger(vLPLR, "W_MetaType", "Type", nType);
    }

    // Position on the correct W_MetaType. If it doesn't exist, create one.
    if (SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nType + 2000, "") != zCURSOR_SET) {
        // DGC? - Why are we creating an entity?  Shouldn't it already exist?
        // If we are commiting an OI, then it has been activated and therefore
        // the MetaType entity should have been created.

        // It does already exist for reports (so we don't get here ... DKS).
        CreateEntity(vLPLR, "W_MetaType", zPOS_AFTER);
        SetAttributeFromInteger(vLPLR, "W_MetaType", "Type", nType + 2000);
    }

    if (SetCursorFirstEntityByAttr(vActiveMetas, "LPLR", "Name", vLPLR, "LPLR", "Name", "") != zCURSOR_SET) {
        MessageSend(vSubtask, "CM00423", "Configuration Management",
                "Unable to locate LPLR Entity in ZeidonCM for CommitMetaOI", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);

        return -1;
    }

    if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaType", "Type", nType, "") != zCURSOR_SET) {
        CreateEntity(vActiveMetas, "W_MetaType", zPOS_AFTER);
        SetAttributeFromInteger(vActiveMetas, "W_MetaType", "Type", nType);
    }

    // Now check for Duplicately named Metas.
    if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "") < zCURSOR_SET) {
        nRC = fnCheckForDuplicateName(vMOI, vLPLR, szMetaOI_Name, lMetaOI_ZKey, 1); // Adding New Meta
    } else {
        if (CompareAttributeToInteger(vActiveMetas, "W_MetaDef", "UpdateInd", 3) == 0) {
            MessageSend(vSubtask, "CM00424", "Configuration Management",
                    "Deleted Meta Def passed to CommitMetaOI", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
            return -1;
        }

        nRC = fnCheckForDuplicateName(vMOI, vLPLR, szMetaOI_Name, lMetaOI_ZKey, 0); // Updating Meta
    }

    if (nRC == -1) {
        return -1;
    }

    if (nRC == 1) // duplicate found and renamed
    {
        szMetaOI_Name = GetStringFromAttribute(vMOI, SRC_CMOD[nType].szOD_ROOT, SRC_CMOD[nType].szOD_NAME);
    }

    if (nType == zSOURCE_DOMAINGRP_META || nType == zSOURCE_GOPGRP_META) {
        // For Global Operation Groups and Domain Groups, check each Global
        // Operation or Domain within the Group to make sure there are no
        // duplicates.
        if (nType == zSOURCE_DOMAINGRP_META) {
            szSubEntityName = "Domain";
            lSubType = zSOURCE_DOMAIN_META;
        } else {
            szSubEntityName = "Operation";
            lSubType = zSOURCE_GO_META;
        }

        CreateViewFromViewForTask(vTempLPLR, vLPLR, vSubtask);
        SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaType", "Type", lSubType + 2000, "");
        nRC = SetCursorFirstEntity(vMOI, szSubEntityName, "");
        while (nRC >= zCURSOR_SET) {
            szSubOI_Name = GetStringFromAttribute(vMOI, szSubEntityName, "Name");
            lSubOI_ZKey = GetIntegerFromAttribute(vMOI, szSubEntityName, "ZKey");
            nRC = fnCheckForDuplicateName(vMOI, vTempLPLR, szSubOI_Name, lSubOI_ZKey, 0);
            if (nRC == -1) {
                return -1;
            }

            nRC = SetCursorNextEntity(vMOI, szSubEntityName, "");
        }

        // For Global Operation Groups and Domain Groups, loop through each
        // operation or domain in the Group and update the names, in case any
        // of those names were changed. Do this first for zSOURCE type and
        // then for zREFER type.
        for (nRC = SetCursorFirstEntity(vMOI, szSubEntityName,
                ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vMOI, szSubEntityName, "")) {
            szSubOI_Name = GetStringFromAttribute(vMOI, szSubEntityName, "Name");
            lSubOI_ZKey = GetIntegerFromAttribute(vMOI, szSubEntityName, "ZKey");

            // zSOURCE type
            SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaType", "Type", lSubType, "");
            nRC = SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaDef", "CPLR_ZKey", lSubOI_ZKey, "");
            if (nRC >= zCURSOR_SET) {
                SetAttributeFromString(vTempLPLR, "W_MetaDef", "Name", szSubOI_Name);
            }

            // zREFER type
            SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaType", "Type", lSubType + 2000, "");
            nRC = SetCursorFirstEntityByInteger(vTempLPLR, "W_MetaDef", "CPLR_ZKey", lSubOI_ZKey, "");
            if (nRC >= zCURSOR_SET) {
                SetAttributeFromString(vTempLPLR, "W_MetaDef", "Name", szSubOI_Name);
            }
        }

        DropView(vTempLPLR);
    }

    // lTaskID = SysGetTaskFromView( vMOI );
    lTaskID = Integer.decode(SysGetTaskFromView(vSubtask).getTaskId());

    if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey,
            "") != zCURSOR_SET) {
        // New Meta
        bNewMeta = true;
    } else {
        // a W_MetaDef exists for this OI in the CM Active list
        bNewMeta = false;
        szCM_ViewName = GetStringFromAttribute(vActiveMetas, "W_MetaDef", "CM_ViewName");
        if (GetViewByName(CM_View, szCM_ViewName + ".u", vZeidonCM, zLEVEL_SUBTASK) < 0) {
            // If such a named view was not found, then the meta was not opened
            // for update.
            MessageSend(vSubtask, "CM00425", "Configuration Management",
                    "The Meta being committed was not Activated for update.", zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
            return -1;
        }

        lMOI_InstanceID = MiGetInstanceID_ForView(CM_View);
        if (CompareAttributeToInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskID) != 0) {
            if (CompareAttributeToInteger(vActiveMetas, "W_MetaDef", "TaskID", 0) == 0) {
                MessageSend(vSubtask, "CM00426", "Configuration Management",
                        "The Meta passed to CommitMetaOI was not opened for Update!",
                        zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
                return -1;
            } else {
                if (MiGetInstanceID_ForView(vMOI) != lMOI_InstanceID) {
                    zstrcpy(sbMsg,
                            "The View to the Meta passed to CommitMetaOI"
                                    + "\nis not to the the same Object Instance for"
                                    + "\nwhich the view was originally opened.");
                    MessageSend(vSubtask, "CM00427", "Configuration Management", sbMsg,
                            zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
                    return -1;
                }
            }
        }

        // Replace the last String in szCM_ViewName with an 'r'.
        if (GetViewByName(CM_View, szCM_ViewName + 'r', vZeidonCM, zLEVEL_SUBTASK) > 0) {
            // REFER OI of Meta exists - Check if there are Views to it
            ReferOI_Active = 1;
            ReferViewsActive = 0;
            lMOI_InstanceID = MiGetInstanceID_ForView(CM_View);
            nRC = DriverApplication.SfGetFirstNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK);
            while (nRC > 0) {
                if (sbNamedView.substring(0, 5).compareTo("__CM.") == 0) {
                    zVIEW vWork2 = new zVIEW();
                    StringBuilder sbTaskView = new StringBuilder();

                    nRC = DriverApplication.SfGetFirstNamedView(vWork2, sbTaskView, vWork1, zLEVEL_SUBTASK);
                    while (nRC > 0) {
                        if (sbTaskView.charAt(0) == 'r') {
                            if (MiGetInstanceID_ForView(vWork2) == lMOI_InstanceID) {
                                ReferViewsActive = 1;
                                break;
                            }
                        }

                        nRC = DriverApplication.SfGetNextNamedView(vWork2, sbTaskView, vWork1, zLEVEL_SUBTASK);
                    }
                }

                if (ReferViewsActive == 1) {
                    return 0;
                }

                nRC = DriverApplication.SfGetNextNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK);
            }

            DropObjectInstance(CM_View);
        }
    }

    if (GetViewByName(WKS_View, "TZCMWKSO", vZeidonCM, zLEVEL_SUBTASK) <= 0) {
        return -1;
    }

    fnGetDirectorySpec(vMOI, sbFileSpec, nType);

    switch (nType) {
    case zSOURCE_VOR_META:
        zltoxa(lMetaOI_ZKey, sbMetaOI_File);
        zstrcat(sbFileSpec, sbMetaOI_File.toString());
        break;

    default:
        if (bNewMeta == false
                && CompareAttributeToString(vActiveMetas, "W_MetaDef", "Name", szMetaOI_Name) != 0) {
            // FileName change
            nRC = zstrlen(sbFileSpec);
            StringBuilder sb = new StringBuilder(GetStringFromAttribute(vActiveMetas, "W_MetaDef", "Name"));
            TruncateName8(sb);
            sbFileSpec.append(sb);
            sbFileSpec.append(SRC_CMOD[nType].szOD_EXT);
            SysOpenFile(vLPLR, sbFileSpec.toString(), COREFILE_DELETE);
            if (nType == zSOURCE_DIALOG_META || nType == zSOURCE_LOD_META) {
                GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir");
                SysAppendcDirSep(sbFileSpec);
                nRC = zstrlen(sbFileSpec);
                sb.setLength(0);
                sb.append(GetStringFromAttribute(vActiveMetas, "W_MetaDef", "Name"));
                TruncateName8(sb);
                sbFileSpec.append(sb);
                if (nType == zSOURCE_LOD_META) {
                    zstrcat(sbFileSpec, ".XOD");
                } else {
                    zstrcat(sbFileSpec, ".XWD");
                }

                SysOpenFile(vLPLR, sbFileSpec.toString(), COREFILE_DELETE);
            }

            fnGetDirectorySpec(vLPLR, sbFileSpec, nType);
        }

        zstrcpy(sbMetaOI_File, szMetaOI_Name);
        TruncateName8(sbMetaOI_File);
        zstrcat(sbFileSpec, sbMetaOI_File);

        break; // default.

    } // switch ( nType )...

    zstrcat(sbFileSpec, SRC_CMOD[nType].szOD_EXT);
    szDesc = GetVariableFromAttribute(0, zTYPE_STRING, 255, vMOI, SRC_CMOD[nType].szOD_ROOT, "Desc", "", 0);

    // Commit the XWD/XRA if a Dialog Meta.
    if (nType == zSOURCE_DIALOG_META || nType == zSOURCE_REPORT_META || nType == zSOURCE_XSLT_META) {
        zVIEW vDialogSubtask = new zVIEW();

        GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir");
        SysAppendcDirSep(sbFileSpec);
        zstrcat(sbFileSpec, sbMetaOI_File);

        GetViewByName(vDialogSubtask, "TZCM_DialogSubtask", vSubtask, zLEVEL_TASK);
        //    MOI_ExecView = ConvertDialog( vDialogSubtask, vMOI, "" );
        if (nType == zSOURCE_DIALOG_META) {
            StringBuilder sbRemotePath = new StringBuilder();
            View vXRA;
            int nLth;

            nLth = zstrlen(sbFileSpec);
            MOI_ExecView.setView(ConvertDialog(vSubtask, vMOI, ""));
            zstrcat(sbFileSpec, ".XWD");
        } else if (nType == zSOURCE_REPORT_META) {
            // Create the Report executable file (.XRP) in the executable meta
            // directory, which is a flattened version of the Report source
            // (.PRP) in the source meta directory.  The executable is flattened
            // by putting all controls to the Control level (moving CtrlCtrl
            // entities directly under the appropriate Group entities as Control
            // entities ... no recursive relationships).
            /*
               fnGetDirectorySpec( szFileSpec, nType );
               zstrcpy( szMetaOI_File, szMetaOI_Name );
               TruncateName8( szMetaOI_File );
               zstrcat( szFileSpec, szMetaOI_File );
               zstrcat( szFileSpec, SRC_CMOD[ nType ].szOD_EXT );
                    
               GetViewByName( &vTempLPLR, "TaskLPLR", vSubtask, zLEVEL_TASK );
               GetStringFromAttribute( szFileSpecExec,
                            vTempLPLR, "LPLR", "ExecDir" );
               SysAppendcDirSep( szFileSpecExec );
               zstrcat( szFileSpecExec, szMetaOI_File );
               zstrcat( szFileSpecExec, ".XRP" );
               SysCopyFile( szFileSpec, szFileSpecExec, true );
               break;
            */

            MOI_ExecView.setView(ConvertReport(vLPLR, vMOI, ""));
            zstrcat(sbFileSpec, ".XRP");
        } else {
            // Create the XSLT executable file (.XSL) in the executable meta
            // directory, which is a flattened version of the Report source
            // (.PSL) in the source meta directory.  The executable is flattened
            // by putting all controls to the Control level (moving CtrlCtrl
            // entities directly under the appropriate Group entities as Control
            // entities ... no recursive relationships).

            MOI_ExecView.setView(ConvertXSLT(vLPLR, vMOI, ""));
            zstrcat(sbFileSpec, ".XSL");
        }

        nRC = CommitOI_ToFile(MOI_ExecView, sbFileSpec.toString(), zSINGLE);
        if (nRC != 0) {
            zstrcpy(sbMsg, "CommitMetaOI failed trying to save ");
            zstrcat(sbMsg, sbFileSpec);
            MessageSend(vSubtask, "CM00428", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR,
                    0);
            return -1;
        }

        DropObjectInstance(MOI_ExecView);
        fnGetDirectorySpec(vMOI, sbFileSpec, nType);
        zstrcat(sbFileSpec, sbMetaOI_File);
        zstrcat(sbFileSpec, SRC_CMOD[nType].szOD_EXT);
    }

    // Decide what control flags should be used based on the current file
    // version and the INI settings.
    nRC = fnAllowBinaryDataInSourceMetaFiles(vLPLR);
    if (nRC == 1) {
        // Keep it the same format.
        if (MiCompareOI_ToRelease(vMOI, releaseCompatible) <= 0) {
            MiSetOI_ReleaseForView(vMOI, releaseCompatible);
            nRC = CommitOI_ToFile(vMOI, sbFileSpec.toString(), zSINGLE);
        } else {
            MiSetOI_ReleaseForView(vMOI, releaseCurrent);
            nRC = CommitOI_ToFile(vMOI, sbFileSpec.toString(), zSINGLE | zENCODE_BLOBS | zNO_NULL_STRING_TERM);
        }
    } else if (nRC == 2) {
        // Force it to compatibility format.
        MiSetOI_ReleaseForView(vMOI, releaseCompatible);
        nRC = CommitOI_ToFile(vMOI, sbFileSpec.toString(), zSINGLE);
    } else {
        // Use the current release version of the software.
        MiSetOI_ReleaseForView(vMOI, releaseCurrent);
        nRC = CommitOI_ToFile(vMOI, sbFileSpec.toString(), zSINGLE | zENCODE_BLOBS | zNO_NULL_STRING_TERM);
    }

    if (nRC != 0) {
        zstrcpy(sbMsg, "CommitMetaOI failed trying to save ");
        zstrcat(sbMsg, sbFileSpec);
        MessageSend(vSubtask, "CM00429", "Configuration Management", sbMsg.toString(),
                zMSGQ_OBJECT_CONSTRAINT_ERROR, 0);
        return -1;
    }

    if (ReferOI_Active == 1) {
        if (nType != zSOURCE_DIALOG_META && nType != zSOURCE_REPORT_META && nType != zSOURCE_XSLT_META
                && nType != zSOURCE_UIS_META) {
            ActivateMetaOI_ByZKey(vSubtask, CM_View, vWork1, nType + 2000, zLEVEL_SUBTASK, lMetaOI_ZKey, 0);

            // If we are committing a DomainGroup, relink it with any ERDs
            // that are currently in memory.
            if (nType == zSOURCE_DOMAINGRP_META) {
                zVIEW vDomainGrp = new zVIEW();

                nRC = DriverApplication.SfGetFirstNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK);
                while (nRC > 0) {
                    if (sbNamedView.substring(0, 5).compareTo("__CM.") == 0) {
                        sbObjectName.setLength(0);
                    } else {
                        MiGetObjectNameForView(sbObjectName, vWork1);
                    }

                    if (zstrcmp(sbObjectName.toString(), "TZEREMDO") == 0) {
                        // Loop through all Domains in ER and Relink any of those
                        // Domains to the current DomainGrp that are a part of that
                        // DomainGrp.
                        CreateViewFromViewForTask(vDomainGrp, vMOI, vSubtask);
                        for (nRC = SetCursorFirstEntity(vWork1, "Domain",
                                "EntpER_Model"); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vWork1, "Domain",
                                        "EntpER_Model")) {
                            nRC = SetCursorFirstEntityByAttr(vDomainGrp, "Domain", "ZKey", vWork1, "Domain",
                                    "ZKey", "");
                            if (nRC >= 0) {
                                RelinkInstanceToInstance(vWork1, "Domain", vDomainGrp, "Domain");
                            }
                        }

                        DropView(vDomainGrp);
                    }

                    nRC = DriverApplication.SfGetNextNamedView(vWork1, sbNamedView, vZeidonCM, zLEVEL_SUBTASK);
                }
            }

            DropMetaOI(vSubtask, CM_View);
        }
    }

    // Reset to correct W_MetaType in case of PostActivate having changed
    // position.
    SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nType + 2000, "");
    if (SetCursorFirstEntityByInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "") != zCURSOR_SET) {
        // Corresponding W_MetaDef Not Found - New Meta.
        CreateEntity(vLPLR, "W_MetaDef", zPOS_AFTER);
        SetAttributeFromInteger(vLPLR, "W_MetaDef", "Status", 1);
    }

    SetAttributeFromString(vLPLR, "W_MetaDef", "Name", szMetaOI_Name);
    szTimestamp = SysGetDateTime(szTimestamp);
    SetAttributeFromString(vLPLR, "W_MetaDef", "LastUpdateDate", szTimestamp);
    SetAttributeFromString(vLPLR, "W_MetaDef", "LastSyncDate", szTimestamp);
    SetAttributeFromInteger(vLPLR, "W_MetaDef", "UpdateInd", 2);
    SetAttributeFromInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey);
    SetAttributeFromString(vLPLR, "W_MetaDef", "Desc", szDesc);

    // Include W_MetaDef to Active MetaDef if not already there.
    CreateViewFromViewForTask(IncludeView, vLPLR, vSubtask);
    SetCursorFirstEntityByInteger(vLPLR, "W_MetaType", "Type", nType, "");
    if (SetCursorFirstEntityByInteger(vLPLR, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey, "") != zCURSOR_SET) {
        // New
        IncludeSubobjectFromSubobject(vLPLR, "W_MetaDef", IncludeView, "W_MetaDef", zPOS_AFTER);

        //BL, 1999.12.29  if check in, then this Meta does exists in
        //                View vActiveMetas
        if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "CPLR_ZKey", lMetaOI_ZKey,
                "") != zCURSOR_SET) {
            IncludeSubobjectFromSubobject(vActiveMetas, "W_MetaDef", vLPLR, "W_MetaDef", zPOS_AFTER);
        }

        szCM_ViewName = GetStringFromAttribute(vActiveMetas, "W_MetaDef", "CM_ViewName");
        CreateViewFromViewForTask(CM_View, vMOI, vSubtask);
        SetNameForView(CM_View, szCM_ViewName + ".u", vZeidonCM, zLEVEL_SUBTASK);
        SetAttributeFromInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskID);
    }

    DropView(IncludeView);
    zgSortEntityWithinParent(zASCENDING, vLPLR, "W_MetaDef", "Name", "");

    switch (nType) {
    case zSOURCE_ERD_META:
        // Make sure that all LODs are eliminated from the Active Metas list.
        if (SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaType", "Type", zSOURCE_LOD_META,
                "") >= zCURSOR_SET) {
            for (nRC = SetCursorFirstEntity(vActiveMetas, "W_MetaDef",
                    ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vActiveMetas, "W_MetaDef", "")) {
                GetStringFromAttribute(sbNamedView, vActiveMetas, "W_MetaDef", "CM_ViewName");
                zstrcat(sbNamedView, ".r");
                if (GetViewByName(CM_View, sbNamedView.toString(), vZeidonCM, zLEVEL_SUBTASK) > 0) {
                    DropObjectInstance(CM_View);
                }

                ExcludeEntity(vActiveMetas, "W_MetaDef", zREPOS_NONE);
            }
        }

        break;

    case zSOURCE_LOD_META:
        SetNameForView(vMOI, "TZZOLODO", vSubtask, zLEVEL_TASK);
        oTZZOXODO_SaveXOD(vSubtask, vMOI);

        // Get access to the newly built XOD.
        if (GetViewByName(MOI_ExecView, "TZZOXODO", vSubtask, zLEVEL_TASK) < 1) {
            zstrcpy(sbMsg, "(fnCommitMetaOI) Unable to Access XOD.  XOD must be opened.");
            MessageSend(vSubtask, "CM00430", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR,
                    0);
            return -1;
        }

        // Save the XOD to a file.
        GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir");
        SysAppendcDirSep(sbFileSpec);
        zstrcat(sbFileSpec, sbMetaOI_File);
        zstrcat(sbFileSpec, ".XOD");
        if (CommitOI_ToFile(MOI_ExecView, sbFileSpec.toString(), zSINGLE) != 0) {
            zstrcpy(sbMsg, "Commit of XOD failed.");
            MessageSend(vSubtask, "CM00431", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR,
                    0);
            return -1;
        }

        break;

    case zSOURCE_PENV_META:
        MOI_ExecView.setView(CreatePE_ExecVersion(vLPLR, vMOI));
        GetStringFromAttribute(sbFileSpec, vLPLR, "LPLR", "ExecDir");
        SysAppendcDirSep(sbFileSpec);
        zstrcat(sbFileSpec, "ZEIDON.XPE");
        if (CommitOI_ToFile(MOI_ExecView, sbFileSpec.toString(), zSINGLE) != 0) {
            zstrcpy(sbMsg, "Commit of Executable Presentation Environment -\n");
            zstrcpy(sbMsg, sbFileSpec);
            zstrcpy(sbMsg, " failed.");
            MessageSend(vSubtask, "CM00432", "Configuration Management", sbMsg, zMSGQ_OBJECT_CONSTRAINT_ERROR,
                    0);
            return -1;
        }

        break;

    case zSOURCE_GOPGRP_META:
    case zSOURCE_DOMAINGRP_META: {
        zVIEW vWorkRefer = new zVIEW();
        zVIEW vWorkSource = new zVIEW();
        int lStatus;
        int lSourceItem;
        int lReferItem;
        String lpchItemName;
        String lpchGroupName;

        // We have just committed a group (e.g.  DomainGroup).  We need to
        // create a W_MetaDef entity for each item in the group (e.g.
        // domain) so that CM can then activate an item by name.

        // The logic is the same for both domain and GO groups, but some of
        // the values are different, so we set up some variables.
        if (nType == zSOURCE_DOMAINGRP_META) {
            lReferItem = zREFER_DOMAIN_META;
            lSourceItem = zSOURCE_DOMAIN_META;
            lpchItemName = "Domain"; // Name of the item ent.
            lpchGroupName = "DomainGroup"; // Name of group entity.
        } else {
            lReferItem = zREFER_GO_META;
            lSourceItem = zSOURCE_GO_META;
            lpchItemName = "Operation"; // Name of the item ent.
            lpchGroupName = "GlobalOperationGroup"; // Name of group entity.
        }

        CreateViewFromViewForTask(vWorkRefer, vLPLR, vSubtask);
        CreateViewFromViewForTask(vWorkSource, vLPLR, vSubtask);

        // #ifdef DEBUG
        //          SetNameForView( vWorkRefer, "WorkRefer", vSubtask, zLEVEL_TASK );
        //          SetNameForView( vWorkSource, "WorkSource", vSubtask, zLEVEL_TASK );
        // #endif

        // Get the value of W_MetaDef.Status from the group W_MetaDef. If the
        // attribute isn't set then set lStatus = -1. Otherwise lStatus will
        // be 0 or 1.  Later on when we're setting W_MetaDef.Status for the
        // domain, if lStatus = -1 then we'll leave W_MetaDef.Status as null.
        // NOTE:  We are assuming that the view vLPLR is pointing to the
        // correct group W_MetaDef.
        MutableInt mi = new MutableInt();
        if (GetIntegerFromAttribute(mi, vLPLR, "W_MetaDef", "Status") < 0) {
            lStatus = -1;
        } else {
            lStatus = mi.intValue();
        }

        // Find the item Meta type (eg Domain). If it doesn't exist, create it.
        if (SetCursorFirstEntityByInteger(vWorkSource, "W_MetaType", "Type", lSourceItem, "") != zCURSOR_SET) {
            CreateEntity(vWorkSource, "W_MetaType", zPOS_LAST);
            SetAttributeFromInteger(vWorkSource, "W_MetaType", "Type", lSourceItem);
        }

        // Same for REFER
        if (SetCursorFirstEntityByInteger(vWorkRefer, "W_MetaType", "Type", lReferItem, "") != zCURSOR_SET) {
            CreateEntity(vWorkRefer, "W_MetaType", zPOS_LAST);
            SetAttributeFromInteger(vWorkRefer, "W_MetaType", "Type", lReferItem);
        }

        // Loop through each of the items in the MetaDef, looking for items
        // with GroupName that matches the name of the group.  If it doesn't
        // exist in the Meta OI, then it's been deleted from the Meta and it
        // needs to be deleted from the item list.
        for (nRC = SetCursorFirstEntityByAttr(vWorkRefer, "W_MetaDef", "GroupName", vMOI, lpchGroupName, "Name",
                ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntityByAttr(vWorkRefer, "W_MetaDef", "GroupName",
                        vMOI, lpchGroupName, "Name", "")) {
            // Try to find the item in the Meta OI by ZKey.  If it doesn't exist,
            // then it no longer exists in the Meta OI and needs to be deleted
            // from the LPLR.
            if (SetCursorFirstEntityByAttr(vMOI, lpchItemName, "ZKey", vWorkRefer, "W_MetaDef", "CPLR_ZKey",
                    "") != zCURSOR_SET) {
                DeleteEntity(vWorkRefer, "W_MetaDef", zREPOS_NONE);
            }
        }

        // Loop through each of the items in the group.  If it doesn't
        // exist in the Refer LPLR, add it to both source and refer.
        for (nRC = SetCursorFirstEntity(vMOI, lpchItemName,
                ""); nRC >= zCURSOR_SET; nRC = SetCursorNextEntity(vMOI, lpchItemName, "")) {
            // Try to find the W_MetaDef by ZKey.  If it doesn't exist, then it
            // needs to be created.
            if (SetCursorFirstEntityByAttr(vWorkRefer, "W_MetaDef", "CPLR_ZKey", vMOI, lpchItemName, "ZKey",
                    "") != zCURSOR_SET) {
                // Create entity in refer meta type
                CreateEntity(vWorkRefer, "W_MetaDef", zREPOS_LAST);
                SetAttributeFromAttribute(vWorkRefer, "W_MetaDef", "Name", vMOI, lpchItemName, "Name");
                SetAttributeFromAttribute(vWorkRefer, "W_MetaDef", "CPLR_ZKey", vMOI, lpchItemName, "ZKey");
                SetAttributeFromAttribute(vWorkRefer, "W_MetaDef", "GroupName", vMOI, lpchGroupName, "Name");
                if (lStatus >= 0) {
                    SetAttributeFromInteger(vWorkRefer, "W_MetaDef", "Status", lStatus);
                }

                // Create entity in source meta type
                CreateEntity(vWorkSource, "W_MetaDef", zREPOS_LAST);
                SetAttributeFromAttribute(vWorkSource, "W_MetaDef", "Name", vMOI, lpchItemName, "Name");
                SetAttributeFromAttribute(vWorkSource, "W_MetaDef", "CPLR_ZKey", vMOI, lpchItemName, "ZKey");
                SetAttributeFromAttribute(vWorkSource, "W_MetaDef", "GroupName", vMOI, lpchGroupName, "Name");

                // If lStatus is not -1, then we need to set status in W_MetaDef.
                if (lStatus >= 0) {
                    SetAttributeFromInteger(vWorkSource, "W_MetaDef", "Status", lStatus);
                }
            }

        } // for...

        DropView(vWorkRefer);
        DropView(vWorkSource);

        break;

    } // case zSOURCE_DOMAINGRP_META...

    } // switch ( nType )...

    if (CommitLPLR(vLPLR) == 0) {
        if (CommitWorkstation(WKS_View) == 0) {
            return (1);
        }
    }

    return -1;
}

From source file:com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance.java

/**
 * Retrieve a L2PcInstance from the characters table of the database and add it in _allObjects of the L2world.<BR>
 * <BR>//from  w  w  w  . jav  a  2s  .com
 * <B><U> Actions</U> :</B><BR>
 * <BR>
 * <li>Retrieve the L2PcInstance from the characters table of the database</li> <li>Add the L2PcInstance object in _allObjects</li> <li>Set the x,y,z position of the L2PcInstance and make it invisible</li> <li>Update the overloaded status of the L2PcInstance</li><BR>
 * <BR>
 * @param objectId Identifier of the object to initialized
 * @return The L2PcInstance loaded from the database
 */
private static L2PcInstance restore(final int objectId) {
    L2PcInstance player = null;
    double curHp = 0;
    double curCp = 0;
    double curMp = 0;

    Connection con = null;
    try {
        // Retrieve the L2PcInstance from the characters table of the database
        con = L2DatabaseFactory.getInstance().getConnection(false);

        final PreparedStatement statement = con.prepareStatement(RESTORE_CHARACTER);
        statement.setInt(1, objectId);
        final ResultSet rset = statement.executeQuery();

        while (rset.next()) {
            final int activeClassId = rset.getInt("classid");
            final boolean female = rset.getInt("sex") != 0;
            final L2PcTemplate template = CharTemplateTable.getInstance().getTemplate(activeClassId);
            PcAppearance app = new PcAppearance(rset.getByte("face"), rset.getByte("hairColor"),
                    rset.getByte("hairStyle"), female);

            player = new L2PcInstance(objectId, template, rset.getString("account_name"), app);
            player.setName(rset.getString("char_name"));
            player._lastAccess = rset.getLong("lastAccess");

            player.getStat().setExp(rset.getLong("exp"));
            player.setExpBeforeDeath(rset.getLong("expBeforeDeath"));
            player.getStat().setLevel(rset.getByte("level"));
            player.getStat().setSp(rset.getInt("sp"));

            player.setWantsPeace(rset.getInt("wantspeace"));

            player.setHeading(rset.getInt("heading"));

            player.setKarma(rset.getInt("karma"));
            player.setPvpKills(rset.getInt("pvpkills"));
            player.setPkKills(rset.getInt("pkkills"));
            player.setOnlineTime(rset.getLong("onlinetime"));
            player.setNewbie(rset.getInt("newbie") == 1);
            player.setNoble(rset.getInt("nobless") == 1);
            player.setClanJoinExpiryTime(rset.getLong("clan_join_expiry_time"));
            player.setFirstLog(rset.getInt("first_log"));
            player.pcBangPoint = rset.getInt("pc_point");
            app = null;

            if (player.getClanJoinExpiryTime() < System.currentTimeMillis()) {
                player.setClanJoinExpiryTime(0);
            }
            player.setClanCreateExpiryTime(rset.getLong("clan_create_expiry_time"));
            if (player.getClanCreateExpiryTime() < System.currentTimeMillis()) {
                player.setClanCreateExpiryTime(0);
            }

            final int clanId = rset.getInt("clanid");
            player.setPowerGrade((int) rset.getLong("power_grade"));
            player.setPledgeType(rset.getInt("subpledge"));
            player.setLastRecomUpdate(rset.getLong("last_recom_date"));
            // player.setApprentice(rset.getInt("apprentice"));

            if (clanId > 0) {
                player.setClan(ClanTable.getInstance().getClan(clanId));
            }

            if (player.getClan() != null) {
                if (player.getClan().getLeaderId() != player.getObjectId()) {
                    if (player.getPowerGrade() == 0) {
                        player.setPowerGrade(5);
                    }
                    player.setClanPrivileges(player.getClan().getRankPrivs(player.getPowerGrade()));
                } else {
                    player.setClanPrivileges(L2Clan.CP_ALL);
                    player.setPowerGrade(1);
                }
            } else {
                player.setClanPrivileges(L2Clan.CP_NOTHING);
            }

            player.setDeleteTimer(rset.getLong("deletetime"));

            player.setTitle(rset.getString("title"));
            player.setAccessLevel(rset.getInt("accesslevel"));
            player.setFistsWeaponItem(player.findFistsWeaponItem(activeClassId));
            player.setUptime(System.currentTimeMillis());

            curHp = rset.getDouble("curHp");
            curCp = rset.getDouble("curCp");
            curMp = rset.getDouble("curMp");

            /*
             * player.setCurrentHp(rset.getDouble("curHp")); player.setCurrentCp(rset.getDouble("curCp")); player.setCurrentMp(rset.getDouble("curMp"));
             */

            // Check recs
            player.checkRecom(rset.getInt("rec_have"), rset.getInt("rec_left"));

            player._classIndex = 0;
            try {
                player.setBaseClass(rset.getInt("base_class"));
            } catch (final Exception e) {
                if (Config.ENABLE_ALL_EXCEPTIONS)
                    e.printStackTrace();

                player.setBaseClass(activeClassId);
            }

            // Restore Subclass Data (cannot be done earlier in function)
            if (restoreSubClassData(player)) {
                if (activeClassId != player.getBaseClass()) {
                    for (final SubClass subClass : player.getSubClasses().values())
                        if (subClass.getClassId() == activeClassId) {
                            player._classIndex = subClass.getClassIndex();
                        }
                }
            }
            if (player.getClassIndex() == 0 && activeClassId != player.getBaseClass()) {
                // Subclass in use but doesn't exist in DB -
                // a possible restart-while-modifysubclass cheat has been attempted.
                // Switching to use base class
                player.setClassId(player.getBaseClass());
                LOGGER.warn("Player " + player.getName()
                        + " reverted to base class. Possibly has tried a relogin exploit while subclassing.");
            } else {
                player._activeClass = activeClassId;
            }

            player.setApprentice(rset.getInt("apprentice"));
            player.setSponsor(rset.getInt("sponsor"));
            player.setLvlJoinedAcademy(rset.getInt("lvl_joined_academy"));
            player.setIsIn7sDungeon(rset.getInt("isin7sdungeon") == 1 ? true : false);

            player.setPunishLevel(rset.getInt("punish_level"));
            if (player.getPunishLevel() != PunishLevel.NONE)
                player.setPunishTimer(rset.getLong("punish_timer"));
            else
                player.setPunishTimer(0);
            /*
             * player.setInJail(rset.getInt("in_jail") == 1 ? true : false); if(player.isInJail()) { player.setJailTimer(rset.getLong("jail_timer")); } else { player.setJailTimer(0); } player.setChatBanTimer(rset.getLong("banchat_time")); player.updateChatBanState();
             */

            try {
                player.getAppearance().setNameColor(Integer.decode(
                        new StringBuilder().append("0x").append(rset.getString("name_color")).toString())
                        .intValue());
                player.getAppearance().setTitleColor(Integer.decode(
                        new StringBuilder().append("0x").append(rset.getString("title_color")).toString())
                        .intValue());
            } catch (final Exception e) {
                if (Config.ENABLE_ALL_EXCEPTIONS)
                    e.printStackTrace();

                // leave them as default
            }

            CursedWeaponsManager.getInstance().checkPlayer(player);

            player.setAllianceWithVarkaKetra(rset.getInt("varka_ketra_ally"));

            player.setDeathPenaltyBuffLevel(rset.getInt("death_penalty_level"));
            player.setAio(rset.getInt("aio") == 1 ? true : false);
            player.setAioEndTime(rset.getLong("aio_end"));
            // Add the L2PcInstance object in _allObjects
            // L2World.getInstance().storeObject(player);

            // Set the x,y,z position of the L2PcInstance and make it invisible
            player.setXYZInvisible(rset.getInt("x"), rset.getInt("y"), rset.getInt("z"));

            // Retrieve the name and ID of the other characters assigned to this account.
            PreparedStatement stmt = con.prepareStatement(
                    "SELECT obj_Id, char_name FROM characters WHERE account_name=? AND obj_Id<>?");
            stmt.setString(1, player._accountName);
            stmt.setInt(2, objectId);
            ResultSet chars = stmt.executeQuery();

            while (chars.next()) {
                final Integer charId = chars.getInt("obj_Id");
                final String charName = chars.getString("char_name");
                player._chars.put(charId, charName);
            }

            chars.close();
            stmt.close();
            chars = null;
            stmt = null;

            break;
        }

        DatabaseUtils.close(rset);
        DatabaseUtils.close(statement);

        if (player == null) {
            // TODO: Log this!
            return null;
        }

        // Retrieve from the database all secondary data of this L2PcInstance
        // and reward expertise/lucky skills if necessary.
        // Note that Clan, Noblesse and Hero skills are given separately and not here.
        player.restoreCharData();
        // reward skill restore mode in order to avoid duplicate storage of already stored skills
        player.rewardSkills(true);

        // Restore pet if exists in the world
        player.setPet(L2World.getInstance().getPet(player.getObjectId()));
        if (player.getPet() != null) {
            player.getPet().setOwner(player);
        }

        // Update the overloaded status of the L2PcInstance
        player.refreshOverloaded();

        player.restoreFriendList();
    } catch (final Exception e) {
        LOGGER.error("Could not restore char data", e);
        e.printStackTrace();
    } finally {
        CloseUtil.close(con);
    }

    if (player != null) {
        player.fireEvent(EventType.LOAD.name, (Object[]) null);

        try {
            Thread.sleep(100);
        } catch (final InterruptedException e) {
            e.printStackTrace();
        }

        // once restored all the skill status, update current CP, MP and HP
        player.setCurrentHpDirect(curHp);
        player.setCurrentCpDirect(curCp);
        player.setCurrentMpDirect(curMp);
        // player.setCurrentCp(curCp);
        // player.setCurrentMp(curMp);
    }
    return player;
}

From source file:com.quinsoft.zeidon.zeidonoperations.KZOEP1AA.java

private int fnCheckCM_ForActiveMetaByTask(View vSubtask, long MOI_InstanceID) {
    zVIEW vWork = new zVIEW();
    zVIEW vZeidonCM = new zVIEW();
    zVIEW vActiveMetas = new zVIEW();
    int nOI_Found;
    String szViewName;//w w w .  jav a2 s.  c  o m
    long lInstanceID;
    int lTaskID;
    int nRC;

    GetViewByName(vWork, "TaskLPLR", vSubtask, zLEVEL_TASK);
    nOI_Found = 0;
    // lTaskID = SysGetTaskFromView( vSubtask );
    lTaskID = Integer.decode(SysGetTaskFromView(vSubtask).getTaskId());

    // Get the view to ZedionCM OI.
    GetViewByName(vZeidonCM, "ZeidonCM", vSubtask, zLEVEL_APPLICATION);

    // Get the view to the ActiveMeta OI.
    GetViewByName(vActiveMetas, "OpenCM_Metas", vZeidonCM, zLEVEL_SUBTASK);
    nRC = SetCursorFirstEntityByInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskID, "LPLR");
    while ((nRC == zCURSOR_SET) || (nRC == zCURSOR_SET_NEWPARENT)) {
        szViewName = GetStringFromAttribute(vActiveMetas, "W_MetaDef", "CM_ViewName");
        zstrcat(szViewName, ".u");
        if (GetViewByName(vWork, szViewName, vZeidonCM, zLEVEL_SUBTASK) < 0) {
            nRC = SetCursorNextEntityByInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskID, "LPLR");
        } else {
            lInstanceID = MiGetInstanceID_ForView(vWork);
            if (lInstanceID != MOI_InstanceID) {
                nRC = SetCursorNextEntityByInteger(vActiveMetas, "W_MetaDef", "TaskID", lTaskID, "LPLR");
            } else {
                nRC = zCURSOR_NULL;
                nOI_Found = 1;
            }
        }
    }

    return (nOI_Found);
}

From source file:com.l2jfree.gameserver.gameobjects.L2Player.java

private final void restoreNameTitleColors() {
    Connection con = null;// w w  w .j a  va2  s .  c  o  m
    try {
        con = L2DatabaseFactory.getInstance().getConnection();
        PreparedStatement statement = con.prepareStatement(RESTORE_COLORS);
        statement.setInt(1, getObjectId());
        ResultSet result = statement.executeQuery();
        if (result.next()) {
            getAppearance().setNameColor(Util.reverseRGBChanels(Integer.decode("0x" + result.getString(1))));
            getAppearance().setTitleColor(Util.reverseRGBChanels(Integer.decode("0x" + result.getString(2))));
        } else {
            getAppearance().setNameColor(PlayerAppearance.DEFAULT_NAME_COLOR);
            getAppearance().setTitleColor(PlayerAppearance.DEFAULT_TITLE_COLOR);
        }
        result.close();
        statement.close();
    } catch (Exception e) {
        getAppearance().setNameColor(PlayerAppearance.DEFAULT_NAME_COLOR);
        getAppearance().setTitleColor(PlayerAppearance.DEFAULT_TITLE_COLOR);

        _log.error("Could not load character name/title colors!", e);
    } finally {
        L2DatabaseFactory.close(con);
    }
    updateNameTitleColor();
}

From source file:com.clark.func.Functions.java

/**
 * <p>//from  w  w w  .  java 2s.  c  o  m
 * Convert a <code>String</code> to a <code>Integer</code>, handling hex and
 * octal notations.
 * </p>
 * 
 * <p>
 * Returns <code>null</code> if the string is <code>null</code>.
 * </p>
 * 
 * @param str
 *            a <code>String</code> to convert, may be null
 * @return converted <code>Integer</code>
 * @throws NumberFormatException
 *             if the value cannot be converted
 */
public static Integer createInteger(String str) {
    if (str == null) {
        return null;
    }
    // decode() handles 0xAABD and 0777 (hex and octal) as well.
    return Integer.decode(str);
}