0

Background: I am using an appian-plugin where Java is the main language to do customizations.

I have inserted codes into a class that belongs to the plugin working space and whenever I maven clean install, at the clean process, my codes will be gone. I heard from other colleagues that it could be because of a .wsdl file that automatically generates files when it's redeployed? Kindly do advise. Thank you.

This is the extract of code that I'm trying to insert.

public static Comparator <DummyFormData> sortWageIncrementFinancialYr = new Comparator <Dummy>() {
        public int compare(DummyFormData u1, DummyFormData u2) {
            int compare1 = u1.financialYr.get(0);
            int compare2 = u2.financialYr.get(0);
            
            Boolean result = compare1 > compare2;
            return result  ? 1 : -1;
        }
        
    };

.wsdl codes relating to this

 <xs:complexType name="DummyFormData">
                <xs:sequence>
                <xs:element name="financialYr" type="xs:int" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="totalWagesOfWorkers" type="xs:decimal" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
                <xs:element name="numOfWorkers" type="xs:int" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
                </xs:sequence>
                 </xs:complexType>
Marcus Moo
  • 196
  • 1
  • 2
  • 20
  • is your code part of target folder? – sanjeevRm Apr 15 '21 at 09:01
  • @sanjeevRm hi yes it is! just checked – Marcus Moo Apr 15 '21 at 09:02
  • 3
    probably the class you are modifying is auto generated based on the wsdl, so it gets overwritten on every deploy. easiest approach would be to put your code in a class that is not generated automatically – Lazar Petrovic Apr 15 '21 at 09:02
  • mvn clean will delete target folder, but it should be generated once you run **mvn install** – sanjeevRm Apr 15 '21 at 09:05
  • @LazarPetrovic is there a way to ensure that this extract of codes get written automatically as well? Because comparator collections.sort require me to code it in this class! – Marcus Moo Apr 15 '21 at 09:08
  • @sanjeevRm yes install works to compile the jar . but I'm worried that when it shifts up the development repo to higher environments, whenever it compiles, it'll erase the code and 'screw' the system – Marcus Moo Apr 15 '21 at 09:08
  • @LazarPetrovic maybe one way is to write into the wsdl to include the extract of code I have written? – Marcus Moo Apr 15 '21 at 09:10
  • Do your think that this input into wsdl will work??? I'm not sure the type is "xs:int" – Marcus Moo Apr 15 '21 at 09:14
  • @MarcusMoo you can supply any comparator to sort `Collections.sort(list, comparator)`. This is the easiest way in my opinion, that way you don't have to deal with the lib that generates code from the wsdl – Lazar Petrovic Apr 15 '21 at 09:21
  • FWIW, your Comparator is incorrect for "equals" case. Just use `Integer.compare(int,int)` – Gyro Gearless Apr 15 '21 at 09:25

0 Answers0